Add compile-time warning on invalid parent use#3564
Add compile-time warning on invalid parent use#3564morrisonlevi wants to merge 1 commit intophp:masterfrom
Conversation
Zend/zend_compile.c
Outdated
| zend_string *extends_name = zend_ast_get_str(extends_ast); | ||
| CG(active_class_entry_parent_name) = zend_resolve_class_name( | ||
| extends_name, | ||
| extends_ast->kind == ZEND_AST_ZVAL ? extends_ast->attr : ZEND_NAME_FQ); |
There was a problem hiding this comment.
This is no longer necessary, you can use ce->parent_name.
There was a problem hiding this comment.
Thanks - will rework the patch.
There was a problem hiding this comment.
@nikic How do I know if it's safe to use parent or parent_name in that union?
There was a problem hiding this comment.
During compilation it should always be parent_name. Otherwise the ZEND_ACC_LINKED flag.
|
Okay, the branch is now passing travis tests. Could I get another review? |
|
Comment on behalf of petk at php.net: Labelling |
|
The changes for I've just fixed an existing related bug in 41af1e6. |
|
I have refactored the |
|
I've committed the parent check as a hard error in a9e6667. I think the BC break here is both very minor and easy to fix, so going through a deprecation period is more trouble than it is worth. |
> - Core > Using "parent" inside a class without parent is deprecated, and will throw > a compile-time error in the future. Currently an error will only be > generated if/when the parent is accessed at run-time. Refs: * https://github.com/php/php-src/blob/42cc58ff7b2fee1c17a00dc77a4873552ffb577f/UPGRADING#L303 * php/php-src#3404 * php/php-src#3564 * php/php-src@a9e6667 (originally committed as hard compile time error) * php/php-src@deb44d4 (reverted back to deprecation error)
This is a new attempt at fixing the issue from PR #3404.