From b70967c628d04133b5e53017b5e5c54ee7d7f4f3 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Thu, 21 Nov 2019 12:34:35 +0100 Subject: [PATCH] EZP-31108: [CS] Enabled ezsystems/ezplatform-code-style package (#83) * Installed and configured ezsystems/ezplatform-code-style package. * Applied `phpdoc_types_order` PHP-CS-Fixer rule. * Re-enabled `declare_strict_types` PHP-CS-Fixer rule. --- .php_cs | 50 +++++++------------ composer.json | 3 +- src/bundle/eZ/RichText/Renderer.php | 10 ++-- .../eZ/RichText/Converter/Render/Embed.php | 2 +- src/lib/eZ/RichText/ConverterDispatcher.php | 2 +- src/lib/eZ/RichText/XmlBase.php | 2 +- 6 files changed, 28 insertions(+), 41 deletions(-) diff --git a/.php_cs b/.php_cs index 41a10476..4e54ea5e 100644 --- a/.php_cs +++ b/.php_cs @@ -1,39 +1,25 @@ setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - 'concat_space' => ['spacing' => 'one'], - 'array_syntax' => ['syntax' => 'short'], - 'simplified_null_return' => false, - 'phpdoc_align' => false, - 'phpdoc_to_comment' => false, - 'cast_spaces' => false, - 'blank_line_after_opening_tag' => false, - 'single_blank_line_before_namespace' => true, - 'space_after_semicolon' => false, - 'header_comment' => [ - 'commentType' => 'PHPDoc', - 'header' => $header, - 'location' => 'after_open', - 'separate' => 'top', - ], - 'yoda_style' => false, - 'no_break_comment' => false, - 'declare_strict_types' => true, - 'native_function_invocation' => false, - 'phpdoc_types_order' => false, - ]) - ->setRiskyAllowed(true) +$config = EzSystems\EzPlatformCodeStyle\PhpCsFixer\EzPlatformInternalConfigFactory::build(); +$config + ->setRules( + array_merge( + $config->getRules(), + [ + 'declare_strict_types' => true, + ] + ) + ) ->setFinder( PhpCsFixer\Finder::create() ->in([__DIR__ . '/src', __DIR__ . '/tests']) ->files()->name('*.php') - ) -; + ); + +return $config; diff --git a/composer.json b/composer.json index d74f229a..95d34888 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "require-dev": { "phpunit/phpunit": "^7.0", "matthiasnoback/symfony-dependency-injection-test": "~3.0", - "friendsofphp/php-cs-fixer": "~2.15.0" + "friendsofphp/php-cs-fixer": "^2.16", + "ezsystems/ezplatform-code-style": "^0.1" }, "autoload": { "psr-4": { diff --git a/src/bundle/eZ/RichText/Renderer.php b/src/bundle/eZ/RichText/Renderer.php index 7e462d41..b1711d77 100644 --- a/src/bundle/eZ/RichText/Renderer.php +++ b/src/bundle/eZ/RichText/Renderer.php @@ -66,7 +66,7 @@ class Renderer implements RendererInterface protected $templateEngine; /** - * @var null|\Psr\Log\LoggerInterface + * @var \Psr\Log\LoggerInterface|null */ protected $logger; @@ -88,7 +88,7 @@ class Renderer implements RendererInterface * @param string $tagConfigurationNamespace * @param string $styleConfigurationNamespace * @param string $embedConfigurationNamespace - * @param null|\Psr\Log\LoggerInterface $logger + * @param \Psr\Log\LoggerInterface|null $logger * @param array $customTagsConfiguration * @param array $customStylesConfiguration */ @@ -329,7 +329,7 @@ protected function render($templateReference, array $parameters) * @param string $identifier * @param bool $isInline * - * @return null|string + * @return string|null */ protected function getStyleTemplateName($identifier, $isInline) { @@ -366,7 +366,7 @@ protected function getStyleTemplateName($identifier, $isInline) * @param string $identifier * @param bool $isInline * - * @return null|string + * @return string|null */ protected function getTagTemplateName($identifier, $isInline) { @@ -414,7 +414,7 @@ protected function getTagTemplateName($identifier, $isInline) * @param $isInline * @param $isDenied * - * @return null|string + * @return string|null */ protected function getEmbedTemplateName($resourceType, $isInline, $isDenied) { diff --git a/src/lib/eZ/RichText/Converter/Render/Embed.php b/src/lib/eZ/RichText/Converter/Render/Embed.php index 6c29e1e8..625e2fae 100644 --- a/src/lib/eZ/RichText/Converter/Render/Embed.php +++ b/src/lib/eZ/RichText/Converter/Render/Embed.php @@ -23,7 +23,7 @@ class Embed extends Render implements Converter { /** - * @var null|\Psr\Log\LoggerInterface + * @var \Psr\Log\LoggerInterface|null */ protected $logger; diff --git a/src/lib/eZ/RichText/ConverterDispatcher.php b/src/lib/eZ/RichText/ConverterDispatcher.php index ced58baf..0bdda385 100644 --- a/src/lib/eZ/RichText/ConverterDispatcher.php +++ b/src/lib/eZ/RichText/ConverterDispatcher.php @@ -37,7 +37,7 @@ public function __construct($converterMap) * Adds converter mapping. * * @param string $namespace - * @param null|\EzSystems\EzPlatformRichText\eZ\RichText\Converter $converter + * @param \EzSystems\EzPlatformRichText\eZ\RichText\Converter|null $converter */ public function addConverter($namespace, Converter $converter = null) { diff --git a/src/lib/eZ/RichText/XmlBase.php b/src/lib/eZ/RichText/XmlBase.php index 0a5f2409..4efaa8f2 100644 --- a/src/lib/eZ/RichText/XmlBase.php +++ b/src/lib/eZ/RichText/XmlBase.php @@ -21,7 +21,7 @@ abstract class XmlBase * When recording errors holds previous setting for libxml user error handling, * null otherwise. * - * @var null|bool + * @var bool|null */ protected $useInternalErrors;