From 3a20928df27fcd8d28feb7bca9adfaa2092edf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Sat, 25 Mar 2017 10:03:40 +0100 Subject: [PATCH] PHP CS Fixer 2.0 --- .php_cs | 41 +++++++++++-------- Core/FieldType/ContentTypeList/Type.php | 41 ++++++++++--------- .../NetgenContentTypeListExtension.php | 8 ++-- .../ContentTypeListConverterTest.php | 2 +- 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/.php_cs b/.php_cs index a25cf15..d010ce7 100644 --- a/.php_cs +++ b/.php_cs @@ -1,24 +1,29 @@ setUsingLinter(false) - ->setUsingCache(true) - ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - ->fixers([ - 'concat_with_spaces', - '-concat_without_spaces', - '-empty_return', - '-phpdoc_params', - '-phpdoc_separation', - '-phpdoc_to_comment', - '-spaces_cast', - '-blankline_after_open_tag', +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + '@Symfony:risky' => true, + 'array_syntax' => array('syntax' => 'long'), + 'combine_consecutive_unsets' => true, + 'concat_space' => ['spacing' => 'one'], + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_align' => false, + 'phpdoc_order' => true, + 'phpdoc_no_alias_tag' => false, + 'psr4' => true, + 'semicolon_after_instruction' => true, + 'strict_comparison' => true, + 'strict_param' => true, ]) - ->finder( - Symfony\CS\Finder\DefaultFinder::create() + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude(['vendor']) ->in(__DIR__) - ->exclude([ - 'vendor', - ]) ) ; diff --git a/Core/FieldType/ContentTypeList/Type.php b/Core/FieldType/ContentTypeList/Type.php index 767e3ff..9dce30d 100644 --- a/Core/FieldType/ContentTypeList/Type.php +++ b/Core/FieldType/ContentTypeList/Type.php @@ -2,10 +2,10 @@ namespace Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList; +use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType; use eZ\Publish\Core\FieldType\FieldType; use eZ\Publish\Core\FieldType\Value as BaseValue; use eZ\Publish\SPI\FieldType\Value as SPIValue; -use eZ\Publish\Core\Base\Exceptions\InvalidArgumentType; class Type extends FieldType { @@ -39,7 +39,7 @@ public function getFieldTypeIdentifier() */ public function getName(SPIValue $value) { - return (string)$value; + return (string) $value; } /** @@ -104,6 +104,22 @@ public function toHash(SPIValue $value) return $value->identifiers; } + /** + * Returns if the given $value is considered empty by the field type. + * + * Default implementation, which performs a "==" check with the value + * returned by {@link getEmptyValue()}. Overwrite in the specific field + * type, if necessary. + * + * @param \eZ\Publish\SPI\FieldType\Value|\Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList\Value $value + * + * @return bool + */ + public function isEmptyValue(SPIValue $value) + { + return $value === null || $value->identifiers === $this->getEmptyValue()->identifiers; + } + /** * Inspects given $inputValue and potentially converts it into a dedicated value object. * @@ -114,7 +130,7 @@ public function toHash(SPIValue $value) * * @param mixed $inputValue * - * @return mixed The potentially converted input value. + * @return mixed the potentially converted input value */ protected function createValueFromInput($inputValue) { @@ -140,9 +156,10 @@ protected function createValueFromInput($inputValue) * * This is an operation method for {@see acceptValue()}. * - * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the value does not match the expected structure. * * @param \eZ\Publish\Core\FieldType\Value|\Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList\Value $value + * + * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the value does not match the expected structure */ protected function checkValueStructure(BaseValue $value) { @@ -185,20 +202,4 @@ protected function getSortInfo(BaseValue $value) { return false; } - - /** - * Returns if the given $value is considered empty by the field type. - * - * Default implementation, which performs a "==" check with the value - * returned by {@link getEmptyValue()}. Overwrite in the specific field - * type, if necessary. - * - * @param \eZ\Publish\SPI\FieldType\Value|\Netgen\Bundle\ContentTypeListBundle\Core\FieldType\ContentTypeList\Value $value - * - * @return bool - */ - public function isEmptyValue(SPIValue $value) - { - return $value === null || $value->identifiers == $this->getEmptyValue()->identifiers; - } } diff --git a/DependencyInjection/NetgenContentTypeListExtension.php b/DependencyInjection/NetgenContentTypeListExtension.php index 9a7762e..58d525e 100644 --- a/DependencyInjection/NetgenContentTypeListExtension.php +++ b/DependencyInjection/NetgenContentTypeListExtension.php @@ -2,12 +2,12 @@ namespace Netgen\Bundle\ContentTypeListBundle\DependencyInjection; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\Config\Resource\FileResource; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\Yaml\Yaml; class NetgenContentTypeListExtension extends Extension implements PrependExtensionInterface diff --git a/Tests/Core/Persistence/Legacy/Content/FieldValue/Converter/ContentTypeListConverterTest.php b/Tests/Core/Persistence/Legacy/Content/FieldValue/Converter/ContentTypeListConverterTest.php index b0d11d8..23bd26d 100644 --- a/Tests/Core/Persistence/Legacy/Content/FieldValue/Converter/ContentTypeListConverterTest.php +++ b/Tests/Core/Persistence/Legacy/Content/FieldValue/Converter/ContentTypeListConverterTest.php @@ -2,12 +2,12 @@ namespace Netgen\Bundle\ContentTypeListBundle\Tests\Core\Persistence\Legacy\Content\FieldValue\Converter; +use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter; use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition; use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue; use eZ\Publish\SPI\Persistence\Content\FieldValue; use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition; use Netgen\Bundle\ContentTypeListBundle\Core\Persistence\Legacy\Content\FieldValue\Converter\ContentTypeListConverter; -use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter; class ContentTypeListConverterTest extends \PHPUnit_Framework_TestCase {