Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#13900 closed defect (bug) (fixed)

Curly Brackets String Index-Based-Access Deprecated

Reported by: hakre's profile hakre Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0
Component: General Keywords: has-patch
Focuses: Cc:


From the PHP Manual:

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)

13900.patch (15.3 KB) - added by hakre 14 years ago.

Download all attachments as: .zip

Change History (8)

14 years ago

#1 @hakre
14 years ago

  • Summary changed from Curly Braces String Index-Based-Access Deprecated to Curly Brackets String Index-Based-Access Deprecated

#2 @nacin
14 years ago

  • Milestone changed from 3.0.1 to 3.1

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.

#3 @hakre
14 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 @nacin
14 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 @hakre
14 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: It shows how I did it.

#6 @nacin
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.

#7 @nacin
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [16340]) Use square brackets instead of braces for string access. props hakre, fixes #13900.

Note: See TracTickets for help on using tickets.