Skip to content

Commit

Permalink
EZP-31108: Use code style rules from ezplatform-code-style (#108)
Browse files Browse the repository at this point in the history
* EZP-31108: Imported code style rules from ezplatform-code-style
* EZP-31108: Updated code style
  • Loading branch information
adamwojs authored Nov 27, 2019
1 parent 7c55fed commit 22f1a12
Show file tree
Hide file tree
Showing 99 changed files with 124 additions and 243 deletions.
44 changes: 11 additions & 33 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
<?php

// PHP-CS-Fixer 2.x syntax
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'concat_space' => ['spacing' => 'one'],
'array_syntax' => false,
'simplified_null_return' => false,
'phpdoc_align' => false,
'phpdoc_separation' => false,
'phpdoc_to_comment' => false,
'cast_spaces' => false,
'blank_line_after_opening_tag' => false,
'single_blank_line_before_namespace' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_no_alias_tag' => false,
'space_after_semicolon' => false,
'yoda_style' => false,
'no_break_comment' => false,
])
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude([
'spec',
'docs',
'features',
'vendor',
])
->files()->name('*.php')
)
;
return EzSystems\EzPlatformCodeStyle\PhpCsFixer\EzPlatformInternalConfigFactory::build()->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude([
'spec',
'docs',
'features',
'vendor',
])
->files()->name('*.php')
);
5 changes: 5 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
require_once __DIR__ . '/vendor/autoload.php';
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"phpunit/phpunit": "^5.7.27 || ^6.5.13",
"matthiasnoback/symfony-dependency-injection-test": "^1.2.0 || ^2.3.1",
"phpspec/phpspec": "^3.4.3 || ^4.3.2",
"friendsofphp/php-cs-fixer": "~2.7.5",
"ezsystems/ezplatform-code-style": "^0.1.0",
"friendsofphp/php-cs-fixer": "^2.16.0",
"memio/spec-gen": "^0.6.2 || ^0.8.5"
},
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions src/ContextProvider/RoleIdentify.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function (Repository $repository) use ($user) {
}
);

