![]() Reports deprecated usages of the assertEquals and assertNotEquals functions with $delta, $maxDepth, $canonicalize, and $ignoreCase parameters. See Usage of the assertEquals function () for details.ĭeprecated 'assertEquals/assertNotEquals' usage For assertions that operate on strings, the specific assertStringContainsString(), assertStringContainsStringIgnoringCase(), assertStringNotContainsString(), and assertStringNotContainsStringIgnoringCase() methods should be used. The string $needle and optional boolean $ignoreCase parameters of the assertContains() and assertNotContains() functions are deprecated and removed in PHPUnit 9. Reports the deprecated assertContains() and assertNotContains() calls with the string $needle and $ignoreCase arguments. Reports the references to functions/methods in the PHPDoc tags that are not prepended with the scope resolution operator ( ::).ĭeprecated 'assertContains/assertNotContains' usage Such usages can be replaced with fail() calls to indicate that a test is expected to fail.Ĭovered function reference is provided without ‘::’ Reports the assertTrue() / assertFalse() calls with the false / true arguments in PHPUnit tests. ![]() Reports the assertTrue / assertFalse usages that can be replaced with assertEmpty / assertNotEmpty in PHPUnit tests. Since the assertTrue() method relies on strict types comparison with true, such assertions will always fail.Īssertion can be replaced with 'assertEmpty/assertNotEmpty' Reports the PHPUnit assertTrue() calls whose arguments are of incompatible types. ![]() 'assertTrue()' with incompatible argument type See foreach (php.net) and unset (php.net) for details. It is recommended to destroy such references by using unset. Reports the write access expressions on variables that are still referencing the array value previously used in a foreach statement. ![]() Write access to referenced array value without 'unset' Reports the statements that cannot be reached. Such branches are redundant and can be safely omitted. Reports the else branches in if statements whose bodies always execute a terminating statement such as return or throw. See Uninitialized and Unset Properties (php.net) for details. Typed properties should be initialized in any of the following ways: Reports the attempts to read from an uninitialized typed property. Such expressions will always evaluate to true. Reports the instanceof expressions whose argument is within the hierarchy of the checked variable. Commonly, such loops are intended to perform an action only on their first iteration (for example, get the first element of an array). The inspection does not report foreach loops with a key or value used inside the loop body. Reports the loop statements whose bodies will execute at most once. Reports the variables in return statements that are always null. Reports the conditions inside logical binary expressions that are covered by subsequent conditions and are therefore redundant. Reports the conditions that are already covered by earlier conditions and thus have no effect as well as the variables that are always true (or always false) when reached.Ĭondition inside logical expression checked by subsequent condition The most common source of such problems is modifying an array passed via a parameter: if an array is passed by value, the change will not be visible outside the function.Ĭondition always evaluates to 'true/false' Reports the array write access expressions that are not used in code afterwards. Reports the 'switch' statements with duplicated common parts. Functions with such a return type are not expected to return any value and must prevent the rest of the script execution by either calling die(), exit(), and so on, or throwing an exception. Reports the functions with the never return type hint that may return some value. Reports the if statements with duplicated common parts. Such usages may unwillingly overwrite an already defined value and cause latent bugs. Reports the keys and values in foreach loops that are assigned a non-primitive value before the foreach loop and are accessed after it. 'foreach' variable overwrites already defined variable
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |