Skip to content

Commit

Permalink
"Small" refactor (#531)
Browse files Browse the repository at this point in the history
* IDE settings

* Refactored phpdoc blocks from `App\ArgumentResolver` namespace.

* Changed ECS rules and fixed those errors.

* Refactored phpdoc blocks from `App\AutoMapper` namespace.

* Refactored phpdoc blocks from `App\Collection` namespace.

* Make PHPStan happy :D

* Change of ECS rules - this will cause a massive update to codebase...

* IDE settings

* Refactored phpdoc blocks from `App\Command` namespace.

* Refactored phpdoc blocks from `App\Controller` namespace.

* Refactored phpdoc blocks from `App\DataFixtures` namespace.

* Refactored phpdoc blocks from `App\Doctrine` namespace.

* Refactored phpdoc blocks from `App\DTO` namespace.

* IDE settings

* Refactored phpdoc blocks from `App\Entity` namespace.

* Refactored phpdoc blocks from `App\Entity` namespace.

* IDE settings

* Refactored phpdoc blocks from `App\EventListener` namespace.

* Refactored phpdoc blocks from `App\EventSubscriber` namespace.

* Refactored phpdoc blocks from `App\Exception` namespace.

* Refactored phpdoc blocks from `App\Form` namespace.

* Removed obsolete use statements.

* Refactored phpdoc blocks from `App\Helpers` namespace.

* Changed `@link` annotation to `@see`

* Refactored phpdoc blocks from `App\Migrations` namespace.

* Refactored migration template.

* Fixed PHPStan errors.

* Fixed @param annotation

* Refactored phpdoc blocks from `App\Repository` namespace.

* Refactored phpdoc blocks from `App\Repository` namespace.

* Refactored phpdoc blocks from `App\Request` namespace.

* Refactored phpdoc blocks from `App\Resource` namespace.

* Fixed return type

* Fixed return type

* Refactored phpdoc blocks from `App\Rest` namespace.

* Fixed types

* Refactored phpdoc blocks from `App\Security` namespace.

* Refactored phpdoc blocks from `App\Serializer` namespace.

* Fixed parameter types.

* Fixed PHPStan errors.

* Refactored phpdoc blocks from `App\Service` namespace.

* Fixed one liner comment block

* Refactored phpdoc blocks from `App\Validator` namespace.

* Refactored phpdoc blocks from `App\Utils` namespace.

* Removed obsolete use statement.

* Refactored phpdoc blocks from `App\Tests` namespace.

* Removed obsolete `RestApiDoc` annotation - this will be replaced later on...

* Fixed types

* Use pure mixed as return type

* Fixed tests - those were using wrong input data.

* Refactored `DtoTestCase` to use `PropertyInfoExtractor`

* Fixed some of Psalm errors.

* Removed `--taint-analysis` option from Psalm

* Fixed Psalm errors.

* Let's make PHPStan and Psalm happy together

* Make PHP Insights happy
  • Loading branch information
tarlepp committed Jul 9, 2020
1 parent e0085d5 commit b9332e8
Show file tree
Hide file tree
Showing 360 changed files with 933 additions and 5,887 deletions.
21 changes: 14 additions & 7 deletions .idea/inspectionProfiles/Project_Default.xml

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

4 changes: 4 additions & 0 deletions .idea/symfony-flex-backend.iml

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

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ ifeq ($(INSIDE_DOCKER), 1)
@mkdir -p build
@@bin/console cache:clear --env=test
@php ./vendor/bin/psalm --version
@php ./vendor/bin/psalm --no-cache --taint-analysis --report=./build/psalm.json
@php ./vendor/bin/psalm --no-cache --report=./build/psalm.json
else
$(WARNING_DOCKER)
endif
Expand All @@ -228,7 +228,7 @@ ifeq ($(INSIDE_DOCKER), 1)
@mkdir -p build
@@bin/console cache:clear --env=test
@php ./vendor/bin/psalm --version
@php ./vendor/bin/psalm --no-cache --taint-analysis --shepherd --report=./build/psalm.json
@php ./vendor/bin/psalm --no-cache --shepherd --report=./build/psalm.json
else
$(WARNING_DOCKER)
endif
Expand Down
7 changes: 5 additions & 2 deletions ecs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ services:
- 'class'
- 'function'
- 'const'
PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer:
remove_inheritdoc: false
allow_mixed: true
allow_unused_params: true
PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer:
space: 'single'
PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer:
Expand All @@ -39,11 +43,10 @@ services:
parameters:
skip:
PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer: ~
PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer: ~
#PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer: ~
PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer: ~
PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer: ~
PhpCsFixer\Fixer\NamespaceNotation\NoBlankLinesBeforeNamespaceFixer: ~
Expand Down
25 changes: 0 additions & 25 deletions src/Annotation/RestApiDoc.php

This file was deleted.

19 changes: 4 additions & 15 deletions src/ArgumentResolver/EntityValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,14 @@ class EntityValueResolver implements ArgumentValueResolverInterface

/**
* EntityValueResolver constructor.
*
* @param ResourceCollection $resourceCollection
*/
public function __construct(ResourceCollection $resourceCollection)
{
$this->resourceCollection = $resourceCollection;
}

/**
* Whether this resolver can resolve the value for the given ArgumentMetadata.
*
* @param Request $request
* @param ArgumentMetadata $argument
*
* @return bool
* {@inheritdoc}
*/
public function supports(Request $request, ArgumentMetadata $argument): bool
{
Expand All @@ -70,18 +63,14 @@ public function supports(Request $request, ArgumentMetadata $argument): bool
}

/**
* Returns the possible value(s).
*
* @param Request $request
* @param ArgumentMetadata $argument
*
* @return Generator
* {@inheritdoc}
*
* @throws Throwable
*/
public function resolve(Request $request, ArgumentMetadata $argument): Generator
{
yield $this->resourceCollection->getEntityResource((string)$argument->getType())
yield $this->resourceCollection
->getEntityResource((string)$argument->getType())
->findOne($request->get($argument->getName()), !$argument->isNullable());
}
}
17 changes: 2 additions & 15 deletions src/ArgumentResolver/LoggedInUserValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class LoggedInUserValueResolver implements ArgumentValueResolverInterface

