From e97d89dfd929d3aff5fc7724e8ff581207bf7cd6 Mon Sep 17 00:00:00 2001 From: Bertrand Dunogier Date: Mon, 18 Nov 2019 10:13:45 +0100 Subject: [PATCH] Fixed CS --- .gitignore | 1 + .php_cs | 7 +++++++ composer.json | 4 +++- .../nearby_places/NearbyPlacesQueryType.php | 10 ++++------ src/API/QueryFieldService.php | 8 ++++---- src/Controller/QueryFieldController.php | 11 +++++++---- src/Controller/QueryFieldRestController.php | 12 ++++++++---- src/FieldType/Mapper/QueryFormMapper.php | 11 ++++++++--- src/FieldType/Query/SearchField.php | 12 ++++++++---- src/FieldType/Query/Type.php | 15 +++++++++------ src/FieldType/Query/Value.php | 4 ++++ src/Form/Type/FieldType/QueryFieldType.php | 4 ++++ src/GraphQL/QueryFieldDefinitionMapper.php | 7 ++++++- src/GraphQL/QueryFieldResolver.php | 10 ++++++++-- .../FieldValue/Converter/QueryConverter.php | 6 +++++- .../BDEzPlatformQueryFieldTypeExtension.php | 9 +++++++-- .../ConfigurableFieldDefinitionMapperPass.php | 7 ++----- .../Compiler/QueryTypesListPass.php | 12 +++++++++--- .../EzSystemsEzPlatformQueryFieldTypeBundle.php | 4 ++++ 19 files changed, 108 insertions(+), 46 deletions(-) create mode 100644 .php_cs diff --git a/.gitignore b/.gitignore index 3a9875b..3452648 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor/ composer.lock +.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..da58c97 --- /dev/null +++ b/.php_cs @@ -0,0 +1,7 @@ +setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__ . '/src') + ->files()->name('*.php') +); diff --git a/composer.json b/composer.json index e0a2236..98d7113 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,9 @@ } }, "require-dev": { - "phpspec/phpspec": "^5.1" + "phpspec/phpspec": "^5.1", + "ezsystems/ezplatform-code-style": "^0.1.0", + "friendsofphp/php-cs-fixer": "^2.16.0" }, "extra": { "branch-alias": { diff --git a/doc/examples/nearby_places/NearbyPlacesQueryType.php b/doc/examples/nearby_places/NearbyPlacesQueryType.php index ea67a69..2b6f82d 100644 --- a/doc/examples/nearby_places/NearbyPlacesQueryType.php +++ b/doc/examples/nearby_places/NearbyPlacesQueryType.php @@ -1,11 +1,9 @@ resolveParameters($fieldDefinition->fieldSettings['Parameters'], $content); return array_map( - function(SearchHit $searchHit) { + function (SearchHit $searchHit) { return $searchHit->valueObject; }, $this->searchService->findContent($queryType->getQuery($parameters))->searchHits @@ -72,7 +73,6 @@ public function getFieldDefinition(ContentInfo $contentInfo, string $fieldDefini $this ->contentTypeService->loadContentType($contentInfo->contentTypeId) ->getFieldDefinition($fieldDefinitionIdentifier); - } /** @@ -105,4 +105,4 @@ private function applyContentToParameter(Content $content, string $parameter) ] ); } -} \ No newline at end of file +} diff --git a/src/Controller/QueryFieldController.php b/src/Controller/QueryFieldController.php index e6e7f0f..7d4740d 100644 --- a/src/Controller/QueryFieldController.php +++ b/src/Controller/QueryFieldController.php @@ -1,10 +1,13 @@ $this->queryFieldService->loadFieldData( $view->getContent(), $queryFieldDefinitionIdentifier - ) + ), ]); return $view; } -} \ No newline at end of file +} diff --git a/src/Controller/QueryFieldRestController.php b/src/Controller/QueryFieldRestController.php index 7d96c16..72045b6 100644 --- a/src/Controller/QueryFieldRestController.php +++ b/src/Controller/QueryFieldRestController.php @@ -1,4 +1,9 @@ queryFieldService = $queryFieldService; $this->contentService = $contentService; $this->contentTypeService = $contentTypeService; @@ -52,7 +56,7 @@ public function getResults($contentId, $versionNumber, $fieldDefinitionIdentifie return new ContentList( array_map( - function(Content $content) { + function (Content $content) { return new RestContent( $content->contentInfo, $this->locationService->loadLocation($content->contentInfo->mainLocationId), @@ -76,4 +80,4 @@ private function getContentType(ContentInfo $contentInfo): ContentType return $contentTypes[$contentInfo->contentTypeId]; } -} \ No newline at end of file +} diff --git a/src/FieldType/Mapper/QueryFormMapper.php b/src/FieldType/Mapper/QueryFormMapper.php index e9bbb4e..69bdc2d 100644 --- a/src/FieldType/Mapper/QueryFormMapper.php +++ b/src/FieldType/Mapper/QueryFormMapper.php @@ -1,5 +1,9 @@ add('QueryType',Type\ChoiceType::class, + ->add('QueryType', Type\ChoiceType::class, [ 'label' => 'Query type', 'property_path' => 'fieldSettings[QueryType]', @@ -51,7 +56,7 @@ public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, Field ->add('Parameters', Type\TextareaType::class, [ 'label' => 'Parameters', - 'property_path' => 'fieldSettings[Parameters]' + 'property_path' => 'fieldSettings[Parameters]', ] ); } diff --git a/src/FieldType/Query/SearchField.php b/src/FieldType/Query/SearchField.php index 564b3fc..6b40fbc 100644 --- a/src/FieldType/Query/SearchField.php +++ b/src/FieldType/Query/SearchField.php @@ -1,5 +1,9 @@ value->data, @@ -30,7 +34,7 @@ public function getIndexData(Field $field, FieldDefinition $fieldDefinition) $field->value->data, new Search\FieldType\FullTextField() ), - ); + ]; } /** @@ -40,9 +44,9 @@ public function getIndexData(Field $field, FieldDefinition $fieldDefinition) */ public function getIndexDefinition() { - return array( + return [ 'value' => new Search\FieldType\StringField(), - ); + ]; } /** diff --git a/src/FieldType/Query/Type.php b/src/FieldType/Query/Type.php index 480da52..16eda07 100644 --- a/src/FieldType/Query/Type.php +++ b/src/FieldType/Query/Type.php @@ -1,5 +1,9 @@ ['type' => 'string', 'default' => ''], @@ -19,7 +23,6 @@ class Type extends FieldType 'ReturnedType' => ['type' => 'string', 'default' => ''], ]; - /** * Validates the validatorConfiguration of a FieldDefinitionCreateStruct or FieldDefinitionUpdateStruct. * @@ -105,7 +108,7 @@ protected function createValueFromInput($inputValue) /** * Throws an exception if value structure is not of expected format. * - * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the value does not match the expected structure. + * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the value does not match the expected structure * * @param \eZ\Publish\Core\FieldType\TextLine\Value $value */ @@ -180,16 +183,16 @@ public function validateFieldSettings($fieldSettings) if (isset($fieldSettings['QueryType'])) { /** - * $errors[] = new ValidationError("Query type %query_type does not exist", null, ['%query_type%' => $fieldSettings['QueryType']]); + * $errors[] = new ValidationError("Query type %query_type does not exist", null, ['%query_type%' => $fieldSettings['QueryType']]);. */ } if (isset($fieldSettings['Parameters']) && $fieldSettings['Parameters']) { if (json_decode($fieldSettings['Parameters']) === null) { - $errors[] = new ValidationError("Parameters is not a valid json structure"); + $errors[] = new ValidationError('Parameters is not a valid json structure'); } } - return $errors; + return $errors; } } diff --git a/src/FieldType/Query/Value.php b/src/FieldType/Query/Value.php index 50ead20..9828074 100644 --- a/src/FieldType/Query/Value.php +++ b/src/FieldType/Query/Value.php @@ -1,5 +1,9 @@ contentTypeService->loadContentTypeByIdentifier($typeIdentifier) ); } -} \ No newline at end of file +} diff --git a/src/GraphQL/QueryFieldResolver.php b/src/GraphQL/QueryFieldResolver.php index 26bee14..33f9edc 100644 --- a/src/GraphQL/QueryFieldResolver.php +++ b/src/GraphQL/QueryFieldResolver.php @@ -1,4 +1,9 @@ queryFieldService = $queryFieldService; } @@ -20,4 +26,4 @@ public function resolveQueryField(Field $field, Content $content) { return $this->queryFieldService->loadFieldData($content, $field->fieldDefIdentifier); } -} \ No newline at end of file +} diff --git a/src/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php b/src/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php index 3cd7bd2..b298e6c 100644 --- a/src/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php +++ b/src/Persistence/Legacy/Content/FieldValue/Converter/QueryConverter.php @@ -1,5 +1,9 @@ fieldTypeConstraints->fieldSettings = [ 'QueryType' => $storageDef->dataText1 ?: null, 'ReturnedType' => $storageDef->dataText2 ?: null, - 'Parameters' => $storageDef->dataText5 ?: '' + 'Parameters' => $storageDef->dataText5 ?: '', ]; } diff --git a/src/Symfony/DependencyInjection/BDEzPlatformQueryFieldTypeExtension.php b/src/Symfony/DependencyInjection/BDEzPlatformQueryFieldTypeExtension.php index 3ae0f65..cbf0fde 100644 --- a/src/Symfony/DependencyInjection/BDEzPlatformQueryFieldTypeExtension.php +++ b/src/Symfony/DependencyInjection/BDEzPlatformQueryFieldTypeExtension.php @@ -1,4 +1,9 @@ [ 'controller' => QueryFieldController::class . ':renderQueryFieldAction', - 'template' => "BDEzPlatformQueryFieldTypeBundle::query_field_view.html.twig", + 'template' => 'BDEzPlatformQueryFieldTypeBundle::query_field_view.html.twig', 'match' => [], - ] + ], ]; $container->setParameter('ezsettings.default.content_view_defaults', $contentViewDefaults); } diff --git a/src/Symfony/DependencyInjection/Compiler/ConfigurableFieldDefinitionMapperPass.php b/src/Symfony/DependencyInjection/Compiler/ConfigurableFieldDefinitionMapperPass.php index 0f173e3..b7d3760 100644 --- a/src/Symfony/DependencyInjection/Compiler/ConfigurableFieldDefinitionMapperPass.php +++ b/src/Symfony/DependencyInjection/Compiler/ConfigurableFieldDefinitionMapperPass.php @@ -1,13 +1,11 @@ hasParameter(self::PARAMETER)) { @@ -34,4 +31,4 @@ public function process(ContainerBuilder $container) $container->setParameter(self::PARAMETER, $parameter); } -} \ No newline at end of file +} diff --git a/src/Symfony/DependencyInjection/Compiler/QueryTypesListPass.php b/src/Symfony/DependencyInjection/Compiler/QueryTypesListPass.php index 3e1d624..16412aa 100644 --- a/src/Symfony/DependencyInjection/Compiler/QueryTypesListPass.php +++ b/src/Symfony/DependencyInjection/Compiler/QueryTypesListPass.php @@ -1,4 +1,9 @@ getDefinition('ezpublish.query_type.registry')->getMethodCalls() as $methodCall) { if ($methodCall[0] === 'addQueryType') { $queryTypes[] = $methodCall[1][0]; - } else if ($methodCall[0] === 'addQueryTypes') { + } elseif ($methodCall[0] === 'addQueryTypes') { foreach (array_keys($methodCall[1][0]) as $queryTypeIdentifier) { $queryTypes[$this->buildQueryTypeName($queryTypeIdentifier)] = $queryTypeIdentifier; } @@ -40,9 +45,10 @@ public function process(ContainerBuilder $container) } /** - * Builds a human readable name out of a query type identifier + * Builds a human readable name out of a query type identifier. * * @param $queryTypeIdentifier + * * @return string */ private function buildQueryTypeName($queryTypeIdentifier) @@ -51,4 +57,4 @@ private function buildQueryTypeName($queryTypeIdentifier) str_replace('_', ' ', $this->nameConverter->normalize($queryTypeIdentifier)) ); } -} \ No newline at end of file +} diff --git a/src/Symfony/EzSystemsEzPlatformQueryFieldTypeBundle.php b/src/Symfony/EzSystemsEzPlatformQueryFieldTypeBundle.php index ba12826..2ea3c32 100644 --- a/src/Symfony/EzSystemsEzPlatformQueryFieldTypeBundle.php +++ b/src/Symfony/EzSystemsEzPlatformQueryFieldTypeBundle.php @@ -1,5 +1,9 @@