Implementation ideas for adding early warning for mis-use of "parent"?
| From: | Levi Morrison | Date: | Sun, 22 Jul 2018 00:05:22 +0000 |
| Subject: | Implementation ideas for adding early warning for mis-use of "parent"? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-102946@lists.php.net to get a copy of this message | ||
This code the illustrates the issue; it has no errors or warnings:
```php
class A {
function m(): parent {
return $this;
}
}
```
However, if you run the method you will get an error. I want to add a
light warning such as E_STRICT or E_DEPRECATED at compile time.
Using CG(active_class_entry)->parent will not work at compile time, so
that strategy is out.
Given that
zend_compile_func_decl is not called directly from
zend_compile_class_decl it would be difficult to pass the parent's
name in any way other than a compiler global. Is there anything in
particular I need to do if I add another compiler global? I intend to
set and unset it in zend_compile_class_decl.
Anyone have a better way to pass around the parent's name at compile time?