Skip to content

Commit

Permalink
EZP-31108: [CS] Enabled ezsystems/ezplatform-code-style package (#83)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
alongosz authored Nov 21, 2019
1 parent af5d031 commit b70967c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 41 deletions.
50 changes: 18 additions & 32 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
<?php

$header = <<<'EOF'
@copyright Copyright (C) eZ Systems AS. All rights reserved.
@license For full copyright and license information view LICENSE file distributed with this source code.
EOF;
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

return PhpCsFixer\Config::create()
->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;
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions src/bundle/eZ/RichText/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Renderer implements RendererInterface
protected $templateEngine;

/**
* @var null|\Psr\Log\LoggerInterface
* @var \Psr\Log\LoggerInterface|null
*/
protected $logger;

Expand All @@ -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
*/
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib/eZ/RichText/Converter/Render/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class Embed extends Render implements Converter
{
/**
* @var null|\Psr\Log\LoggerInterface
* @var \Psr\Log\LoggerInterface|null
*/
protected $logger;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/eZ/RichText/ConverterDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib/eZ/RichText/XmlBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit b70967c

Please sign in to comment.