From 176f4ae348049bc67c77c47865fad52ecb50ec72 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Wed, 15 Mar 2023 17:06:25 +0100 Subject: [PATCH] Be consistent --- src/Framework/TestSuite.php | 2 +- src/Metadata/Api/HookMethods.php | 2 +- src/Util/Reflection.php | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index 3539eb6d74c..7bd49513fc7 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -115,7 +115,7 @@ public static function fromClassReflector(ReflectionClass $class): static return $testSuite; } - foreach ((new Reflection)->publicMethodsInTestClass($class) as $method) { + foreach (Reflection::publicMethodsInTestClass($class) as $method) { if ($method->getDeclaringClass()->getName() === Assert::class) { continue; } diff --git a/src/Metadata/Api/HookMethods.php b/src/Metadata/Api/HookMethods.php index 19daf6460d9..26c6f5d86de 100644 --- a/src/Metadata/Api/HookMethods.php +++ b/src/Metadata/Api/HookMethods.php @@ -43,7 +43,7 @@ public function hookMethods(string $className): array self::$hookMethods[$className] = self::emptyHookMethodsArray(); - foreach ((new Reflection)->methodsInTestClass(new ReflectionClass($className)) as $method) { + foreach (Reflection::methodsInTestClass(new ReflectionClass($className)) as $method) { $methodName = $method->getName(); assert(!empty($methodName)); diff --git a/src/Util/Reflection.php b/src/Util/Reflection.php index 46aeeb933da..f1fe5825a12 100644 --- a/src/Util/Reflection.php +++ b/src/Util/Reflection.php @@ -47,23 +47,23 @@ public static function sourceLocationFor(string $className, string $methodName): /** * @psalm-return list */ - public function publicMethodsInTestClass(ReflectionClass $class): array + public static function publicMethodsInTestClass(ReflectionClass $class): array { - return $this->filterMethods($class, ReflectionMethod::IS_PUBLIC); + return self::filterMethods($class, ReflectionMethod::IS_PUBLIC); } /** * @psalm-return list */ - public function methodsInTestClass(ReflectionClass $class): array + public static function methodsInTestClass(ReflectionClass $class): array { - return $this->filterMethods($class, null); + return self::filterMethods($class, null); } /** * @psalm-return list */ - private function filterMethods(ReflectionClass $class, ?int $filter): array + private static function filterMethods(ReflectionClass $class, ?int $filter): array { $methods = [];