Skip to content

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jan 26, 2025

This issue has been open for a while, and it's easy to fix, we just have to agree what is right.
As per my comment, I sent an email to internals to see what people think: https://externals.io/message/126224

…DEF zval for uninitialized typed properties
"Property %s::$%s does not exist", ZSTR_VAL(ce->name), ZSTR_VAL(name));
if (prop) {
zend_throw_exception_ex(reflection_exception_ptr, 0,
"Property %s::$%s is not initialized and no default was provided", ZSTR_VAL(ce->name), ZSTR_VAL(name));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should say "Typed property (...)" to emphasize that this is for typed props?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we not just use the existing message that is already used when uninitialized accessing typed properties?

Typed static property C::$prop must not be accessed before initialization

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, and then just as an Error rather than a ReflectionException or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to the standard wording. Although I like the custom message that I had put (as it indicates why the exception is thrown more precisely), I see the appeal of using the standard wording.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@nielsdos nielsdos closed this in 6e84c41 Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReflectionClass::getStaticPropertyValue() returns UNDEF zval for uninitialized typed properties
2 participants