Skip to content

Commit

Permalink
Updated paragraph on initialization of static variables (GH-3827)
Browse files Browse the repository at this point in the history
* Updated paragraph on initialization of static variables

Updated information about restrictions on initialization of static variables to comply with PHP 8.3

* Removed confusing note in static variables section

As of PHP 8.3, static declarations are resolved not only at compile time

* Removed confusing note in static variables section

As of PHP 8.3, static declarations are resolved not only at compile time.

Closes GH-3701.
  • Loading branch information
agroholism authored Oct 4, 2024
1 parent a6ee935 commit b6915fd
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions language/variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ function test()
</para>

<para>
Static variables can be assigned values which are the
result of constant expressions, but dynamic expressions, such as function
calls, will cause a parse error.
Prior to PHP 8.3.0, you could only initialize a static variable using
a constant expression. As of PHP 8.3.0, dynamic expressions
(e.g. function calls) are also allowed:
</para>
<para>
<example>
Expand All @@ -482,7 +482,7 @@ function test()
function foo(){
static $int = 0; // correct
static $int = 1+2; // correct
static $int = sqrt(121); // wrong (as it is a function)
static $int = sqrt(121); // correct as of PHP 8.3.0
$int++;
echo $int;
Expand Down Expand Up @@ -520,12 +520,6 @@ var_dump(Bar::counter()); // int(4), prior to PHP 8.1.0 int(2)
]]>
</programlisting>
</example>

<note>
<para>
Static declarations are resolved in compile-time.
</para>
</note>
</sect2>

<sect2 xml:id="language.variables.scope.references">
Expand Down

4 comments on commit b6915fd

@Girgias
Copy link
Member

@Girgias Girgias commented on b6915fd Oct 5, 2024

Choose a reason for hiding this comment

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

This uses personalization in the text.

We really need a script to flag this and fail CI.

@cmb69
Copy link
Member

@cmb69 cmb69 commented on b6915fd Oct 5, 2024

Choose a reason for hiding this comment

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

Oops, going to fix right away.

PS: 18 occurrences of "you" on that page. On three of "your".

@Girgias
Copy link
Member

@Girgias Girgias commented on b6915fd Oct 5, 2024

Choose a reason for hiding this comment

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

Just checked, across all doc-en there are 3260~ mentions of "you". So getting rid of all of them is going to be tedious.

It is more about not adding more to the list

@cmb69
Copy link
Member

@cmb69 cmb69 commented on b6915fd Oct 5, 2024

Choose a reason for hiding this comment

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

Yeah, but a simple script looking for "you" will only find the most obvious issues (still, better than nothing, though). I should have caught that in the first place.

Please sign in to comment.