Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let closure created from magic method accept named parameters
- Loading branch information
Showing
4 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--TEST-- | ||
Trampoline closure created from magic method accepts named arguments | ||
--FILE-- | ||
<?php | ||
|
||
class Test { | ||
public function __call($name, $args) { | ||
var_dump($name, $args); | ||
} | ||
public static function __callStatic($name, $args) { | ||
var_dump($name, $args); | ||
} | ||
} | ||
|
||
$test = new Test; | ||
|
||
echo "-- Non-static cases --\n"; | ||
$test->test(1, 2, a: 123); | ||
$test->test(...)(1, 2); | ||
$test->test(...)(1, 2, a: 123, b: $test); | ||
$test->test(...)(a: 123, b: $test); | ||
$test->test(...)(); | ||
|
||
echo "-- Static cases --\n"; | ||
Test::testStatic(1, 2, a: 123); | ||
Test::testStatic(...)(1, 2); | ||
Test::testStatic(...)(1, 2, a: 123, b: $test); | ||
Test::testStatic(...)(a: 123, b: $test); | ||
Test::testStatic(...)(); | ||
|
||
?> | ||
--EXPECT-- | ||
-- Non-static cases -- | ||
string(4) "test" | ||
array(3) { | ||
[0]=> | ||
int(1) | ||
[1]=> | ||
int(2) | ||
["a"]=> | ||
int(123) | ||
} | ||
string(4) "test" | ||
array(2) { | ||
[0]=> | ||
int(1) | ||
[1]=> | ||
int(2) | ||
} | ||
string(4) "test" | ||
array(4) { | ||
[0]=> | ||
int(1) | ||
[1]=> | ||
int(2) | ||
["a"]=> | ||
int(123) | ||
["b"]=> | ||
object(Test)#1 (0) { | ||
} | ||
} | ||
string(4) "test" | ||
array(2) { | ||
["a"]=> | ||
int(123) | ||
["b"]=> | ||
object(Test)#1 (0) { | ||
} | ||
} | ||
string(4) "test" | ||
array(0) { | ||
} | ||
-- Static cases -- | ||
string(10) "testStatic" | ||
array(3) { | ||
[0]=> | ||
int(1) | ||
[1]=> | ||
int(2) | ||
["a"]=> | ||
int(123) | ||
} | ||
string(10) "testStatic" | ||
array(2) { | ||
[0]=> | ||
int(1) | ||
[1]=> | ||
int(2) | ||
} | ||
string(10) "testStatic" | ||
array(4) { | ||
[0]=> | ||
int(1) | ||
[1]=> | ||
int(2) | ||
["a"]=> | ||
int(123) | ||
["b"]=> | ||
object(Test)#1 (0) { | ||
} | ||
} | ||
string(10) "testStatic" | ||
array(2) { | ||
["a"]=> | ||
int(123) | ||
["b"]=> | ||
object(Test)#1 (0) { | ||
} | ||
} | ||
string(10) "testStatic" | ||
array(0) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters