Fix PHPStan level 4 errors
Problem/Motivation
PHPStan reports various level 4 errors.
Proposed resolution
Address reported level 4 errors.
Reported errors
Ternary Operator Issues
-
Major - Ternary operator condition is always true. in devel_generate/src/Plugin/DevelGenerate/BlockContentDevelGenerate.php:76 -
Major - Ternary operator condition is always true. in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php:133 -
Major - Ternary operator condition is always true. in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php:134 -
Major - Ternary operator condition is always true. in devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php:80
Boolean Expression Issues
-
Major - Negated boolean expression is always false. in devel_generate/src/Plugin/DevelGenerate/MenuDevelGenerate.php:345 -
Major - Result of && is always false. in devel_generate/src/Plugin/DevelGenerate/MenuDevelGenerate.php:345 -
Major - Left side of && is always true. in src/DevelDumperManager.php:189 -
Major - Left side of && is always true. in src/EventSubscriber/ErrorHandlerSubscriber.php:37 -
Major - Left side of && is always true. in src/EventSubscriber/ThemeInfoRebuildSubscriber.php:120 -
Major - Left side of && is always true. in src/EventSubscriber/ThemeInfoRebuildSubscriber.php:122 -
Major - Unreachable statement - code above always terminates. in src/Form/SettingsForm.php:207 -
Major - Negated boolean expression is always false. in src/Form/SwitchUserForm.php:91
Strict Comparison Issues
-
Major - Strict comparison using === between null and null will always evaluate to true. in src/Controller/ContainerInfoController.php:129 -
Major - Unreachable statement - code above always terminates. in src/Controller/ContainerInfoController.php:133 -
Major - Strict comparison using === between Drupal\Core\Config\ImmutableConfig and false will always evaluate to false. in src/Form/ConfigDeleteForm.php:49 -
Major - Strict comparison using === between Drupal\Core\Config\ImmutableConfig and false will always evaluate to false. in src/Form/ConfigEditor.php:57 -
Major - Strict comparison using !== between 'Twig_Template' and class-string<Twig\Template>&literal-string will always evaluate to true. in src/Twig/Extension/Debug.php:254 -
Major - Strict comparison using !== between null and Twig\Template will always evaluate to true. in src/Twig/Extension/Debug.php:264 -
Strict comparison using !== between non-empty-list and array{} will always evaluate to true. in MenuDevelGenerate.php:352
Assertion Issues
-
Major - Call to method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true. in tests/src/Functional/DevelDumperTest.php:39 -
Major - Call to method PHPUnit\Framework\Assert::assertNotNull() with array<Behat\Mink\Element\NodeElement> will always evaluate to true. in tests/src/Functional/DevelEventInfoTest.php:79 -
Major - Call to method PHPUnit\Framework\Assert::assertNull() with string will always evaluate to false. in tests/src/Functional/DevelLayoutInfoTest.php:85 -
Major - Call to method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true. in tests/src/Kernel/DevelTwigExtensionTest.php:93 -
Major - Instanceof between Twig\TwigFunction and Twig\TwigFunction will always evaluate to true. in tests/src/Kernel/DevelTwigExtensionTest.php:93 -
Major - Call to method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true. in tests/src/Kernel/DevelTwigExtensionTest.php:115 -
Major - Instanceof between Twig\TwigFunction and Twig\TwigFunction will always evaluate to true. in tests/src/Kernel/DevelTwigExtensionTest.php:115
Edited by Marcin Ścieszka