com php-src: Rename ::apply to ::call for the sake of JS consistency: Zend/tests/closure_apply.phpt Zend/tests/closure_call .phpt Zend/zend_closures.c

From: Date: Wed, 30 Jul 2014 00:26:53 +0000
Subject: com php-src: Rename ::apply to ::call for the sake of JS consistency: Zend/tests/closure_apply.phpt Zend/tests/closure_call .phpt Zend/zend_closures.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81165@lists.php.net to get a copy of this message
Commit: f65bdda469dfc30bd28652a6aa94d369eac1b6b2 Author: Andrea Faulds <ajf@ajf.me> Wed, 30 Jul 2014 01:26:53 +0100 Parents: d67ec70a4c11b8da9b579ef79825f905629f305c Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f65bdda469dfc30bd28652a6aa94d369eac1b6b2 Log: Rename ::apply to ::call for the sake of JS consistency Changed paths: D Zend/tests/closure_apply.phpt A Zend/tests/closure_call.phpt M Zend/zend_closures.c Diff: diff --git a/Zend/tests/closure_apply.phpt b/Zend/tests/closure_apply.phpt deleted file mode 100644 index 9599031..0000000 --- a/Zend/tests/closure_apply.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Closure::apply ---FILE-- -<?php - -class Foo { - public $x = 0; - function bar() { - return function () { - return $this->x; - }; - } -} - -$foo = new Foo; -$qux = $foo->bar(); - -$foobar = new Foo; -$foobar->x = 3; - -var_dump($qux()); -var_dump($qux->apply($foo)); -var_dump($qux->apply($foobar)); - - -$bar = function () { - return $this->x; -}; - -$elePHPant = new StdClass; -$elePHPant->x = 7; - -var_dump($bar->apply($elePHPant)); - - -$beta = function ($z) { - return $this->x * $z; -}; - -var_dump($beta->apply($elePHPant, 3)); - -?> ---EXPECT-- -int(0) -int(0) -int(3) -int(7) -int(21) \ No newline at end of file diff --git a/Zend/tests/closure_call.phpt b/Zend/tests/closure_call.phpt new file mode 100644 index 0000000..7a65817 --- /dev/null +++ b/Zend/tests/closure_call.phpt @@ -0,0 +1,48 @@ +--TEST-- +Closure::call +--FILE-- +<?php + +class Foo { + public $x = 0; + function bar() { + return function () { + return $this->x; + }; + } +} + +$foo = new Foo; +$qux = $foo->bar(); + +$foobar = new Foo; +$foobar->x = 3; + +var_dump($qux()); +var_dump($qux->call($foo)); +var_dump($qux->call($foobar)); + + +$bar = function () { + return $this->x; +}; + +$elePHPant = new StdClass; +$elePHPant->x = 7; + +var_dump($bar->call($elePHPant)); + + +$beta = function ($z) { + return $this->x * $z; +}; + +var_dump($beta->call($elePHPant, 3)); + +?> +--EXPECT-- +int(0) +int(0) +int(3) +int(7) +int(21) \ No newline at end of file diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 39f5a0e..72823a5 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -70,9 +70,9 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */ } /* }}} */ -/* {{{ proto mixed Closure::apply(object $to [, mixed $parameter] [, mixed $...] ) +/* {{{ proto mixed Closure::call(object $to [, mixed $parameter] [, mixed $...] ) Call closure, binding to a given object */ -ZEND_METHOD(Closure, apply) /* {{{ */ +ZEND_METHOD(Closure, call) /* {{{ */ { zval *zclosure, *newthis, *closure_result_ptr = NULL; zend_closure *closure; @@ -457,7 +457,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_bind, 0, 0, 2) ZEND_ARG_INFO(0, unbound_scoped) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_apply, 0, 0, 1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_closure_call, 0, 0, 1) ZEND_ARG_INFO(0, newthis) ZEND_ARG_VARIADIC_INFO(0, parameters) ZEND_END_ARG_INFO() @@ -466,7 +466,7 @@ static const zend_function_entry closure_functions[] = { ZEND_ME(Closure, __construct, NULL, ZEND_ACC_PRIVATE) ZEND_ME(Closure, bind, arginfo_closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_MALIAS(Closure, bindTo, bind, arginfo_closure_bindto, ZEND_ACC_PUBLIC) - ZEND_ME(Closure, apply, arginfo_closure_apply, ZEND_ACC_PUBLIC) + ZEND_ME(Closure, call, arginfo_closure_call, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} };

« previous php.cvs (#81165) next »