Skip to content

Commit

Permalink
Expect an instanceof ReflectionNamedType
Browse files Browse the repository at this point in the history
`^8.0` marks `ReflectionType` abstract and moves `isBuiltin` to `ReflectionNamedType`

Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Oct 10, 2022
1 parent 00a257d commit fa2ec24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Tool/ConfigDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laminas\ServiceManager\Exception\InvalidArgumentException;
use Psr\Container\ContainerInterface;
use ReflectionClass;
use ReflectionNamedType;
use ReflectionParameter;
use Traversable;

Expand Down Expand Up @@ -83,7 +84,7 @@ public function createDependencyConfig(array $config, $className, $ignoreUnresol

foreach ($constructorArguments as $constructorArgument) {
$type = $constructorArgument->getType();
$argumentType = null !== $type && ! $type->isBuiltin() ? $type->getName() : null;
$argumentType = $type instanceof ReflectionNamedType && ! $type->isBuiltin() ? $type->getName() : null;

if ($argumentType === null) {
if ($ignoreUnresolved) {
Expand Down
5 changes: 3 additions & 2 deletions src/Tool/FactoryCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;
use ReflectionClass;
use ReflectionNamedType;
use ReflectionParameter;

use function array_filter;
Expand Down Expand Up @@ -105,7 +106,7 @@ function (ReflectionParameter $argument): bool {
}

$type = $argument->getType();
$class = null !== $type && ! $type->isBuiltin() ? $type->getName() : null;
$class = $type instanceof ReflectionNamedType && ! $type->isBuiltin() ? $type->getName() : null;

if (null === $class) {
throw new InvalidArgumentException(sprintf(
Expand All @@ -125,7 +126,7 @@ function (ReflectionParameter $argument): bool {

return array_map(function (ReflectionParameter $parameter): ?string {
$type = $parameter->getType();
return null !== $type && ! $type->isBuiltin() ? $type->getName() : null;
return $type instanceof ReflectionNamedType && ! $type->isBuiltin() ? $type->getName() : null;
}, $constructorParameters);
}

Expand Down

0 comments on commit fa2ec24

Please sign in to comment.