Skip to content
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

Static variable initializers can now contain arbitrary expressions. #3701

Closed
MorganLOCode opened this issue Aug 30, 2024 · 0 comments
Closed
Labels
bug Documentation contains incorrect information

Comments

@MorganLOCode
Copy link
Contributor

MorganLOCode commented Aug 30, 2024

From manual page: https://php.net/language.variables.scope


Example 7 says that static $int = sqrt(121); is wrong. This has not been updated for 8.3, which allows static variables to be initialised with arbitrary expressions.

There is also a Note: slightly further down that states that " Static declarations are resolved in compile-time." My understanding (which isn't certain enough to be writing the necessary docs) is that the declarations are now resolved the first time the function is executed (and if the expression defining the value recurses on the function call itself, the first time the expression completely evaluates provides the value).

@cmb69 cmb69 added the bug Documentation contains incorrect information label Aug 30, 2024
agroholism added a commit to agroholism/php-doc-en that referenced this issue Oct 3, 2024
As of PHP 8.3, static declarations are resolved not only at compile time.

This commit fixes php#3701.
@cmb69 cmb69 closed this as completed in b6915fd Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Documentation contains incorrect information
Projects
None yet
Development

No branches or pull requests

2 participants