Skip to content

Commit

Permalink
[RequestMapper]: Added GitHub workflows and update dependencies for s…
Browse files Browse the repository at this point in the history
…upporting symfony 5.4 and 6.0 and Refactoring
  • Loading branch information
fractalzombie committed Dec 5, 2021
1 parent 47569ff commit 9aac1de
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion EventListener/RequestMapperListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function onKernelController(ControllerEvent $event): void
private function getReflectionMethod(mixed $controller): \ReflectionMethod|\ReflectionFunction
{
return match (true) {
\is_array($controller) => new \ReflectionMethod(...$controller),
\is_array($controller) => new \ReflectionMethod(/* @scrutinizer ignore-type */ ...$controller),
\is_object($controller) && \is_callable([$controller, '__invoke']) => new \ReflectionMethod($controller, '__invoke'),
default => new \ReflectionFunction($controller),
};
Expand Down
8 changes: 4 additions & 4 deletions Extractor/ConstraintExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ class ConstraintExtractor
public function extract(string $class): ?Collection
{
try {
$rClass = new \ReflectionClass($class);
return ConstraintsHelper::createCollection($this->extractConstraints(new \ReflectionClass($class)));
} catch (\ReflectionException) {
return null;
}

return ConstraintsHelper::createCollection($this->extractConstraints($rClass));
}

/** @throws \ReflectionException */
private function extractConstraints(\ReflectionClass $rClass): array
{
$constraints = [];
Expand All @@ -34,7 +33,8 @@ private function extractConstraints(\ReflectionClass $rClass): array

foreach ($rClass->getProperties() as $property) {
$propertyName = SerializerHelper::getSerializedNameAttribute($property)->getSerializedName();
$constraints[$propertyName] = ClassHelper::isNotBuiltinAndExists($propertyClass = $property->getType()?->getName())
$propertyClass = $property->getType()?->/* @scrutinizer ignore-call */ getName();
$constraints[$propertyName] = ClassHelper::isNotBuiltinAndExists($propertyClass)
? ConstraintsHelper::createCollection($this->extractConstraints(new \ReflectionClass($propertyClass)))
: ConstraintsHelper::fromProperty($property);
}
Expand Down
2 changes: 1 addition & 1 deletion Helper/ClassHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function getPropertyMapping(string $className): array
}

$map = static fn (\ReflectionProperty $p): array => [
SerializerHelper::getSerializedNameAttribute($p)->getSerializedName() => $p->getType()?->getName(),
SerializerHelper::getSerializedNameAttribute($p)->getSerializedName() => $p->getType()?->/* @scrutinizer ignore-call */ getName(),
];

return array_merge(...array_map($map, $properties));
Expand Down
2 changes: 1 addition & 1 deletion Helper/ParamConverterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class ParamConverterHelper
public static function getAttribute(\ReflectionParameter $parameter, array $attributes): ?ParamConverter
{
return $attributes[$parameter->getName()]
?? $attributes[$parameter->getType()?->getName()]
?? $attributes[$parameter->getType()?->/* @scrutinizer ignore-call */ getName()]
?? self::searchAttribute($parameter, $attributes);
}

Expand Down
2 changes: 0 additions & 2 deletions Tests/Unit/Data/ConverterDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

declare(strict_types=1);


namespace FRZB\Component\RequestMapper\Tests\Unit\Data;


use FRZB\Component\RequestMapper\Attribute\ParamConverter;
use FRZB\Component\RequestMapper\Data\ConverterData;
use FRZB\Component\RequestMapper\Tests\Helper\RequestHelper;
Expand Down

0 comments on commit 9aac1de

Please sign in to comment.