6 ms·
For those wondering what the new features for PHP 5.5 are at this point, here is a small (not complete) list: Large language changes: * Generators and corouti
by nikic 14y ago
For those wondering what the new features for PHP 5.5 are at this point, here is a small (not complete) list:
Large language changes:
* Generators and coroutines (https://wiki.php.net/rfc/generators https://wiki.php.net/rfc/generators by me)
* `finally` blocks (https://wiki.php.net/rfc/finally https://wiki.php.net/rfc/finally by laruence)
Syntactic sugar:
* Support for function calls in `empty()` (https://wiki.php.net/rfc/empty_isset_exprs https://wiki.php.net/rfc/empty_isset_exprs by me)
* Support for `list()` in foreach (https://wiki.php.net/rfc/foreachlist https://wiki.php.net/rfc/foreachlist by laruence)
* Constant array/string dereferencing (https://wiki.php.net/rfc/constdereference https://wiki.php.net/rfc/constdereference by laruence)
* Getting the fully qualified class name using `ClassName::class` (https://wiki.php.net/rfc/class_name_scalars https://wiki.php.net/rfc/class_name_scalars by ralph)
Standard library:
* Simplified password hashing API (https://wiki.php.net/rfc/password_hash https://wiki.php.net/rfc/password_hash by ircmaxell)
* `hash_pbkdf2()` function (https://wiki.php.net/rfc/hash_pbkdf2 https://wiki.php.net/rfc/hash_pbkdf2 by ircmaxell)
* DateTimeImmutable, which is an immutable variant of DateTime (by derick)
Key anti-features (aka BC breaks):
* Dropped Windows XP and 2003 support (by pierre)
* ext/mysql deprecated (https://wiki.php.net/rfc/mysql_deprecation https://wiki.php.net/rfc/mysql_deprecation by aharvey)
* preg_replace /e modifier deprecated (https://wiki.php.net/rfc/remove_preg_replace_eval_modifier https://wiki.php.net/rfc/remove_preg_replace_eval_modifier by me)
* Logo GUIDs removed (by ajf)
For the beta 1 (the next planned released) at least two more things are planned:
* Bundling of ZendOptimizer+ (https://wiki.php.net/rfc/optimizerplus https://wiki.php.net/rfc/optimizerplus by zeev)
* Allowing non-scalar Iterator keys in foreach (https://wiki.php.net/rfc/foreach-non-scalar-keys https://wiki.php.net/rfc/foreach-non-scalar-keys by me)
- nolok 14y agoAre ZendOptimizer and APC meant to cohabitate in the core, or is the former going to replace the later ? Any news on object literals $o = {'abc': 456}; and scalar type hint ? Thanks for all the hard work, improvement in the language in 5.3 and 5.4 were awesome.
- nikic 14y agoZO+ will replace APC, only the user-cache from APC will be left (see also this comment: http://news.ycombinator.com/item?id=5343883 http://news.ycombinator.com/item?id=5343883). Object literals and scalar type hints won't be in 5.5. Scalar type hints may be in the next version (it's a rather tricky topic). For object literals I don't see reason to add them at all (in PHP you can just use arrays ^^).
- k3n 14y ago> in PHP you can just use arrays ^^ Which thankfully aren't as painful now! $cfg = [ 'path' => '.', 'mask' => 655 ]; Otherwise, if we still had to write "array" each time, I'd be more supportive of the object-literal, although I do think there's value in the literal but mostly to make the language similar to other languages with similar constructs (js, py).
- yogo 14y agoWith arrays you would have to do: $o = (object)[ 'foo' => 'bar' ]; Personally I think there should be a way to create objects right away instead of having to cast an array. Maybe there is a good reason all together for not using objects but I very much prefer typing $var->field instead of $var['field'].
- brokenparser 14y agoSure, but this still doesn't work: $o = (object)[ 'foo' => function(){ print 'bar'; }, ]; $o->foo(); You have to do it this way: call_user_func($o->foo); Or this way: $foo = $o->foo; $foo(); Which doesn't work when foo is defined as a class method.
- yogo 14y agoI believe by design it will always be: $foo = $o->foo; $foo(); Using __get/__set behaves the same way. Let's say $o is of SomeType that defines those magic methods. You can have a function foo on that type that is defined as a public method. $o->foo(); // the actual instance method $o->foo = function() { print 'bar'; }; $o->foo(); // same instance method $foo = $o->foo; $foo(); // prints bar In the case of StdClass it might be possible to do it your way where foo could be callable ($o->foo()) but I can see why they wouldn't allow this in order to keep things consistent. Edit: It also behaves the same way if you assign a function to a public field of a class (I'm using 5.4) so I actually support not allowing a method to be directly callable in this fashion because this would be the only case where this behavior would occur.
- ecaron 14y agoI feel like there are dark factors at play for dropping the XP support. Although the most thorough discussion of it is at http://programmers.stackexchange.com/questions/177732/why-was-support-for-windows-xp-dropped-in-php-5-5 http://programmers.stackexchange.com/questions/177732/why-wa..., the conspiracist in me says that Microsoft (pierre's employer) pressured him to drop support - even though it wasn't entirely necessary to do so.
- mratzloff 14y agoThat's a good catch, and the justification was a little soft. But would you blame them?
- ecaron 14y agoFrankly, I'm irritated at them for dragging their heals on getting the PECL4Win back up and running (and the lack of updates to http://downloads.php.net/pierre/ http://downloads.php.net/pierre/ doesn't help matters.) Since I've moved to the camp of "You developing PHP and use Windows? Let me show you how to setup Vagrant" I've become less concerned about the state of PHP & Windows. I just won't tolerate when people say PHP dropping XP support is a good thing (which the OP wasn't saying, but some have.)
- nikic 14y agoDLLs for PECL exts are currently available here: http://windows.php.net/downloads/pecl/ http://windows.php.net/downloads/pecl/ Not for all of them, but some of the more important ones. If you want something added to the list it's usually as simple as pinging Pierre on IRC :)
- ecaron 14y agoSomeone should update the "In the meantime, some extensions can be found here." link on http://windows.php.net/ http://windows.php.net/, then.
- deleted 14y ago[deleted]
- mratzloff 14y agoHey, great work on that generators patch! Very well documented. It's been years since I wrote PHP but it's nice to know that if I have to at some point I'll have some things I like from Python and other languages available to me now.
- yogo 14y agoGood stuff nikita, keep up the great work. I also vote for getting object literals added (it will be a great addition to the array literals).