exactCompareFactory = $exactCompareFactory; } public function getRuleDefinition() : RuleDefinition { $errorMessage = \sprintf('Fixer for PHPStan reports by strict type rule - "%s"', 'PHPStan\\Rules\\BooleansInConditions\\BooleanInBooleanNotRule'); return new RuleDefinition($errorMessage, [new ConfiguredCodeSample(<<<'CODE_SAMPLE' class SomeClass { public function run(string|null $name) { if (! $name) { return 'no name'; } return 'name'; } } CODE_SAMPLE , <<<'CODE_SAMPLE' class SomeClass { public function run(string|null $name) { if ($name === null) { return 'no name'; } return 'name'; } } CODE_SAMPLE , [\Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector::TREAT_AS_NON_EMPTY => \true])]); } /** * @return array> */ public function getNodeTypes() : array { return [BooleanNot::class]; } /** * @param BooleanNot $node */ public function refactorWithScope(Node $node, Scope $scope) : ?Expr { $exprType = $scope->getNativeType($node->expr); if ($exprType->isBoolean()->yes()) { return null; } return $this->exactCompareFactory->createIdenticalFalsyCompare($exprType, $node->expr, $this->treatAsNonEmpty); } }