I use PHPClipse for my PHP development. It has some code highlighting and some other validation such as forgetting to put a ';' at the end of a statement or forgetting '}' etc. I find it is easy to make a mistakes, for example
class foo {
private $test;
function __construct() {
$test = new stdClass;
$test->myVar = "hello";
}
function getTest() {
echo $this->test->myVar;
}
}
This should have been $this->test = 6;
In code when things like this happen in conditionals such as if else
the only time you realise is when the else
statement executes which might be after the software was delivered to clients.
Other examples may be displaying a warning when a function from an abstract class is not implemented.
Is there a way, particularly in Eclipse, that you can turn on some sort of STRICT validate which highlights anything that might be a little dubious?
If you're using the PHPEclipse version from http://www.phpeclipse.com/ there should be some code analysis options under "Preferences / PHPeclipse / PHP / PHP Parser -> Style"
You can select warnings for uninitialized variables and unreachable code.
I'm not sure if there are anything similar available for the PHP Development Tools Project http://www.eclipse.org/pdt/
No checkbox for dubious code, though...