Opened 15 years ago
Closed 14 years ago
#13900 closed defect (bug) (fixed)
Curly Brackets String Index-Based-Access Deprecated
Reported by: | hakre | Owned by: | |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
Note: String s [!sic] may also be accessed using braces, as in $str{42}, for the same purpose. However, this syntax is deprecated as of PHP 5.3.0. Use square brackets instead, such as $str[42].
It is recommended to replace it using square brackets ([
,]
)
(Informative: I know at least that it has been warned about to use that since a longer time. It is a very old syntax and you find it often in outdated code, even before PHP 5.3.)
Attachments (1)
Change History (8)
#1
@
15 years ago
- Summary changed from Curly Braces String Index-Based-Access Deprecated to Curly Brackets String Index-Based-Access Deprecated
#3
@
15 years ago
Don't feel offended or distracted Nacin, I just did not wanted to judge about that before 3.0 is actually out and feedback to base a decision on is available. More and more users are using 5.3 these days and taking care of deprecated stuff looks like maintenance to me. But you do not need to share that opinion, I just write it here to explain why I suggested that 3.0.1 milestone.
#4
@
15 years ago
I have no problem with the patch, but it's too late for 3.0. In fact I was reading PHP developer meeting minutes the other day and saw the curly bracket thing and made a mental note to search core for them, so I appreciate the patch.
It is indeed maintenance, good maintenance, but it doesn't meet our own definition of what a maintenance release is.
At the moment, we take care of deprecated stuff by silencing E_DEPRECATED. :-)
#5
@
15 years ago
Ah good to see you're with me on this one. I stumbled over it about three weeks ago while in a look for something else and noted to fix it for this week. I think it even has some value for other projects and wrote a report about that: http://hakre.wordpress.com/2010/06/15/php-curly-brackets-substring-access/. It shows how I did it.
#6
@
14 years ago
- Milestone changed from Awaiting Triage to 3.1
Did PHP core undeprecate it? Looks like it.
"Note: Strings may also be accessed using braces, as in $str{42}, for the same purpose."
I'm finding the 5.3.0 reference become 6.0 on a mirror, but that's no longer there either.
I'm still fine with the patch, we should make it our coding standard. Incoming.
No need to handle this in a maintenance release, let's keep this clear. Many also apply diffs of maintenance releases and this is just a slew of code hunks that are trivial, so it's one less piece of noise by leaving it out.
Moving to 3.1.