Re: Closures and $this
| From: | Stanislav Malyshev | Date: | Thu, 19 Nov 2009 18:22:53 +0000 |
| Subject: | Re: Closures and $this | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46110@lists.php.net to get a copy of this message | ||
Hi!
If php-people really would like rebinding $this, I beleive this should be done via method like Closure->bindTo() - to make the fact of rebinding clear in the code. However, there is a problem with rebinding $this - that was not mentioned yet, I think.This can be a problem, but since PHP is not a compiled language, this problem already exists - all method names are only checked in runtime anyway, so it doesn't matter if you rebind the closure or not. Of course, with rebinding you can easily shoot yourself in the foot by calling non-existing method - but so you can with $foo->$bar() or $foo() or a number of other ways. So I think if this construct is expressed in a way that makes the intent clear (i.e., no implicit rebinding) then it would be OK. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com