From e3c59e00d075691eff6b7e8fe1c17ed8c2280ed2 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Thu, 5 Nov 2026 18:15:45 +0000 Subject: [PATCH] chore: fix types --- src/Expectations/OppositeExpectation.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index b85150a0..397e6b8a 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -73,7 +73,7 @@ final readonly class OppositeExpectation $original = $this->original; return GroupArchExpectation::fromExpectations($original, array_map(fn (string $target): SingleArchExpectation => ToUse::make($original, $target)->opposite( - fn () => $this->throwExpectationFailedException('toUse', $target), + fn (): never => $this->throwExpectationFailedException('toUse', $target), ), is_string($targets) ? [$targets] : $targets)); } @@ -106,7 +106,7 @@ final readonly class OppositeExpectation || array_filter( Reflection::getMethodsFromReflectionClass($object->reflectionClass), fn (ReflectionMethod $method): bool => (enum_exists($object->name) === false || in_array($method->name, ['from', 'tryFrom', 'cases'], true) === false) - && realpath($method->getFileName() ?: '/') === realpath($object->path) // @phpstan-ignore-line + && realpath($method->getFileName() ?: '/') === realpath($object->path) && $method->getDocComment() !== false, ) === [], 'to have methods without documentation / annotations', @@ -125,7 +125,7 @@ final readonly class OppositeExpectation || array_filter( Reflection::getPropertiesFromReflectionClass($object->reflectionClass), fn (ReflectionProperty $property): bool => (enum_exists($object->name) === false || in_array($property->name, ['value', 'name'], true) === false) - && realpath($property->getDeclaringClass()->getFileName() ?: '/') === realpath($object->path) // @phpstan-ignore-line + && realpath($property->getDeclaringClass()->getFileName() ?: '/') === realpath($object->path) && $property->isPromoted() === false && $property->getDocComment() !== false, ) === [], @@ -180,7 +180,7 @@ final readonly class OppositeExpectation return Targeted::make( $original, - fn (ObjectDescription $object): bool => ! enum_exists($object->name) && (isset($object->reflectionClass) === false || ! $object->reflectionClass->isReadOnly()) && assert(true), // @phpstan-ignore-line + fn (ObjectDescription $object): bool => ! enum_exists($object->name) && (isset($object->reflectionClass) === false || ! $object->reflectionClass->isReadOnly()), 'not to be readonly', FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')), ); @@ -580,7 +580,7 @@ final readonly class OppositeExpectation $original = $this->original; return GroupArchExpectation::fromExpectations($original, array_map(fn (string $target): GroupArchExpectation => ToBeUsedIn::make($original, $target)->opposite( - fn () => $this->throwExpectationFailedException('toBeUsedIn', $target), + fn (): never => $this->throwExpectationFailedException('toBeUsedIn', $target), ), is_string($targets) ? [$targets] : $targets)); } @@ -631,7 +631,6 @@ final readonly class OppositeExpectation throw InvalidExpectation::fromMethods(['not', $name]); } - /* @phpstan-ignore-next-line */ $this->original->{$name}(...$arguments); } catch (ExpectationFailedException|AssertionFailedError) { return $this->original; @@ -650,7 +649,7 @@ final readonly class OppositeExpectation throw InvalidExpectation::fromMethods(['not', $name]); } - $this->original->{$name}; // @phpstan-ignore-line + $this->original->__get($name); } catch (ExpectationFailedException) { return $this->original; } @@ -694,8 +693,8 @@ final readonly class OppositeExpectation $original, fn (ObjectDescription $object): bool => isset($object->reflectionClass) === false || ! $object->reflectionClass->isEnum() - || ! new \ReflectionEnum($object->name)->isBacked() // @phpstan-ignore-line - || (string) new \ReflectionEnum($object->name)->getBackingType() !== $backingType, // @phpstan-ignore-line + || ! new \ReflectionEnum($object->name)->isBacked() + || (string) new \ReflectionEnum($object->name)->getBackingType() !== $backingType, 'not to be '.$backingType.' backed enum', FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')), );