2015-10-19 12:19 GMT+03:00 Nikita Popov <nikita....@gmail.com>:

> This change is primarily targeting userland methods, so your use-case is
> exactly the one this is supposed to prevent. Note that you can still use
> ->bindTo($object). The only thing you cannot do is ->bindTo($object,
> get_class($object)).



It's very pity ( It was a very interesting feature that gives a birth for
userland AOP, without it part of framework functionality *will be lost*.
>From the list of attached bugs I can see that all weird stuff happens only
with internal classes/functions/methods. I never have seen a segfaults in
my code that heavily uses closure rebinding with userland methods/classes
and expect it to work in all future versions of PHP, starting from >=5.4.

I don't know PHP engine well, but this feature with scope rebinding for
methods allows some interesting patterns, like "Spy", "Field initializer",
"Lazy proxy initializer", etc. We just take one method and bind it to
another scope to perform an additional logic if needed.

Maybe, apply your patch only to internal functions (restrict them to have
$this inside) and simple functions? This will cover most bugs, but won't
break an exisitng code.

Reply via email to