--TEST-- Testing Closure::fromCallable() functionality: Basic --FILE-- closePrivateValid(); echo $fn(" OK".PHP_EOL); echo "Instance return private static method as callable"; $foo = new Foo; $fn = $foo->closePrivateStatic(); echo $fn(" OK".PHP_EOL); echo 'Instance return protected static method as callable'; $subFoo = new SubFoo; $fn = $subFoo->closeProtectedStaticMethod(); echo $fn(" OK".PHP_EOL); echo 'Subclass closure over parent class protected method'; $subFoo = new SubFoo; $fn = $subFoo->closeProtectedValid(); echo $fn(" OK".PHP_EOL); echo 'Subclass closure over parent class static protected method'; $subFoo = new SubFoo; $fn = $subFoo->closeProtectedStaticMethod(); echo $fn(" OK".PHP_EOL); echo 'Access public instance method of parent object through "parent::" '; $subFoo = new SubFoo; $fn = $subFoo->getParentPublicInstanceMethod(); echo $fn(" OK".PHP_EOL); echo 'Access public instance method of self object through "self::" '; $foo = new Foo; $fn = $foo->getSelfColonPublicInstanceMethod(); echo $fn(" OK".PHP_EOL); echo 'Access public instance method of parent object through "self::" to parent method'; $foo = new SubFoo; $fn = $foo->getSelfColonParentPublicInstanceMethod(); echo $fn(" OK".PHP_EOL); echo 'Access proteced instance method of parent object through "self::" to parent method'; $foo = new SubFoo; $fn = $foo->getSelfColonParentProtectedInstanceMethod(); echo $fn(" OK".PHP_EOL); echo 'MagicCall __call instance method '; $fn = Closure::fromCallable([new MagicCall, 'nonExistentMethod']); echo $fn(" OK".PHP_EOL); echo 'MagicCall __callStatic static method '; $fn = Closure::fromCallable(['MagicCall', 'nonExistentMethod']); echo $fn(" OK".PHP_EOL); ?> ===DONE=== --EXPECT-- Access public static function OK Access public static function with different case OK Access public static function with colon scheme OK Access public instance method of object OK Access public instance method of parent object through parent:: OK Function that exists OK Function that exists with different spelling OK Closure is already a closure OK Class with public invokable OK Instance return private method as callable OK Instance return private static method as callable OK Instance return protected static method as callable OK Subclass closure over parent class protected method OK Subclass closure over parent class static protected method OK Access public instance method of parent object through "parent::" OK Access public instance method of self object through "self::" OK Access public instance method of parent object through "self::" to parent method OK Access proteced instance method of parent object through "self::" to parent method OK MagicCall __call instance method __call,nonExistentMethod, OK MagicCall __callStatic static method __callStatic,nonExistentMethod, OK ===DONE===