News Feed
Sections




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

PHP in Action:
Type hints are more useful for scalars than objects
September 11, 2008 @ 10:08:33

On the PHP in Action blog, there's a new post looking at a recent library that was posted to support type hinting on scalars. They agree with his choice of subjects, noting that they see type hinting as much more useful on scalars than on objects.

I admit that these judgments are hard to make. I could be wrong, more or less. Type hints are probably useful when code becomes stable enough and at the boundaries between modules. But I still tend to avoid using them until I get an actual bug that might have been prevented by a type hint. Their usefulness is and has to be an empirical question. The purpose of using them has to be catching errors earlier, so if they don't have that effect, there's no point.

He lists three reasons why he had given up on type hinting before, one being the limited usefulness when it came to objects. Applying it to scalars is a different matter, though, and can prevent improper passing of array/scalars when the other is needed.

0 comments voice your opinion now!
type hinting scalar object array string class library


blog comments powered by Disqus

Similar Posts

John Hamelink's Blog: Top codeigniter libraries I can't live without.

David Walsh's Blog: Using PHP Generic Objects To Organize Your Code

SitePoint PHP Blog: Simple Object Iterators in PHP

Sameer Borate's Blog: Parallel cURL execution in PHP

John Mertic's Blog: PHP Windows Installer updated for PHP 5.2.0RC2 and more


Community Events





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


framework release zendserver series tips laravel list conference podcast api bugfix developer deployment language library voicesoftheelephpant community introduction symfony interview

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