Skip to content

Commit

Permalink
Merge pull request #1437 from tarlepp/feat/ecs-parallel
Browse files Browse the repository at this point in the history
Feat/Run ECS tool parallel
  • Loading branch information
tarlepp committed Oct 1, 2021
2 parents d421cd6 + 14a0843 commit f38344c
Show file tree
Hide file tree
Showing 64 changed files with 659 additions and 241 deletions.
4 changes: 3 additions & 1 deletion .idea/symfony-flex-backend.iml

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

3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -113,7 +113,8 @@
],
"PhpCsFixer\\": "tools/04_symplify/vendor/symplify/easy-coding-standard/vendor/friendsofphp/php-cs-fixer/src",
"Symplify\\CodingStandard\\": "tools/04_symplify/vendor/symplify/easy-coding-standard/vendor/symplify/coding-standard/src",
"Symplify\\RuleDocGenerator\\": "tools/04_symplify/vendor/symplify/easy-coding-standard/vendor/symplify/rule-doc-generator-contracts/src",
"Symplify\\EasyCodingStandard\\": "tools/04_symplify/vendor/symplify/easy-coding-standard/src",
"ECSPrefix20210928\\Symplify\\RuleDocGenerator\\": "tools/04_symplify/vendor/symplify/easy-coding-standard/vendor/symplify/rule-doc-generator-contracts/src",
"PHPStan\\PhpDoc\\PHPUnit\\": "tools/02_phpstan/vendor/phpstan/phpstan-phpunit/src/PhpDoc/PHPUnit",
"PHPStan\\Rules\\PHPUnit\\": "tools/02_phpstan/vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit",
"PHPStan\\Symfony\\": "tools/02_phpstan/vendor/phpstan/phpstan-symfony/src/Symfony",
Expand Down
13 changes: 3 additions & 10 deletions ecs.php
Expand Up @@ -11,7 +11,6 @@
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer;
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer;
Expand All @@ -30,12 +29,9 @@
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer;
use PhpCsFixer\Fixer\Whitespace\HeredocIndentationFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer;
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer;
use Symplify\CodingStandard\Fixer\Strict\BlankLineAfterStrictTypesFixer;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$imports = [
Expand Down Expand Up @@ -173,14 +169,11 @@
NotOperatorWithSuccessorSpaceFixer::class => null,
SingleLineThrowFixer::class => null,
BlankLineAfterStrictTypesFixer::class => null,
ParamReturnAndVarTagMalformsFixer::class => null,
ArrayOpenerAndCloserNewlineFixer::class => null,
ArrayListItemNewlineFixer::class => null,
PhpdocAlignFixer::class => null,
HeredocIndentationFixer::class => null,
PhpdocToCommentFixer::class => null,
NativeFunctionInvocationFixer::class => null,
NativeConstantInvocationFixer::class => null,
]
);