/**
* LoggedInUserValueResolver constructor.
*
* @param TokenStorageInterface $tokenStorage
* @param UserTypeIdentification $userService
*/
public function __construct(TokenStorageInterface $tokenStorage, UserTypeIdentification $userService)
{
Expand All @@ -56,12 +53,7 @@ public function __construct(TokenStorageInterface $tokenStorage, UserTypeIdentif
}

/**
* Whether this resolver can resolve the value for the given ArgumentMetadata.
*
* @param Request $request
* @param ArgumentMetadata $argument
*
* @return bool
* {@inheritdoc}
*/
public function supports(Request $request, ArgumentMetadata $argument): bool
{
Expand All @@ -86,12 +78,7 @@ public function supports(Request $request, ArgumentMetadata $argument): bool
}

/**
* Returns the possible value(s).
*
* @param Request $request
* @param ArgumentMetadata $argumentMetadata
*
* @return Generator
* {@inheritdoc}
*
* @throws Throwable
*/
Expand Down
17 changes: 2 additions & 15 deletions src/ArgumentResolver/RestDtoValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ class RestDtoValueResolver implements ArgumentValueResolverInterface

/**
* RestDtoValueResolver constructor.
*
* @param ControllerCollection $controllerCollection
* @param AutoMapperInterface $autoMapper
*/
public function __construct(ControllerCollection $controllerCollection, AutoMapperInterface $autoMapper)
{
Expand All @@ -65,12 +62,7 @@ public function __construct(ControllerCollection $controllerCollection, AutoMapp
}

/**
* Whether this resolver can resolve the value for the given ArgumentMetadata.
*
* @param Request $request
* @param ArgumentMetadata $argument
*
* @return bool
* {@inheritdoc}
*/
public function supports(Request $request, ArgumentMetadata $argument): bool
{
Expand All @@ -86,12 +78,7 @@ public function supports(Request $request, ArgumentMetadata $argument): bool
}

/**
* Returns the possible value(s).
*
* @param Request $request
* @param ArgumentMetadata $argumentMetadata
*
* @return Generator
* {@inheritdoc}
*
* @throws UnregisteredMappingException
*/
Expand Down
2 changes: 0 additions & 2 deletions src/AutoMapper/ApiKey/AutoMapperConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class AutoMapperConfiguration extends RestAutoMapperConfiguration

/**
* AutoMapperConfiguration constructor.
*
* @param RequestMapper $requestMapper
*/
public function __construct(RequestMapper $requestMapper)
{
Expand Down
6 changes: 2 additions & 4 deletions src/AutoMapper/ApiKey/RequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ class RequestMapper extends RestRequestMapper

/**
* RequestMapper constructor.
*
* @param UserGroupResource $userGroupResource
*/
public function __construct(UserGroupResource $userGroupResource)
{
$this->userGroupResource = $userGroupResource;
}

/**
* @param array|array<int, string> $userGroups
* @param array<int, string> $userGroups
*
* @return array|UserGroup[]
* @return array<int, UserGroup>
*/
protected function transformUserGroups(array $userGroups): array
{
Expand Down
2 changes: 0 additions & 2 deletions src/AutoMapper/RestAutoMapperConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ abstract class RestAutoMapperConfiguration implements AutoMapperConfiguratorInte

/**
* Use this method to register your mappings.
*
* @param AutoMapperConfigInterface $config
*/
public function configure(AutoMapperConfigInterface $config): void
{
Expand Down
13 changes: 0 additions & 13 deletions src/AutoMapper/RestRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ abstract class RestRequestMapper implements MapperInterface
* {@inheritdoc}
*
* @param array|object $source
* @param string $targetClass
* @param array<int, mixed> $context
*
* @return RestDtoInterface
*/
public function map($source, string $targetClass, array $context = []): RestDtoInterface
{
Expand All @@ -60,8 +57,6 @@ public function map($source, string $targetClass, array $context = []): RestDtoI
* @param array|object $source
* @param object $destination
* @param array<int, mixed> $context
*
* @return RestDtoInterface
*/
public function mapToObject($source, $destination, array $context = []): RestDtoInterface
{
Expand Down Expand Up @@ -104,12 +99,6 @@ public function mapToObject($source, $destination, array $context = []): RestDto
return $this->getObject($source, $destination);
}

/**
* @param Request $request
* @param RestDtoInterface $restDto
*
* @return RestDtoInterface
*/
private function getObject(Request $request, RestDtoInterface $restDto): RestDtoInterface
{
foreach ($this->getValidProperties($request) as $property) {
Expand All @@ -131,8 +120,6 @@ private function getObject(Request $request, RestDtoInterface $restDto): RestDto
}

/**
* @param Request $request
*
* @return array<int, string>
*/
private function getValidProperties(Request $request): array
Expand Down
2 changes: 0 additions & 2 deletions src/AutoMapper/User/AutoMapperConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class AutoMapperConfiguration extends RestAutoMapperConfiguration

/**
* AutoMapperConfiguration constructor.
*
* @param RequestMapper $requestMapper
*/
public function __construct(RequestMapper $requestMapper)
{
Expand Down
6 changes: 2 additions & 4 deletions src/AutoMapper/User/RequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@ class RequestMapper extends RestRequestMapper

/**
* RequestMapper constructor.
*
* @param UserGroupResource $userGroupResource
*/
public function __construct(UserGroupResource $userGroupResource)
{
$this->userGroupResource = $userGroupResource;
}

/**
* @param array|array<int, string> $userGroups
* @param array<int, string> $userGroups
*
* @return array|UserGroup[]
* @return array<int, UserGroup>
*/
protected function transformUserGroups(array $userGroups): array
{
Expand Down
2 changes: 0 additions & 2 deletions src/AutoMapper/UserGroup/AutoMapperConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class AutoMapperConfiguration extends RestAutoMapperConfiguration

/**
* AutoMapperConfiguration constructor.
*
* @param RequestMapper $requestMapper
*/
public function __construct(RequestMapper $requestMapper)
{
Expand Down
6 changes: 0 additions & 6 deletions src/AutoMapper/UserGroup/RequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ class RequestMapper extends RestRequestMapper

/**
* RequestMapper constructor.
*
* @param RoleResource $roleResource
*/
public function __construct(RoleResource $roleResource)
{
$this->roleResource = $roleResource;
}

/**
* @param string $role
*
* @return Role
*
* @throws ORMException
*/
protected function transformRole(string $role): Role
Expand Down
Loading

0 comments on commit b9332e8

Please sign in to comment.