2013年11月10日星期日

Community News: Packagist Latest Releases for 11.10.2013

Recent releases from the Packagist:

2013年11月9日星期六

Community News: Packagist Latest Releases for 11.09.2013

Recent releases from the Packagist:

2013年11月8日星期五

Site News: Popular Posts for the Week of 11.08.2013

Popular posts from PHPDeveloper.org for the past week:

Community News: Packagist Latest Releases for 11.08.2013

Recent releases from the Packagist:

Christian Weiske: PHP: Cannot access property started with '\o'


Christian Weiske had an interesting situation pop up in one of his applications around a call to a variable with an interesting name.



Some days ago I saw the following fatal error for the first time in my life:



Fatal error: Cannot access property started with '\o' in file.php



After some debugging, I found out that the source of the error was not some strange BOM or UTF-8 characters in PHP source code files. No, it was a combination of protected class properties, object-to-array casting and automatic template property mappings.




As it turns out, there was a change in how object-to-array casting was done in PHP 5.3 that made this break (related to things appended to private and protected variable names). He includes a bit of sample code to illustrate the problem - a simple class converted from object to array with direct casting. He does point out that it doesn't happen with get_object_vars, though, as that doesn't do the casting, just extraction.


Link: http://cweiske.de/tagebuch/php-property-started-nul.htm

Leve.rs: Array Manipulation in PHP, the Correct Way


On the Leve.rs blog there's a recent post showing what they consider is the right way to work with arrays in PHP. It shows three things you can do to use PHP's own functionality to more correctly perform some common array operations.



More often than not, when PHP developers debug others' code, the majority of each method is taken up by array manipulations. Spending this much time on array manipulations is a huge hassle when trying to understand any given method. In order to speed up the debugging process, it's important to start writing array manipulations the correct way, first. Here are a few examples of code I have either written myself or had to fix in the past. It is time every PHP developer knows how to manipulate arrays properly!

Their three tips relate to:



  • Merging Arrays
  • Array Value Manipulation (with array_walk)
  • Array Value Manipulation (append with the plus sign, "+")

Link: http://leve.rs/blog/correct-array-manipulation-in-php/

Community News: GoPHP5 Initiative Reborn?


There's a movement stirring in a part of the PHP community (the PHP-FIG group) that wants to bring back the idea behind the "GoPHP5" movement years back. This time, though, their focus is a bit different - it's not switching to PHP5 they want, it's pushing towards PHP 5.5.



We all know that PHP 5.3 is about to lose even security support in the
first half of next year. PHP 5.3 is still the most widely used PHP version, with the completely
unsupported 5.2 a strong second [and] 5.4 hasn't even reached 10% yet, and 5.5, which is current stable, barely registers. [...] The last time this big of a chicken-and-egg issue existed was around moving to PHP 5.x at all, which took *for frickin' ever* to supplant PHP 4. [...] I believe it is time to discuss round 2 of that effort. I also believe that it would be good for FIG to play a leading role in such an effort if possible.


There's been some varied feedback on the thread both for and against. Overall, there's a lot of support for the idea, but there are a few "hitches" in the plans - mainly the lack of support from the linux OS vendors to bump up their versions. The projects themselves are receptive, many noting that they've been planning the first steps to this already - a move to PHP 5.4 only.


Link: https://groups.google.com/forum/#!topic/php-fig/ogp03OHbVJ0