$parameters->set(Option::PARALLEL, true);
};
7 changes: 6 additions & 1 deletion src/Command/ApiKey/ApiKeyHelper.php
Expand Up @@ -94,7 +94,12 @@ private function getApiKeyEntity(SymfonyStyle $io, string $question): ?ApiKey
{
$choices = [];

array_map($this->getApiKeyIterator($choices), $this->apiKeyResource->find(orderBy: ['token' => 'ASC']));
array_map(
$this->getApiKeyIterator($choices),
$this->apiKeyResource->find(orderBy: [
'token' => 'ASC',
])
);

$choices['Exit'] = 'Exit command';

Expand Down
9 changes: 8 additions & 1 deletion src/Command/ApiKey/EditApiKeyCommand.php
Expand Up @@ -73,7 +73,14 @@ private function updateApiKey(InputInterface $input, OutputInterface $output, Ap
$helper = $this->getHelper('form');

/** @var ApiKeyDto $dtoEdit */
$dtoEdit = $helper->interactUsingForm(ApiKeyType::class, $input, $output, ['data' => $dtoLoaded]);
$dtoEdit = $helper->interactUsingForm(
ApiKeyType::class,
$input,
$output,
[
'data' => $dtoLoaded,
]
);

// Patch API key
$this->apiKeyResource->patch($apiKey->getId(), $dtoEdit);
Expand Down
7 changes: 6 additions & 1 deletion src/Command/ApiKey/ListApiKeysCommand.php
Expand Up @@ -72,7 +72,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function getRows(): array
{
return array_map($this->getFormatterApiKey(), $this->apiKeyResource->find(orderBy: ['token' => 'ASC']));
return array_map(
$this->getFormatterApiKey(),
$this->apiKeyResource->find(orderBy: [
'token' => 'ASC',
])
);
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/Command/User/EditUserCommand.php
Expand Up @@ -71,7 +71,14 @@ private function updateUser(InputInterface $input, OutputInterface $output, User
$helper = $this->getHelper('form');

/** @var UserDto $dtoEdit */
$dtoEdit = $helper->interactUsingForm(UserType::class, $input, $output, ['data' => $dtoLoaded]);
$dtoEdit = $helper->interactUsingForm(
UserType::class,
$input,
$output,
[
'data' => $dtoLoaded,
]
);

// Patch user
$this->userResource->patch($user->getId(), $dtoEdit);
Expand Down
9 changes: 8 additions & 1 deletion src/Command/User/EditUserGroupCommand.php
Expand Up @@ -74,7 +74,14 @@ protected function updateUserGroup(
$helper = $this->getHelper('form');

/** @var UserGroupDto $dtoEdit */
$dtoEdit = $helper->interactUsingForm(UserGroupType::class, $input, $output, ['data' => $dtoLoaded]);
$dtoEdit = $helper->interactUsingForm(
UserGroupType::class,
$input,
$output,
[
'data' => $dtoLoaded,
]
);

// Patch user group
$this->userGroupResource->patch($userGroup->getId(), $dtoEdit);
Expand Down
7 changes: 6 additions & 1 deletion src/Command/User/ListUserGroupsCommand.php
Expand Up @@ -70,7 +70,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function getRows(): array
{
return array_map($this->getFormatterUserGroup(), $this->userGroupResource->find(orderBy: ['name' => 'ASC']));
return array_map(
$this->getFormatterUserGroup(),
$this->userGroupResource->find(orderBy: [
'name' => 'ASC',
])
);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Command/User/ListUsersCommand.php
Expand Up @@ -74,7 +74,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function getRows(): array
{
return array_map($this->getFormatterUser(), $this->userResource->find(orderBy: ['username' => 'ASC']));
return array_map(
$this->getFormatterUser(),
$this->userResource->find(orderBy: [
'username' => 'ASC',
])
);
}

/**
Expand Down
14 changes: 12 additions & 2 deletions src/Command/User/UserHelper.php
Expand Up @@ -91,7 +91,12 @@ private function getUserEntity(SymfonyStyle $io, string $question): ?User
$choices = [];
$iterator = $this->getUserIterator($choices);

array_map($iterator, $this->userResource->find(orderBy: ['username' => 'asc']));
array_map(
$iterator,
$this->userResource->find(orderBy: [
'username' => 'asc',
])
);

$choices['Exit'] = 'Exit command';

Expand All @@ -109,7 +114,12 @@ private function getUserGroupEntity(SymfonyStyle $io, string $question): ?UserGr
$choices = [];
$iterator = $this->getUserGroupIterator($choices);

array_map($iterator, $this->userGroupResource->find(orderBy: ['name' => 'asc']));
array_map(
$iterator,
$this->userGroupResource->find(orderBy: [
'name' => 'asc',
])
);

$choices['Exit'] = 'Exit command';

Expand Down
1 change: 1 addition & 0 deletions src/Command/Utils/CheckDependencies.php
Expand Up @@ -39,6 +39,7 @@
use function sprintf;
use function str_replace;
use function strlen;
use const DIRECTORY_SEPARATOR;

/**
* Class CheckDependencies
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/VersionController.php
Expand Up @@ -46,6 +46,8 @@ public function __construct(
)]
public function __invoke(): JsonResponse
{
return new JsonResponse(['version' => $this->version->get()]);
return new JsonResponse([
'version' => $this->version->get(),
]);
}
}
4 changes: 3 additions & 1 deletion src/Controller/v1/Profile/GroupsController.php
Expand Up @@ -96,7 +96,9 @@ public function __invoke(User $loggedInUser): JsonResponse
$this->serializer->serialize(
$loggedInUser->getUserGroups()->toArray(),
'json',
['groups' => UserGroup::SET_USER_PROFILE_GROUPS],
[
'groups' => UserGroup::SET_USER_PROFILE_GROUPS,
],
),
json: true,
);
Expand Down
8 changes: 7 additions & 1 deletion src/Controller/v1/Profile/IndexController.php
Expand Up @@ -84,7 +84,13 @@ public function __invoke(User $loggedInUser): JsonResponse
{
/** @var array<string, string|array<string, string>> $output */
$output = JSON::decode(
$this->serializer->serialize($loggedInUser, 'json', ['groups' => User::SET_USER_PROFILE]),
$this->serializer->serialize(
$loggedInUser,
'json',
[
'groups' => User::SET_USER_PROFILE,
]
),
true,
);

Expand Down
4 changes: 3 additions & 1 deletion src/Controller/v1/Role/FindOneRoleController.php
Expand Up @@ -41,7 +41,9 @@ public function __construct(
*/
#[Route(
path: '/v1/role/{role}',
requirements: ['role' => '^ROLE_\w+$'],
requirements: [
'role' => '^ROLE_\w+$',
],
methods: [Request::METHOD_GET],
)]
#[IsGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY)]
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/v1/Role/InheritedRolesController.php
Expand Up @@ -74,7 +74,9 @@ public function __construct(
*/
#[Route(
path: '/v1/role/{role}/inherited',
requirements: ['role' => '^ROLE_\w+$'],
requirements: [
'role' => '^ROLE_\w+$',
],
methods: [Request::METHOD_GET],
)]
#[IsGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY)]
Expand Down
4 changes: 3 additions & 1 deletion src/EventSubscriber/ResponseSubscriber.php
Expand Up @@ -46,6 +46,8 @@ public static function getSubscribedEvents(): array
public function onKernelResponse(ResponseEvent $event): void
{
// Attach new header
$event->getResponse()->headers->add(['X-API-VERSION' => $this->version->get()]);
$event->getResponse()->headers->add([
'X-API-VERSION' => $this->version->get(),
]);
}
}
5 changes: 4 additions & 1 deletion src/Repository/BaseRepository.php
Expand Up @@ -123,7 +123,10 @@ public function remove(EntityInterface $entity, ?bool $flush = null): self
public function processQueryBuilder(QueryBuilder $queryBuilder): void
{
// Reset processed joins and callbacks
self::$processedJoins = [self::INNER_JOIN => [], self::LEFT_JOIN => []];
self::$processedJoins = [
self::INNER_JOIN => [],
self::LEFT_JOIN => [],
];
self::$processedCallbacks = [];

$this->processJoins($queryBuilder);
Expand Down
4 changes: 3 additions & 1 deletion src/Rest/ResponseHandler.php
Expand Up @@ -95,7 +95,9 @@ public function getSerializeContext(Request $request, ?RestResourceInterface $re
}

return array_merge(
['groups' => $groups],
[
'groups' => $groups,
],
$restResource !== null ? $restResource->getSerializerContext() : [],
);
}
Expand Down
8 changes: 7 additions & 1 deletion src/Rest/Traits/Methods/CountMethod.php
Expand Up @@ -42,7 +42,13 @@ public function countMethod(Request $request, ?array $allowedHttpMethods = null)

return $this
->getResponseHandler()
->createResponse($request, ['count' => $resource->count($criteria, $search)], $resource);
->createResponse(
$request,
[
'count' => $resource->count($criteria, $search),
],
$resource
);
} catch (Throwable $exception) {
throw $this->handleRestMethodException($exception);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Security/Provider/ApiKeyUserProvider.php
Expand Up @@ -55,7 +55,9 @@ public function refreshUser(UserInterface $user): UserInterface

public function getApiKeyForToken(string $token): ?ApiKey
{
return $this->apiKeyRepository->findOneBy(['token' => $token]);
return $this->apiKeyRepository->findOneBy([
'token' => $token,
]);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Utils/Tests/Auth.php
Expand Up @@ -25,6 +25,7 @@
use function sprintf;
use function str_pad;
use function sys_get_temp_dir;
use const DIRECTORY_SEPARATOR;

/**
* Class Auth
Expand Down Expand Up @@ -137,7 +138,10 @@ private function getToken(string $username, string $password): string
'HTTP_X-Requested-With' => 'XMLHttpRequest',
]
),
JSON::encode(['username' => $username, 'password' => $password])
JSON::encode([
'username' => $username,
'password' => $password,
])
);

$response = $client->getResponse();
Expand Down
14 changes: 12 additions & 2 deletions src/Utils/Tests/WebTestCase.php
Expand Up @@ -77,7 +77,15 @@ public function getTestClient(

self::ensureKernelShutdown();

return static::createClient(array_merge($options, ['debug' => false]), $server);
return static::createClient(
array_merge(
$options,
[
'debug' => false,
]
),
$server
);
}

/**
Expand All @@ -96,7 +104,9 @@ public function getApiKeyClient(?string $role = null, ?array $options = null, ?a
// Merge authorization headers
$server = array_merge(
$role === null
? ['HTTP_AUTHORIZATION' => 'ApiKey invalid-api-key']
? [
'HTTP_AUTHORIZATION' => 'ApiKey invalid-api-key',
]
: $authService->getAuthorizationHeadersForApiKey($role),
array_merge($this->getJsonHeaders(), $this->getFastestHeaders()),
$authService->getJwtHeaders(),
Expand Down
4 changes: 3 additions & 1 deletion tests/E2E/Rest/ResourceLifeCycleTest.php
Expand Up @@ -37,7 +37,9 @@ public function testThatModifiedEntityIsNotFlushedIfLifeCycleMethodThrowsAnExcep
$client->request('GET', '/test_lifecycle_behaviour/' . $role);

$response = $client->getResponse();
$entity = $this->getRepository()->findOneBy(['id' => $role]);
$entity = $this->getRepository()->findOneBy([
'id' => $role,
]);

static::assertNotNull($entity, sprintf('Role entity for id `%s` not found...', $role));
static::assertSame(418, $response->getStatusCode(), (string)$response->getContent());
Expand Down

0 comments on commit f38344c

Please sign in to comment.