Wednesday, July 12, 2006

VS.PHP (3) - The comment is power

VS.PHP has a interesting idea to use the intellisence in PHP which isn't a type safe language. Look at this:

class Foo1
{
function
methodFoo($num)
{
}
}

function
foo($a, $b)
{
}


In foo(), VS.PHP doesn't know the type of $a. Therefore, you aren't supported by VS.PHP when you type code in foo().

We often write comments on the top of the definition of functions for a document system. The format of those comments aren't defined by the grammer of PHP. But, there is the popular rule which is phpdoc or Doxygen. VS.PHP analogizes the type of variables by reading those comments. Look at this sample:

class Foo1
{
function
methodFoo($num)
{
}
}

/**
* @param Foo1 $a
*/
function foo($a, $b)
{
}


I added simple comments to the top of foo(). If these comments are written, VS.PHP can analogize the type to run intellisence:


This is a great hint for all of IDE which handles type unsafe languages. And, the idea brings rapid typing to us. That's must for us. I don't want to write code in PHP if I'm not with VS.PHP.

No comments: