Re: Implementation ideas for adding early warning for mis-use of "parent"?
| From: | Levi Morrison | Date: | Wed, 25 Jul 2018 01:48:51 +0000 |
| Subject: | Re: Implementation ideas for adding early warning for mis-use of "parent"? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102967@lists.php.net to get a copy of this message | ||
On Tue, Jul 24, 2018 at 1:15 AM Stanislav Malyshev <smalyshev@gmail.com> wrote:
>
> Hi!
>
> > Please note that for traits and closures it's not possible to determine
> > this at compile time.
>
> Why not for closures? I thought closures are bound at definition site,
> and thus should know everything at compile time?
>
> --
> Stas Malyshev
> smalyshev@gmail.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
Closures can be rebound to another scope; see [Closure::bindTo][1]'s
second parameter.
I have a [pull request][2] that adds a compile-time warning for usages
of "parent" without a parent. It need a review; there is a case where
the warning is emitted twice and I don't know what to do.
[1]: https://secure.php.net/manual/en/closure.bindto.php
[2]: https://github.com/php/php-src/pull/3404