News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Derick Rethans:
DateTimeImmutable
February 26, 2014 @ 10:26:45

In his latest post Derick Rethans (knower of all things date and time) talks about the DateTimeImmutable functionality. It has been added into the PHP 5.5 releases and provides the same DateTime functionality but removes the ability for modification (mutability).

The first time that my improved DateTime support made its way into PHP was officially in PHP 5.1, although the more advanced features such as the DateTime class only made it appearance in PHP 5.2. Since its introduction the DateTime class implementation suffered from one design mistake - arguably not something that even an RFC would have highlighted. [...] This mutability property that all modifying methods of the DateTime class have is highly annoying, and something that I would now rather remove. But of course we cannot as that would break backwards compatibility. So in PHP 5.5, after a few stumbles, I finally managed to rectify this.

He includes some code examples showing the current DateTime object's mutability (via the "modify" function) and the new immutable handling. This new handling doesn't update the current object but instead returns the modified object, leaving the initial one intact. You can find out more about this new object in the PHP manual.

0 comments voice your opinion now!
datetime datetimeimmutable mutability return object php55

Link: http://derickrethans.nl/immutable-datetime.html

PHP.net:
PHP 5.5.0 Alpha4 released
January 24, 2013 @ 09:29:39

On PHP.net today they've announced the tagging and release of the latest alpha for the PHP 5.5.0 series - PHP 5.5.0 alpha4:

The PHP development team announces the release of PHP 5.5.0alpha4. This release fixe some bugs from alpha3 and add some new features. All users of PHP are encouraged to test this version carefully, and report any bugs in the bug tracking system.

There's new improvements included in this non-production release including class name resolution with "class" keyword and the DateTimeImmutable class. You can see the NEWS file for the complete list of changes. If you'd like to help test it out, you can download the preview release here (or here for Windows users).

0 comments voice your opinion now!
alpha release language class keyword datetimeimmutable test



Community Events





Don't see your event here?
Let us know!


testing unittest introduction framework list series interview language opinion threedevsandamaybe podcast laravel symfony2 developer community api refactor install release code

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework