2015-05-08 13:28:54 +08:00
|
|
|
--TEST--
|
|
|
|
Bug #68475 Calling function using $callable() syntax with strings of form 'Class::method'
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
class TestClass
|
|
|
|
{
|
|
|
|
public static function staticMethod()
|
|
|
|
{
|
|
|
|
echo "Static method called!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function staticMethodWithArgs($arg1, $arg2, $arg3)
|
|
|
|
{
|
|
|
|
printf("Static method called with args: %s, %s, %s\n", $arg1, $arg2, $arg3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test basic call using Class::method syntax.
|
|
|
|
$callback = 'TestClass::staticMethod';
|
|
|
|
$callback();
|
|
|
|
|
|
|
|
// Case should not matter.
|
|
|
|
$callback = 'testclass::staticmethod';
|
|
|
|
$callback();
|
|
|
|
|
|
|
|
$args = ['arg1', 'arg2', 'arg3'];
|
|
|
|
$callback = 'TestClass::staticMethodWithArgs';
|
|
|
|
|
|
|
|
// Test call with args.
|
|
|
|
$callback($args[0], $args[1], $args[2]);
|
|
|
|
|
|
|
|
// Test call with splat operator.
|
|
|
|
$callback(...$args);
|
|
|
|
|
|
|
|
// Reference undefined method.
|
|
|
|
$callback = 'TestClass::undefinedMethod';
|
|
|
|
try {
|
|
|
|
$callback();
|
2015-05-17 05:49:14 +08:00
|
|
|
} catch (Error $e) {
|
2015-05-08 13:28:54 +08:00
|
|
|
echo $e->getMessage() . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reference undefined class.
|
|
|
|
$callback = 'UndefinedClass::testMethod';
|
|
|
|
try {
|
|
|
|
$callback();
|
2015-05-17 05:49:14 +08:00
|
|
|
} catch (Error $e) {
|
2015-05-08 13:28:54 +08:00
|
|
|
echo $e->getMessage() . "\n";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
Static method called!
|
|
|
|
Static method called!
|
|
|
|
Static method called with args: arg1, arg2, arg3
|
|
|
|
Static method called with args: arg1, arg2, arg3
|
|
|
|
Call to undefined method TestClass::undefinedMethod()
|
2020-05-26 20:10:57 +08:00
|
|
|
Class "UndefinedClass" not found
|