Skip to content

Document DelayedTargetValidation attribute (PHP 8.5)#5457

Open
jordikroon wants to merge 3 commits intophp:masterfrom
jordikroon:attribute/delated-target-validation
Open

Document DelayedTargetValidation attribute (PHP 8.5)#5457
jordikroon wants to merge 3 commits intophp:masterfrom
jordikroon:attribute/delated-target-validation

Conversation

@jordikroon
Copy link
Copy Markdown
Contributor

Document DelayedTargetValidation attribute that was introduced in PHP 8.5.

Ref: #4886

@jordikroon
Copy link
Copy Markdown
Contributor Author

I can't assign reviewers. But I think it's best if @DanielEScherzer takes a good look at this for completeness.

Copy link
Copy Markdown
Member

@DanielEScherzer DanielEScherzer left a comment

Choose a reason for hiding this comment

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

looks correct to me, a few suggestions

Comment thread language/predefined/attributes/delayedtargetvalidation.xml
Comment thread language/predefined/attributes/delayedtargetvalidation.xml Outdated
Comment thread language/predefined/attributes/delayedtargetvalidation.xml
Comment thread language/predefined/versions.xml Outdated
Comment thread language/predefined/attributes/delayedtargetvalidation.xml Outdated
Comment thread language/predefined/attributes/delayedtargetvalidation.xml Outdated
Co-authored-by: Louis-Arnaud <la.catoire@gmail.com>
]]></programlisting>

<simpara>
When the attribute is instantiated via reflection using
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should somehow clarify that "the attribute" here means the other attribute applied in the same location

Comment on lines +15 to +18
When applied to a declaration, any invalid usage of internal attributes
on the same target will not trigger a compile time error. Instead, the
validation is deferred and performed when the attribute is accessed via
the Reflection API.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
When applied to a declaration, any invalid usage of internal attributes
on the same target will not trigger a compile time error. Instead, the
validation is deferred and performed when the attribute is accessed via
the Reflection API.
When applied to a declaration, any invalid usage of internal attributes
on the same target will not trigger a compile time error. Instead, the
validation is deferred and performed when the attribute is instantiated
via <link linkend="reflectionattribute.newinstance">ReflectionAttribute::newInstance()</link>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ReflectionClass::getAttributes() alone does not trigger validation: the deferred check only fires on ReflectionAttribute::newInstance() (see Zend/zend_compile.c:7874-7930, where the error is stored on attr->validation_error and only rethrown by newInstance()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants