phper-framework / phper

The framework that allows us to write PHP extensions using pure and safe Rust whenever possible.
Other
295 stars 17 forks source link

Cannot override abstract classes in PHP #150

Closed florianschieder closed 8 months ago

florianschieder commented 9 months ago

Example:

Trying to construct an object which derives the abstract class results in a panic here. The current implementation seems like it only tries to lookup the state constructor from the current Zend class entry. I assume subclassing an abstract class exposed by Rust should either set the state constructor for derived classes properly or the current implementation of create_object() should scan the entire inheritance tree until it finds the proper state constructor.

Please let me know if you need further information to reproduce the issue. Thank you in advance!

jmjoy commented 9 months ago

You are right, I can reproduce this issue.

The reason is subclass will rewrite the create_object to parent's.

https://github.com/php/php-src/blob/171e3986b044875ca252ef59dbb4d1b68a7e3d6c/Zend/zend_inheritance.c#L137

I will fix this problem later, or if you are interested, you can also submit a PR.