News Feed
Sections




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

The PHP.cc:
PHP 5.5 New CLASS Constant
June 26, 2013 @ 09:02:08

The PHP.cc have posted another article in their series looking at the new features that come with the latest release of PHP (5.5). In this new post they cover the "CLASS" constant.

Last week, the first stable version of PHP 5.5 was released. It introduced a class-level constant, aptly named CLASS, that is automatically available on all classes and holds the fully-qualified name of that class. [...] So why would you need such a constant? [...] When you need the fully qualified name of a namespaced class that is referenced by a namespace alias ... then it gets interesting.

He illustrates with an example of a unit test using stubs and mocks. The normal method requires the definition of the class namespace in the "getMock" call. With the CLASS constant, PHP can extract that information from the namespace referenced in the "use" and drop it in as a replacement.

0 comments voice your opinion now!
class constant php55 new feature namespace unittest

Link: http://thephp.cc/viewpoints/blog/2013/06/php-5-5-new-class-constant

blog comments powered by Disqus

Similar Posts

Sherif Ramadan: Test Drive PHP 5.5: A Sneak Peek

Derick Rethans: Mongo is dead, long live MongoClient

Gonzalo Ayuso's Blog: Database Abstraction Layers in PHP. PDO versus DBAL

NetTuts.com: Testing your PHP Codebase with EnhancePHP

Greg Beaver's Blog: Working towards Pyrus and PEAR2, check it out or miss out


Community Events

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


language development laravel5 interview introduction wordpress psr7 series release extension opinion podcast library api unittest framework laravel conference voicesoftheelephpant community

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