sebastianbergmann/phpunit — pull request #1032 by wimg (2013-10-19 09:07:48+00:00)
Title: Parameter and return type check

Purpose of this patch :
- Allows developers to check if they're calling methods with the right parameter types, compared to the docblock of the method
- Allows developers to check their docblocks are still up-to-date

It expects a docblock variable definition of this form :
/**
* @param type $variableName Optional comment
* @return type
*/

Produces output such as :
2) ATest::testMultiply
Invalid type calling A->multiply : parameter 2 ($factor2) should be of type int but got string(1) instead in /tmp/test/ATest.php:46

Adds 3 parameters to PHPUnit :
--check-param-types Enables the type checking
--check-param-type-depth=x Defines the depth to check. The default is 2, meaning it will check the functions/methods you call from within your test and all calls from within the next level. if you increase it, it might check libraries you use, which might not always be a good idea)
--check-param-type-ignore-null Defines whether passing null as a parameter should be ignored, even if null is not part of the parameter list in the docblock

It will also check return types when running Xdebug code after https://github.com/xdebug/xdebug/pull/79 since this fixes Xdebug bug #416 (http://bugs.xdebug.org/view.php?id=416), otherwise it will not check return types.

Enabling this code slows down execution of PHPUnit by a factor of about 4-5, mostly due to the use of Xdebug trace and the parsing of the trace file.

Any feedback most welcome ;-)