Skip to content

[RFC] Allow #[\Override] on class constants#20478

Open
DanielEScherzer wants to merge 8 commits into
php:masterfrom
DanielEScherzer:override-constants
Open

[RFC] Allow #[\Override] on class constants#20478
DanielEScherzer wants to merge 8 commits into
php:masterfrom
DanielEScherzer:override-constants

Conversation

@DanielEScherzer

@DanielEScherzer DanielEScherzer commented Nov 14, 2025

Copy link
Copy Markdown
Member

@DanielEScherzer

Copy link
Copy Markdown
Member Author

Someone at MergePHP suggested this today, I'll write up the RFC when I have a chance

@TimWolla TimWolla left a comment

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.

Looks correct, except for test remark. But please have someone else double-check the engine implementation.

Comment on lines +29 to +31
#[\Override]
public const C1 = 'C1';
public const C2 = 'C2';

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.

C2 is not tested at all. The original Zend/tests/attributes/override/001.phpt test specifically had 4 cases to test all situations:

  • p1: Override in PP and C.
  • p2: Override in C, implementation in PP.
  • p3: Override in PP.
  • p4: Override in C, implementation in P.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added the cases from the origin test file which I think now covers everything

@DanielEScherzer

Copy link
Copy Markdown
Member Author

Rebased onto latest master

@iluuu1994 iluuu1994 left a comment

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.

I'm very sorry for the big delay. Some things got in the way yesterday.

Only a nit. The implementation looks correct. Too many tests for my taste.

Comment thread Zend/zend_compile.c Outdated
Comment thread Zend/zend_compile.c Outdated

@iluuu1994 iluuu1994 left a comment

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.

Thanks!

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.

3 participants