php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67781 Use array() instead of square brackets
Submitted: 2014-08-05 17:09 UTC Modified: 2015-07-12 04:22 UTC
Votes:3
Avg. Score:1.7 ± 0.9
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: joelm@php.net Assigned:
Status: No Feedback Package: PHP Language Specification
PHP Version: PHP-5.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joelm@php.net
New email:
PHP Version: OS:

 

 [2014-08-05 17:09 UTC] joelm@php.net
Description:
------------
https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#array-creation-operator

It might be better to say that "array(..)" is the 'array creation operator' and mostly use "array(..)" instead of "[..]" in examples. Most existing PHP code uses "array(..)" way more than "[..]" (because "[..]" was added very recently), and I think using "array(..)" as the 'array creation operator' helps disambiguate it from the subscript operator ("[]"). 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-05 17:10 UTC] joelm@php.net
There was disagreement here:

"Both notations are permitted, and unless we’re going to deprecate one of them, we should be able to use both. If that causes a significant problem, then IMHO the wrong spelling was chosen for the new/alternate notation."
 [2014-08-06 21:56 UTC] fa@php.net
I am not a native speaker, but wouldn't "the xy operator" imply some sort of uniqueness in a general sense?
Especially as "the array operator []" is also "the subscript operator []".

I am thinking along the lines of "when using [] as the(an?) array operator". But that sounds less succinct and somehow less precise.
 [2014-08-06 21:58 UTC] ajf@php.net
I'd say "the array literal syntax". It's a literal, not an operator.
 [2015-06-28 21:54 UTC] stas@php.net
-PHP Version: Irrelevant +PHP Version: PHP-5.6
 [2015-06-28 21:54 UTC] stas@php.net
I don't think we need to change the examples - [] is a legit feature of PHP and should not be avoided, unless it is confusing in a specific case. Not sure though which changes you ask for in array-creation-operator - could you elaborate?
 [2015-06-28 21:54 UTC] stas@php.net
-Status: Open +Status: Feedback
 [2015-07-12 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2022-03-03 01:27 UTC] net at danguifofana487 dot com
welcame on bug report presenter la page,connexion donner le site web de php.net
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 07 01:01:29 2024 UTC