chore: fix types

This commit is contained in:
nuno maduro
2026-11-05 18:15:45 +00:00
parent c01972c34c
commit e3c59e00d0
+8 -9
View File
@@ -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')),
);