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

Code Inspection: Assertion can be replaced with 'assertEmpty/assertNotEmpty'

Last modified: 16 May 2022

Reports the assertTrue / assertFalse usages that can be replaced with assertEmpty / assertNotEmpty in PHPUnit tests.

See assertEmpty (phpunit.readthedocs.io) for details.

In the following example, asserting whether the $arr array is empty is initially performed by providing the empty() and count() functions calls as the conditions for the assertTrue method. After the quick-fix is applied, the more specific assertEmpty and assertNotEmpty are used directly on the $arr array.