From 842d0729684f0161f7c3d6d764b68c3296196f07 Mon Sep 17 00:00:00 2001 From: Bastien Philippe Date: Thu, 2 Jan 2025 16:26:12 +0100 Subject: [PATCH] Fix mutable datatime rules --- src/Rules/NoMutableDateTimeStaticCallRule.php | 4 ++++ src/Rules/NoMutableDateTimeUseRule.php | 4 ++++ src/Rules/NoNewMutableDateTimeRule.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/Rules/NoMutableDateTimeStaticCallRule.php b/src/Rules/NoMutableDateTimeStaticCallRule.php index c489841..b4840b9 100644 --- a/src/Rules/NoMutableDateTimeStaticCallRule.php +++ b/src/Rules/NoMutableDateTimeStaticCallRule.php @@ -38,6 +38,10 @@ public function processNode(Node $node, Scope $scope): array $class = $node->class->toString(); + if (!$this->reflectionProvider->hasClass($class)) { + return []; + } + if ($this->isAllowed($class)) { return []; } diff --git a/src/Rules/NoMutableDateTimeUseRule.php b/src/Rules/NoMutableDateTimeUseRule.php index 5777766..22905c3 100644 --- a/src/Rules/NoMutableDateTimeUseRule.php +++ b/src/Rules/NoMutableDateTimeUseRule.php @@ -34,6 +34,10 @@ public function processNode(Node $node, Scope $scope): array { $class = $node->name->toString(); + if (!$this->reflectionProvider->hasClass($class)) { + return []; + } + if ($this->isAllowed($class)) { return []; } diff --git a/src/Rules/NoNewMutableDateTimeRule.php b/src/Rules/NoNewMutableDateTimeRule.php index f7ceff0..ee533fd 100644 --- a/src/Rules/NoNewMutableDateTimeRule.php +++ b/src/Rules/NoNewMutableDateTimeRule.php @@ -38,6 +38,10 @@ public function processNode(Node $node, Scope $scope): array $class = $node->class->toString(); + if (!$this->reflectionProvider->hasClass($class)) { + return []; + } + if ($this->isAllowed($class)) { return []; }