closure_027.phpt 608 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Closure 027: Testing Closure type-hint
  3. --FILE--
  4. <?php
  5. function test(closure $a) {
  6. var_dump($a());
  7. }
  8. test(function() { return new stdclass; });
  9. test(function() { });
  10. $a = function($x) use ($y) {};
  11. test($a);
  12. test(new stdclass);
  13. ?>
  14. --EXPECTF--
  15. object(stdClass)#%d (0) {
  16. }
  17. NULL
  18. Notice: Undefined variable: y in %s on line %d
  19. Warning: Missing argument 1 for {closure}(), called in %s on line %d and defined in %s on line %d
  20. NULL
  21. Catchable fatal error: Argument 1 passed to test() must be an instance of Closure, instance of stdClass given, called in %s on line %d and defined in %s on line %d