closure_040.phpt 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Closure 040: Rebinding closures, bad arguments
  3. --FILE--
  4. <?php
  5. class A {
  6. private $x;
  7. private static $xs = 10;
  8. public function __construct($v) {
  9. $this->x = $v;
  10. }
  11. public function getIncrementor() {
  12. return function() { return ++$this->x; };
  13. }
  14. public function getStaticIncrementor() {
  15. return static function() { return ++static::$xs; };
  16. }
  17. }
  18. $a = new A(20);
  19. $ca = $a->getIncrementor();
  20. $cas = $a->getStaticIncrementor();
  21. $ca->bindTo($a, array());
  22. $ca->bindTo(array(), 'A');
  23. $ca->bindTo($a, array(), "");
  24. $ca->bindTo();
  25. $cas->bindTo($a, 'A');
  26. ?>
  27. --EXPECTF--
  28. Notice: Array to string conversion in %s on line %d
  29. Warning: Class 'Array' not found in %s on line %d
  30. Warning: Closure::bindTo() expects parameter 1 to be object, array given in %s on line 25
  31. Warning: Closure::bindTo() expects at most 2 parameters, 3 given in %s on line %d
  32. Warning: Closure::bindTo() expects at least 1 parameter, 0 given in %s on line %d
  33. Warning: Cannot bind an instance to a static closure in %s on line %d