4 changed files with 117 additions and 5 deletions
-
39ext/reflection/php_reflection.c
-
25ext/reflection/tests/closures_003.phpt
-
27ext/reflection/tests/closures_004.phpt
-
31ext/reflection/tests/reflectionParameter_invalidMethodInConstructor.phpt
@ -0,0 +1,25 @@ |
|||
--TEST-- |
|||
Reflection on closures: Segfaults with getParameters() and getDeclaringFunction() |
|||
--FILE-- |
|||
<?php |
|||
|
|||
$closure = function($a, $b = 0) { }; |
|||
|
|||
$method = new ReflectionMethod ($closure); |
|||
$params = $method->getParameters (); |
|||
unset ($method); |
|||
$method = $params[0]->getDeclaringFunction (); |
|||
unset ($params); |
|||
echo $method->getName ()."\n"; |
|||
|
|||
$parameter = new ReflectionParameter ($closure, 'b'); |
|||
$method = $parameter->getDeclaringFunction (); |
|||
unset ($parameter); |
|||
echo $method->getName ()."\n"; |
|||
|
|||
?> |
|||
===DONE=== |
|||
--EXPECTF-- |
|||
__invoke |
|||
__invoke |
|||
===DONE=== |
|||
@ -0,0 +1,27 @@ |
|||
--TEST-- |
|||
Reflection on closures: Segfault with getClosure() on closure itself |
|||
--FILE-- |
|||
<?php |
|||
|
|||
$closure = function() { echo "Invoked!\n"; }; |
|||
|
|||
$method = new ReflectionMethod ($closure); |
|||
|
|||
$closure2 = $method->getClosure ($closure); |
|||
|
|||
$closure2 (); |
|||
$closure2->__invoke (); |
|||
|
|||
unset ($closure); |
|||
|
|||
$closure2 (); |
|||
$closure2->__invoke (); |
|||
|
|||
?> |
|||
===DONE=== |
|||
--EXPECTF-- |
|||
Invoked! |
|||
Invoked! |
|||
Invoked! |
|||
Invoked! |
|||
===DONE=== |
|||
@ -0,0 +1,31 @@ |
|||
--TEST-- |
|||
ReflectionParameter::__construct(): Invalid method as constructor |
|||
--FILE-- |
|||
<?php |
|||
|
|||
// Invalid class name |
|||
try { |
|||
new ReflectionParameter (array ('A', 'b'), 0); |
|||
} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } |
|||
|
|||
// Invalid class method |
|||
try { |
|||
new ReflectionParameter (array ('C', 'b'), 0); |
|||
} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } |
|||
|
|||
// Invalid object method |
|||
try { |
|||
new ReflectionParameter (array (new C, 'b'), 0); |
|||
} catch (ReflectionException $e) { echo $e->getMessage ()."\n"; } |
|||
|
|||
echo "Done.\n"; |
|||
|
|||
class C { |
|||
} |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Class A does not exist |
|||
Method C::b() does not exist |
|||
Method C::b() does not exist |
|||
Done. |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue