Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflection factory resolves array $options #238

Open
wants to merge 1 commit into
base: 3.23.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/AbstractFactory/ReflectionBasedAbstractFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

UnusedBaselineEntry

src/AbstractFactory/ReflectionBasedAbstractFactory.php:0:0: UnusedBaselineEntry: Baseline for issue "MissingClosureReturnType" has 1 extra entry. (see https://psalm.dev/316)

declare(strict_types=1);

Expand Down Expand Up @@ -123,8 +123,8 @@
}

$resolver = $container->has('config')
? $this->resolveParameterWithConfigService($container, $requestedName)
: $this->resolveParameterWithoutConfigService($container, $requestedName);
? $this->resolveParameterWithConfigService($container, $requestedName, $options)
: $this->resolveParameterWithoutConfigService($container, $requestedName, $options);

$parameters = array_map($resolver, $reflectionParameters);

Expand Down Expand Up @@ -153,7 +153,7 @@
* @param string $requestedName
* @return callable
*/
private function resolveParameterWithoutConfigService(ContainerInterface $container, $requestedName)
private function resolveParameterWithoutConfigService(ContainerInterface $container, $requestedName, $options)

Check failure on line 156 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Method \Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::resolveParameterWithoutConfigService() does not have parameter type hint nor @param annotation for its parameter $options.

Check failure on line 156 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

MissingParamType

src/AbstractFactory/ReflectionBasedAbstractFactory.php:156:106: MissingParamType: Parameter $options has no provided type (see https://psalm.dev/154)
{
/**
* @param ReflectionParameter $parameter
Expand All @@ -162,7 +162,7 @@
* resolved to a service in the container.
* @psalm-suppress MissingClosureReturnType
*/
return fn(ReflectionParameter $parameter) => $this->resolveParameter($parameter, $container, $requestedName);
return fn(ReflectionParameter $parameter) => $this->resolveParameter($parameter, $container, $requestedName, $options);

Check warning on line 165 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Line exceeds 120 characters; contains 127 characters
}

/**
Expand All @@ -174,22 +174,22 @@
* @param string $requestedName
* @return callable
*/
private function resolveParameterWithConfigService(ContainerInterface $container, $requestedName)
private function resolveParameterWithConfigService(ContainerInterface $container, $requestedName, $options)

Check failure on line 177 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Method \Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::resolveParameterWithConfigService() does not have parameter type hint nor @param annotation for its parameter $options.

Check failure on line 177 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

MissingParamType

src/AbstractFactory/ReflectionBasedAbstractFactory.php:177:103: MissingParamType: Parameter $options has no provided type (see https://psalm.dev/154)
{
/**
* @param ReflectionParameter $parameter
* @return mixed
* @throws ServiceNotFoundException If type-hinted parameter cannot be
* resolved to a service in the container.
*/
return function (ReflectionParameter $parameter) use ($container, $requestedName) {
return function (ReflectionParameter $parameter) use ($container, $requestedName, $options) {

Check failure on line 185 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

MissingClosureReturnType

src/AbstractFactory/ReflectionBasedAbstractFactory.php:185:16: MissingClosureReturnType: Closure does not have a return type, expecting mixed (see https://psalm.dev/068)
if ($parameter->getName() === 'config') {
$type = $parameter->getType();
if ($type instanceof ReflectionNamedType && $type->getName() === 'array') {
return $container->get('config');
}
}
return $this->resolveParameter($parameter, $container, $requestedName);
return $this->resolveParameter($parameter, $container, $requestedName, $options);
};
}

Expand All @@ -201,12 +201,15 @@
* @throws ServiceNotFoundException If type-hinted parameter cannot be
* resolved to a service in the container.
*/
private function resolveParameter(ReflectionParameter $parameter, ContainerInterface $container, $requestedName)
private function resolveParameter(ReflectionParameter $parameter, ContainerInterface $container, $requestedName, $options)

Check failure on line 204 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Method \Laminas\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory::resolveParameter() does not have parameter type hint nor @param annotation for its parameter $options.

Check warning on line 204 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Line exceeds 120 characters; contains 126 characters

Check failure on line 204 in src/AbstractFactory/ReflectionBasedAbstractFactory.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

MissingParamType

src/AbstractFactory/ReflectionBasedAbstractFactory.php:204:118: MissingParamType: Parameter $options has no provided type (see https://psalm.dev/154)
{
$type = $parameter->getType();
$type = $type instanceof ReflectionNamedType ? $type->getName() : null;

if ($type === 'array') {
if ($parameter->getName() === 'options') {
return $options ?? [];
}
return [];
}

Expand Down