PhpStorm
 
Get PhpStorm
You are viewing the documentation for an earlier version of PhpStorm.

Code Inspection: 'assertTrue()' with incompatible argument type

Last modified: 16 May 2022

Reports the PHPUnit assertTrue() calls whose arguments are of incompatible types. Since the assertTrue() method relies on strict types comparison with true, such assertions will always fail.

In the following example, the performAction() function returns a value of integer type, so the PHPUnit assertion will always fail. After the quick-fix is applied, the returned value is cast to boolean; as a result, the assertion will only fail in case 0 is returned and will pass otherwise. For more information about type conversions in PHP, refer to Type Casting (php.net).