- Added parseOrderedOperand() to handle operand evaluation in correct sequence - Updated BinaryOpTrait to use ordered parsing for concat() operations - Modified CallArgumentGenerator to materialize nested calls before argument lowering - Enhanced CompilerBase to maintain evaluation order in string interpolations - Updated MethodCallTrait to evaluate receiver before method arguments - Added comprehensive test case for function/method call argument evaluation orderpull/47/head
parent
833b74b344
commit
ca41af9bb5
6 changed files with 93 additions and 15 deletions
@ -0,0 +1,64 @@ |
||||
--TEST-- |
||||
Function, method, static and generated helper call arguments evaluate left-to-right |
||||
--FILE-- |
||||
<?php |
||||
function traced(string $label, string $value): string |
||||
{ |
||||
echo $label, "\n"; |
||||
return $value; |
||||
} |
||||
|
||||
function combine(string $left, string $right): string |
||||
{ |
||||
return $left . $right; |
||||
} |
||||
|
||||
class CallOrder |
||||
{ |
||||
public function method(string $left, string $right): string |
||||
{ |
||||
return $left . $right; |
||||
} |
||||
|
||||
public static function staticMethod(string $left, string $right): string |
||||
{ |
||||
return $left . $right; |
||||
} |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
var_dump(combine(traced('function-left', 'a'), traced('function-right', 'b'))); |
||||
|
||||
$function = 'combine'; |
||||
var_dump($function(traced('dynamic-function-left', 'i'), traced('dynamic-function-right', 'j'))); |
||||
|
||||
$object = new CallOrder(); |
||||
var_dump($object->method(traced('method-left', 'c'), traced('method-right', 'd'))); |
||||
|
||||
$method = 'method'; |
||||
var_dump($object->$method(traced('dynamic-method-left', 'k'), traced('dynamic-method-right', 'l'))); |
||||
|
||||
var_dump(CallOrder::staticMethod(traced('static-left', 'e'), traced('static-right', 'f'))); |
||||
var_dump(traced('concat-left', 'g') . traced('concat-right', 'h')); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
function-left |
||||
function-right |
||||
string(2) "ab" |
||||
dynamic-function-left |
||||
dynamic-function-right |
||||
string(2) "ij" |
||||
method-left |
||||
method-right |
||||
string(2) "cd" |
||||
dynamic-method-left |
||||
dynamic-method-right |
||||
string(2) "kl" |
||||
static-left |
||||
static-right |
||||
string(2) "ef" |
||||
concat-left |
||||
concat-right |
||||
string(2) "gh" |
||||
Loading…
Reference in new issue