$roleIds = array();
$limitationValues = array();
$roleIds = [];
$limitationValues = [];
/** @var \eZ\Publish\API\Repository\Values\User\UserRoleAssignment $roleAssignment */
foreach ($roleAssignments as $roleAssignment) {
$roleId = $roleAssignment->getRole()->id;
Expand All @@ -52,7 +52,7 @@ function (Repository $repository) use ($user) {
// If a limitation is present, store the limitation values by roleId
if ($limitation !== null) {
$limitationValuesKey = sprintf('%s-%s', $roleId, $limitation->getIdentifier());
$limitationValues[$limitationValuesKey] = array();
$limitationValues[$limitationValuesKey] = [];
foreach ($limitation->limitationValues as $value) {
$limitationValues[$limitationValuesKey][] = $value;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Controller/InvalidateTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ class InvalidateTokenController

/**
* TokenController constructor.
*
* @param ConfigResolverInterface $configResolver
* @param int $ttl
* @param TagHandler $tagHandler
*
* @internal param string $invalidatetoken
*/
public function __construct(ConfigResolverInterface $configResolver, $ttl, TagHandler $tagHandler)
Expand All @@ -47,6 +49,7 @@ public function __construct(ConfigResolverInterface $configResolver, $ttl, TagHa
* Request::isFromTrustedProxy is private in Symfony <3.1, so this is a re-implementation of it.
*
* @param Request $request
*
* @return bool
*/
private function isFromTrustedProxy(Request $request)
Expand All @@ -56,6 +59,7 @@ private function isFromTrustedProxy(Request $request)

/**
* @param Request $request
*
* @return Response
*/
public function tokenAction(Request $request)
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/Compiler/DriverPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
2 changes: 0 additions & 2 deletions src/DependencyInjection/Compiler/HttpCachePass.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the HttpCachePass class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Compiler/KernelPass.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
2 changes: 2 additions & 0 deletions src/DependencyInjection/Compiler/ResponseTaggersPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\DependencyInjection\Compiler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down Expand Up @@ -30,7 +31,7 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder)
->children()
->arrayNode('purge_servers')
->info('Servers to use for Http PURGE (will NOT be used if ezpublish.http_cache.purge_type is "local").')
->example(array('http://localhost/', 'http://another.server/'))
->example(['http://localhost/', 'http://another.server/'])
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/EzPlatformHttpCacheExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
5 changes: 3 additions & 2 deletions src/EventListener/ConditionallyRemoveVaryHeaderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ConditionallyRemoveVaryHeaderListener implements EventSubscriberInterface

/**
* ConditionallyRemoveVaryHeaderListener constructor.
*
* @param array $routes List of routes which will not have default vary headers
* @param array $userIdentifierHeaders
*/
Expand Down Expand Up @@ -69,8 +70,8 @@ public function onKernelResponse(FilterResponseEvent $event)
*/
public static function getSubscribedEvents()
{
return array(
return [
KernelEvents::RESPONSE => 'onKernelResponse',
);
];
}
}
2 changes: 2 additions & 0 deletions src/EventSubscriber/HttpCacheResponseSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\EventSubscriber;
Expand Down
1 change: 1 addition & 0 deletions src/EventSubscriber/RestKernelViewSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
1 change: 1 addition & 0 deletions src/EventSubscriber/UserContextSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
1 change: 1 addition & 0 deletions src/EventSubscriber/XLocationIdResponseSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
10 changes: 4 additions & 6 deletions src/Proxy/TagAwareStore.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the TagAwareStore class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down Expand Up @@ -97,7 +95,7 @@ public function write(Request $request, Response $response)
*/
private function saveTag($tag, $digest)
{
$path = $this->getTagPath($tag) . DIRECTORY_SEPARATOR . $digest;
$path = $this->getTagPath($tag) . \DIRECTORY_SEPARATOR . $digest;
if (!is_dir(dirname($path)) && false === @mkdir(dirname($path), 0777, true) && !is_dir(dirname($path))) {
return false;
}
Expand Down Expand Up @@ -152,7 +150,7 @@ function ($id) {return 'location-' . $id;},
explode('|', substr($locationId, 1, -1))
);
} else {
$tags = array('location-' . $locationId);
$tags = ['location-' . $locationId];
}

if (empty($tags)) {
Expand Down Expand Up @@ -211,12 +209,12 @@ private function purgeByCacheTag($tag)
*/
public function getTagPath($tag = null)
{
$path = $this->root . DIRECTORY_SEPARATOR . static::TAG_CACHE_DIR;
$path = $this->root . \DIRECTORY_SEPARATOR . static::TAG_CACHE_DIR;
if ($tag) {
// Flip the tag so we put id first so it gets sliced into folders.
// (otherwise we would easily reach inode limits on file system)
$tag = strrev($tag);
$path .= DIRECTORY_SEPARATOR . substr($tag, 0, 2) . DIRECTORY_SEPARATOR . substr($tag, 2, 2) . DIRECTORY_SEPARATOR . substr($tag, 4);
$path .= \DIRECTORY_SEPARATOR . substr($tag, 0, 2) . \DIRECTORY_SEPARATOR . substr($tag, 2, 2) . \DIRECTORY_SEPARATOR . substr($tag, 4);
}

return $path;
Expand Down
2 changes: 0 additions & 2 deletions src/Proxy/UserContextSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the UserContextSubscriber class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/ProxyClient/Varnish.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the Varnish class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand All @@ -22,6 +20,6 @@ class Varnish extends FOSVarnish
*/
protected function getAllowedSchemes()
{
return array('http', 'https');
return ['http', 'https'];
}
}
2 changes: 0 additions & 2 deletions src/PurgeClient/LocalPurgeClient.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the LocalPurgeClient class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/PurgeClient/RepositoryPrefixDecorator.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the RepositoryPrefixDecorator class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/PurgeClient/VarnishProxyClientFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the VarnishProxyClientFactory class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down Expand Up @@ -53,7 +51,7 @@ public function __construct(
*/
public function buildProxyClient(array $servers, $baseUrl)
{
$allServers = array();
$allServers = [];
foreach ($servers as $server) {
if (!$this->dynamicSettingParser->isDynamicSetting($server)) {
$allServers[] = $server;
Expand Down
2 changes: 0 additions & 2 deletions src/RequestAwarePurger.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

/**
* File containing the RequestAwarePurger interface.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand All @@ -21,6 +22,7 @@ class ConfigurableResponseCacheConfigurator implements ResponseCacheConfigurator

/**
* True if TTL cache is enabled, false if it is not.
*
* @var bool
*/
private $enableTtlCache;
Expand Down
1 change: 1 addition & 0 deletions src/ResponseConfigurator/ResponseCacheConfigurator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
1 change: 1 addition & 0 deletions src/ResponseTagger/Delegator/ContentValueViewTagger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
4 changes: 4 additions & 0 deletions src/ResponseTagger/Delegator/DispatcherTagger.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\ResponseTagger\Delegator;

use EzSystems\PlatformHttpCacheBundle\ResponseTagger\ResponseTagger;
Expand Down
1 change: 1 addition & 0 deletions src/ResponseTagger/Delegator/LocationValueViewTagger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
1 change: 1 addition & 0 deletions src/ResponseTagger/ResponseTagger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
Expand Down
4 changes: 4 additions & 0 deletions src/ResponseTagger/Value/AbstractValueTagger.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value;

use EzSystems\PlatformHttpCacheBundle\ResponseTagger\ResponseTagger;
Expand Down
4 changes: 4 additions & 0 deletions src/ResponseTagger/Value/ContentInfoTagger.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\PlatformHttpCacheBundle\ResponseTagger\Value;

use eZ\Publish\API\Repository\Values\Content\ContentInfo;
Expand Down
Loading

0 comments on commit 22f1a12

Please sign in to comment.