Thursday, 16 September 2010

PHP DOC

My personal pet hate is lack of type strength in languages. I've worked with some languages in the past that consider all variables to be strings regardless of their types, an incredible waste of resources, but these languages are now popular and well supported so you find yourself having to work with them.

While PHP does have some weak type strength built in variables are quite easily converted from one type to another if you are not careful and as the type cannot be declared for the return value of functions you are left with a value of ambiguous type. Which can be a problem when working on complex sites like Car Arena.

PHP DOC however helps enforce type strength when it would normally be forgotten, at design time at least. IDE's can recognise the type of the return value from functions and save you time with the Intelisense, documentation, parameters, etc...
Based on Javadoc you only need add a few lines of comments to your declration and not only is your routine documented but IDE's such as NetBeans can now resolve types when it would not be too clear in PHP. Also variables declared within the __get magic method can be declared for classes, along with their read / write status so that the IDE can issue warnings if you attempt to write to a read only member and display the member in the Intelisense member list while editing your code.

For me PHP DOC changed my opinoin of PHP quite a lot. I used to view the language in quite a dim light before I started using it, now I would rather use PHP over any of the scripted languages we use today.

No comments:

Post a Comment

Custom computer software development Bespoke software