Remove dead code from zend_declare_typed_property()#21391
Remove dead code from zend_declare_typed_property()#21391iluuu1994 wants to merge 3 commits intophp:masterfrom
Conversation
Since phpGH-15878, trait properties are bound before linking the parent class. Since phpGH-21358, trait properties don't redeclare locally declared properties. With these two changes, declared properties are never redeclared, and as such we can remove this case from zend_declare_typed_property().
|
Would this need to be reintroduced if we want to resolve |
I don't know exactly what you mean, but FWIU your case doesn't involve properties, so probably not? |
Possibly, but for clarity I meant that if a trait is declared as such: trait T {
public self $v;
}
class C {
use T;
}if this affects "redeclaring" the type of |
No redeclaration happens in this case. So inferring |
| if ($this->type === "class" && isset($this->extends[0])) { | ||
| $parent = "class_entry_" . str_replace("\\", "_", $this->extends[0]->toString()); | ||
| $code .= "\n\tzend_do_inheritance_ex(class_entry, $parent, 0);"; | ||
| } | ||
| $code .= "\n\tzend_build_properties_info_table(class_entry);\n"; | ||
|
|
||
| if (!empty($implements)) { | ||
| $code .= "\tzend_class_implements(class_entry, " . count($implements) . ", " . implode(", ", $implements) . ");\n"; | ||
| } |
There was a problem hiding this comment.
Do you need to emit preprocessor checks on PHP_VERSION_ID for this or is the new output compatible with earlier PHP versions?
There was a problem hiding this comment.
Technically compatible, though I think it's a good point that the previous behavior should likely be maintained for older PHP versions when regenerating stubs. I'll ship this in a different PR entirely. Also still need to check why zend_test fails.
Since GH-15878, trait properties are bound before linking the parent class. Since GH-21358, trait properties don't redeclare locally declared properties. With these two changes, declared properties are never redeclared, and as such we can remove this case from zend_declare_typed_property().