phpqa --analyzedDirs src/phpstan --output cli --tools phpstan
Output
------ --------------------------------------------------------------------------
Line phpstan/MethodAnnotations.php
------ --------------------------------------------------------------------------
10 Call to an undefined method Whatever\Swift_SmtpTransport::setUsername().
14 Call to an undefined method Whatever\Swift_SmtpTransport::setUsername().
------ --------------------------------------------------------------------------
------ -----------------------------------------------------------
Line phpstan/Proxy.php
------ -----------------------------------------------------------
29 Property Whatever\Proxy::$pdo (null) does not accept PDO.
30 Cannot call method setAttribute() on null.
------ -----------------------------------------------------------
------ ------------------------------------------------------------------------------
Line phpstan/Singleton.php
------ ------------------------------------------------------------------------------
14 Static property Whatever\Singleton::$facade (null) does not accept stdClass.
------ ------------------------------------------------------------------------------
[ERROR] Found 5 errors
@zdenekdrahos Well, the tests situation is ideally solved either by adding the regexps to
ignoreErrors
(precisely what you did) or by documenting your code correctly - documenting your variables and properties by@var \Foo|\ PHPUnit_Framework_MockObject_MockObject
(which will switch them tomixed
type and PHPStan will not perform any checks on them). I don't see a third solution with current features.It will be possible to create a PHPUnit/Prophecy/Mockista extension in the future that will solve this for you correctly. I am also planning to support union types (so that
Foo|Bar
does not result inmixed
but behaves and checks everything correctly), but there are yet some decisions and technical problems to overcome.