@@ -94,6 +94,11 @@ public static function evaluate(
9494                return  self ::sqlDay ($ conn , $ scope , $ expr , $ row , $ result );
9595            case  'LAST_DAY ' :
9696                return  self ::sqlLastDay ($ conn , $ scope , $ expr , $ row , $ result );
97+             case  'CURDATE ' :
98+             case  'CURRENT_DATE ' :
99+                 return  self ::sqlCurDate ($ expr );
100+             case  'WEEKDAY ' :
101+                 return  self ::sqlWeekDay ($ conn , $ scope , $ expr , $ row , $ result );
97102        }
98103
99104        throw  new  ProcessorException ("Function  "  . $ expr ->functionName  . " not implemented yet " );
@@ -203,6 +208,10 @@ public static function getColumnSchema(
203208            case  'NOW ' :
204209                return  new  Column \DateTime ();
205210
211+             case  'CURDATE ' :
212+             case  'CURRENT_DATE ' :
213+                 return  new  Column \Date ();
214+ 
206215            case  'DATE ' :
207216            case  'LAST_DAY ' :
208217                $ arg  = Evaluator::getColumnSchema ($ expr ->args [0 ], $ scope , $ columns );
@@ -230,6 +239,7 @@ public static function getColumnSchema(
230239
231240            case  'DATEDIFF ' :
232241            case  'DAY ' :
242+             case  'WEEKDAY ' :
233243                return  new  Column \IntColumn (false , 10 );
234244        }
235245
@@ -1007,6 +1017,49 @@ private static function sqlLastDay(
10071017        return  (new  \DateTimeImmutable ($ subject ))->format ('Y-m-t ' );
10081018    }
10091019
1020+     /** 
1021+      * @param array<string, mixed> $row 
1022+      */ 
1023+     private  static  function  sqlCurDate (FunctionExpression   $ expr ): string 
1024+     {
1025+         $ args  = $ expr ->args ;
1026+ 
1027+         if  (\count ($ args ) !== 0 ) {
1028+             throw  new  ProcessorException ("MySQL CURDATE() function takes no arguments. " );
1029+         }
1030+ 
1031+         return  (new  \DateTimeImmutable ())->format ('Y-m-d ' );
1032+     }
1033+ 
1034+     /** 
1035+      * @param array<string, mixed> $row 
1036+      */ 
1037+     private  static  function  sqlWeekDay (
1038+         FakePdoInterface   $ conn ,
1039+         Scope   $ scope ,
1040+         FunctionExpression   $ expr ,
1041+         array  $ row ,
1042+         QueryResult   $ result
1043+     ) : ?int  {
1044+         $ args  = $ expr ->args ;
1045+ 
1046+         if  (\count ($ args ) !== 1 ) {
1047+             throw  new  ProcessorException ("MySQL WEEKDAY() function must be called with one argument " );
1048+         }
1049+ 
1050+         $ subject  = Evaluator::evaluate ($ conn , $ scope , $ args [0 ], $ row , $ result );
1051+ 
1052+         if  (!is_string ($ subject )) {
1053+             throw  new  \TypeError ('Failed assertion ' );
1054+         }
1055+ 
1056+         if  (!$ subject  || \strpos ($ subject , '0000-00-00 ' ) === 0 ) {
1057+             return  null ;
1058+         }
1059+ 
1060+         return  (int )(new  \DateTimeImmutable ($ subject ))->format ('N ' );
1061+     }
1062+ 
10101063    /** 
10111064     * @param array<string, mixed> $row 
10121065     * 
0 commit comments