Skip to content

Commit

Permalink
Fix Deprecations for php8.0+ (#13)
Browse files Browse the repository at this point in the history
* Fix reflectionParameter->getClass() deprecation
Fix substr when $v is null deprecation

* Move null filtering to process
  • Loading branch information
vi-auto1 authored Dec 9, 2024
1 parent e43fc35 commit 6a9bbf4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions DependencyInjection/CompilerPass/EndpointRouterCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ public function process(ContainerBuilder $container)
if (strpos($id, '.abstract.instanceof.') === 0) {
continue;
}
$services[$id] = $definition->getClass();

$class = $definition->getClass();
if ($class === null) {
continue;
}
$services[$id] = $class;
}

$classToServiceMapping = array_flip($this->filterControllers($services));
Expand Down Expand Up @@ -130,17 +135,20 @@ private function getRouteDetailsForControllers(array $controllers) : array

$resolvedRequests = [];

foreach($reflectionMethod->getParameters() as $reflectionParameter) {
if (null === $reflectionParameter->getClass()) {
foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
$type = $reflectionParameter->getType();

if (!$type instanceof \ReflectionNamedType || $type->isBuiltin()) {
continue;
}

if ($reflectionParameter->getClass()->isAbstract()) {
$className = $type->getName();
if (!class_exists($className) || (new \ReflectionClass($className))->isAbstract()) {
continue;
}

if (is_subclass_of($reflectionParameter->getClass()->getName(), ServiceRequestInterface::class, true)) {
$resolvedRequests[] = $reflectionParameter->getClass()->getName();
if (is_subclass_of($className, ServiceRequestInterface::class)) {
$resolvedRequests[] = $className;
}
}

Expand Down

0 comments on commit 6a9bbf4

Please sign in to comment.