File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / closure_040.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (12 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

--TEST--
Closure 040: Rebinding closures, bad arguments
--FILE--
<?php

class A {
	private $x;
	private static $xs = 10;
	
	public function __construct($v) {
		$this->x = $v;
	}
	
	public function getIncrementor() {
		return function() { return ++$this->x; };
	}
	public function getStaticIncrementor() {
		return static function() { return ++static::$xs; };
	}
}

$a = new A(20);

$ca = $a->getIncrementor();
$cas = $a->getStaticIncrementor();

$ca->bindTo($a, array());
$ca->bindTo(array(), 'A');
$ca->bindTo($a, array(), "");
$ca->bindTo();
$cas->bindTo($a, 'A');

?>
--EXPECTF--
Notice: Array to string conversion in %s on line %d

Warning: Class 'Array' not found in %s on line %d

Warning: Closure::bindTo() expects parameter 1 to be object, array given in %s on line 25

Warning: Closure::bindTo() expects at most 2 parameters, 3 given in %s on line %d

Warning: Closure::bindTo() expects at least 1 parameter, 0 given in %s on line %d

Warning: Cannot bind an instance to a static closure in %s on line %d

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>