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