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 65fdef7 commit 1647c80
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/php.yml
Expand Up @@ -2,14 +2,14 @@ name: Tests

on:
push:
branches: [main]
branches: [ main ]

pull_request:
branches: [main]
branches: [ main ]

page_build:
release:
types: [published, created, edited]
types: [ published, created, edited ]

jobs:
build:
Expand Down Expand Up @@ -37,6 +37,7 @@ jobs:
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --prefer-dist --no-progress
Expand Down
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Expand Up @@ -19,6 +19,8 @@
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'],
'comment_to_phpdoc' => ['ignored_tags' => ['scrutinizer']],
'phpdoc_to_comment' => ['ignored_tags' => ['scrutinizer']],
'date_time_immutable' => true,
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'php_unit_test_case_static_method_calls' => false,
Expand Down
2 changes: 1 addition & 1 deletion EventListener/RequestMapperListener.php
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(/* @scrutinizer ignore-type */ ...$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
2 changes: 1 addition & 1 deletion Extractor/ConstraintExtractor.php
Expand Up @@ -33,7 +33,7 @@ private function extractConstraints(\ReflectionClass $rClass): array

foreach ($rClass->getProperties() as $property) {
$propertyName = SerializerHelper::getSerializedNameAttribute($property)->getSerializedName();
$propertyClass = $property->getType()?->/* @scrutinizer ignore-call */ 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
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()?->/* @scrutinizer ignore-call */ getName(),
SerializerHelper::getSerializedNameAttribute($p)->getSerializedName() => $p->getType()?->/** @scrutinizer ignore-call */ getName(),
];

return array_merge(...array_map($map, $properties));
Expand Down
9 changes: 6 additions & 3 deletions Helper/ParamConverterHelper.php
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()?->/* @scrutinizer ignore-call */ getName()]
?? $attributes[$parameter->getType()?->/** @scrutinizer ignore-call */ getName()]
?? self::searchAttribute($parameter, $attributes);
}

Expand All @@ -44,9 +44,12 @@ public static function fromReflectionAttributes(\ReflectionAttribute ...$attribu

public static function fromReflectionParameter(\ReflectionParameter $parameter): ?ParamConverter
{
$parameterName = $parameter->getName();
$parameterType = $parameter->getType()?->/** @scrutinizer ignore-call */ getName();

return match (true) {
!$parameter->getType()?->getName(), !ClassHelper::isNameContains($parameter->getType()?->getName(), ...self::REQUEST_POSTFIXES) => null,
default => new ParamConverter(parameterClass: $parameter->getType()?->getName(), parameterName: $parameter->getName()),
!$parameterType, !ClassHelper::isNameContains($parameterType, ...self::REQUEST_POSTFIXES) => null,
default => new ParamConverter(parameterClass: $parameterType, parameterName: $parameterName),
};
}

Expand Down
5 changes: 1 addition & 4 deletions composer.json
@@ -1,6 +1,5 @@
{
"name": "frzb/request-mapper",
"version": "v1.4.2",
"type": "library",
"description": "The RequestMapper component allows you to serialize JSON request to Request class and validate it",
"keywords": [
Expand Down Expand Up @@ -60,6 +59,7 @@
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them"
},
"conflict": {
"symfony/symfony": "*",
"ext-psr": "<1.1|>=2",
"symfony/config": "<5.4|>6.0",
"symfony/finder": "<5.4|>6.0",
Expand All @@ -85,9 +85,6 @@
"php -n -dzend_extension=xdebug -dxdebug.mode=coverage vendor/bin/phpunit --colors=always --verbose --configuration phpunit.xml.dist --log-junit var/tests/.phpunit.output.xml --coverage-html var/tests/coverage --coverage-clover var/tests/coverage/coverage.xml"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1647c80

Please sign in to comment.