Skip to content

Add Asymmetric Visibility flags #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 12, 2025

Conversation

SergiiDolgushev
Copy link
Contributor

@SergiiDolgushev SergiiDolgushev commented Jun 20, 2025

Introduces new asymmetric visibility flags: MODIFIER_PUBLIC_SET, MODIFIER_PROTECTED_SET and MODIFIER_PRIVATE_SET.

Copy link
Owner

@nikic nikic left a comment

Choose a reason for hiding this comment

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

Can you please also add a test involving these flags?

@SergiiDolgushev SergiiDolgushev requested a review from nikic June 20, 2025 16:35
@SergiiDolgushev
Copy link
Contributor Author

Can you please also add a test involving these flags?

Added in d04a1d6

ast.c Outdated
@@ -117,6 +117,16 @@
# define ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR (1<<1)
#endif

#if PHP_VERSION_ID < 80400
# define MODIFIER_PUBLIC_SET (1 << 10)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like in PHP 7.3 ZEND_ACC_PRIVATE was 1024: https://github.com/php/php-src/blob/89dc78e0f0c1a4f27b889f232b109a3919ecf478/Zend/zend_compile.h#L214. But for all later versions it was updated to 4: https://github.com/php/php-src/blob/master/Zend/zend_compile.h#L220C9-L220C25.

Because of that introducing MODIFIER_PUBLIC_SET for 7.2./7.3 leads to failed tests. Is there a simple way to introduce modifiers from this PR only for PHP8.4+?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nikic seems like setting 0 for the new flags (<8.4) fixes this. Can you please give it a look? And run tests one more time? I`ve run 7.3 and 8.4 tests locally, and it seemed fine.

Copy link
Owner

Choose a reason for hiding this comment

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

I don't think it's a good idea to set these to zero. People can reasonably expect that the flags are all disjoint and non-zero. We should find values here that work (but don't have to match any specific PHP version).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I probably should be more clear in my initial comment. Please let me try doing better job at explaining my vision of the problem here:

Because of that, we can't use 1024 value for MODIFIER_PUBLIC_SET for <8.4 versions. As it conflicts with ZEND_ACC_PRIVATE flag on <7.4.

Setting 0 value for MODIFIER_PUBLIC_SET flag for <8.4 seemed as simplest approach. As this flag (and other set modifiers) is not available in those PHP versions at all.

Seems like you are suggesting to use non-zero but not-conflicting (non-existing) flag values for set modifiers for versions where they were unavailable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I`ve just pushed 18ea5b5 and all local test runs were green for that change. @nikic can you please give it a look?

@SergiiDolgushev
Copy link
Contributor Author

Dear @nikic could you please review the latest updates in this PR? Are there any other changes you would like to be included here?

@nikic nikic merged commit 869ea5e into nikic:master Jul 12, 2025
8 checks passed
@SergiiDolgushev
Copy link
Contributor Author

@nikic thank you very much for merging this! Can you please release a new version that includes updates from this PR?

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.

2 participants