Skip to content

[PHP 8.3] Assigning a negative index to an empty array#4173

Merged
Girgias merged 1 commit into
php:masterfrom
alexandre-daubois:negative-index
Nov 28, 2024
Merged

[PHP 8.3] Assigning a negative index to an empty array#4173
Girgias merged 1 commit into
php:masterfrom
alexandre-daubois:negative-index

Conversation

@alexandre-daubois
Copy link
Copy Markdown
Member

Part of #2796

@alexandre-daubois alexandre-daubois changed the title Assigning a negative index to an empty array [PHP 8.3] Assigning a negative index to an empty array Nov 27, 2024
@Girgias Girgias added this to the PHP 8.3 milestone Nov 27, 2024
Comment thread language/types/array.xml Outdated
Comment on lines +356 to +361
<note>
<para>
Prior to PHP 8.3.0, assigning a negative integer key <literal>n</literal> would
assign the next key to <literal>0</literal>.
</para>
</note>
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.

Could you also add a screen tag showcasing the old output?

Suggested change
<note>
<para>
Prior to PHP 8.3.0, assigning a negative integer key <literal>n</literal> would
assign the next key to <literal>0</literal>.
</para>
</note>
<warning>
<simpara>
Prior to PHP 8.3.0, assigning a negative integer key <literal>n</literal> would
assign the next key to <literal>0</literal>.
</simpara>
</warning>

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 also updated the example, it wasn't working as I expected in older versions. The new one is better: https://3v4l.org/J9ZRL

Comment thread language/types/array.xml Outdated
Comment thread language/types/array.xml Outdated
Comment on lines +352 to +353
Prior to PHP 8.3.0, assigning a negative integer key <literal>n</literal> would
assign the next key to <literal>0</literal>, as shown in this example:
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.

Maybe?

Suggested change
Prior to PHP 8.3.0, assigning a negative integer key <literal>n</literal> would
assign the next key to <literal>0</literal>, as shown in this example:
Prior to PHP 8.3.0, assigning a negative integer key <literal>n</literal> would
assign the next key to <literal>0</literal>, the previous example would therefore output:

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.

Definitely!

@Girgias Girgias merged commit cb3794f into php:master Nov 28, 2024
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