ReflectionFunction_getClosure_basic.phpt 856 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Test ReflectionFunction::getClosure() function : basic functionality
  3. --FILE--
  4. <?php
  5. /* Prototype : public mixed ReflectionFunction::getClosure()
  6. * Description: Returns a dynamically created closure for the function
  7. * Source code: ext/reflection/php_reflection.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing ReflectionFunction::getClosure() : basic functionality ***\n";
  11. function foo()
  12. {
  13. var_dump( "Inside foo function" );
  14. }
  15. function bar( $arg )
  16. {
  17. var_dump( "Arg is " . $arg );
  18. }
  19. $func = new ReflectionFunction( 'foo' );
  20. $closure = $func->getClosure();
  21. $closure();
  22. $func = new ReflectionFunction( 'bar' );
  23. $closure = $func->getClosure();
  24. $closure( 'succeeded' );
  25. ?>
  26. ===DONE===
  27. --EXPECTF--
  28. *** Testing ReflectionFunction::getClosure() : basic functionality ***
  29. string(19) "Inside foo function"
  30. string(16) "Arg is succeeded"
  31. ===DONE===