diff --git a/.php_cs b/.php_cs index 74cfb3d9..a021ec38 100644 --- a/.php_cs +++ b/.php_cs @@ -1,35 +1,13 @@ 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') +); diff --git a/bootstrap.php b/bootstrap.php index 539f2dff..92dc3a95 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,2 +1,7 @@ getRole()->id; @@ -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; } diff --git a/src/Controller/InvalidateTokenController.php b/src/Controller/InvalidateTokenController.php index 04eb347f..90edb531 100644 --- a/src/Controller/InvalidateTokenController.php +++ b/src/Controller/InvalidateTokenController.php @@ -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) @@ -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) @@ -56,6 +59,7 @@ private function isFromTrustedProxy(Request $request) /** * @param Request $request + * * @return Response */ public function tokenAction(Request $request) diff --git a/src/DependencyInjection/Compiler/DriverPass.php b/src/DependencyInjection/Compiler/DriverPass.php index b2861544..f44739d8 100644 --- a/src/DependencyInjection/Compiler/DriverPass.php +++ b/src/DependencyInjection/Compiler/DriverPass.php @@ -1,5 +1,9 @@ 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() diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 1f31bfe4..c6c2394e 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -1,4 +1,5 @@ 'onKernelResponse', - ); + ]; } } diff --git a/src/EventSubscriber/HttpCacheResponseSubscriber.php b/src/EventSubscriber/HttpCacheResponseSubscriber.php index 15b5a4b0..99679f45 100644 --- a/src/EventSubscriber/HttpCacheResponseSubscriber.php +++ b/src/EventSubscriber/HttpCacheResponseSubscriber.php @@ -1,5 +1,7 @@ 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; } @@ -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)) { @@ -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; diff --git a/src/Proxy/UserContextSubscriber.php b/src/Proxy/UserContextSubscriber.php index dee9bacc..11728fb6 100644 --- a/src/Proxy/UserContextSubscriber.php +++ b/src/Proxy/UserContextSubscriber.php @@ -1,8 +1,6 @@ dynamicSettingParser->isDynamicSetting($server)) { $allServers[] = $server; diff --git a/src/RequestAwarePurger.php b/src/RequestAwarePurger.php index d661b404..d0c7ba85 100644 --- a/src/RequestAwarePurger.php +++ b/src/RequestAwarePurger.php @@ -1,8 +1,6 @@ repositoryMock = $this ->getMockBuilder(Repository::class) ->disableOriginalConstructor() - ->setMethods(array('getRoleService', 'getCurrentUser', 'getPermissionResolver')) + ->setMethods(['getRoleService', 'getCurrentUser', 'getPermissionResolver']) ->getMock(); $this->roleServiceMock = $this->createMock(RoleService::class); @@ -71,46 +71,46 @@ public function testSetIdentity() $roleId2 = 456; $roleId3 = 789; $limitationForRole2 = $this->generateLimitationMock( - array( - 'limitationValues' => array('/1/2', '/1/2/43'), - ) + [ + 'limitationValues' => ['/1/2', '/1/2/43'], + ] ); $limitationForRole3 = $this->generateLimitationMock( - array( - 'limitationValues' => array('foo', 'bar'), - ) + [ + 'limitationValues' => ['foo', 'bar'], + ] ); - $returnedRoleAssignments = array( + $returnedRoleAssignments = [ $this->generateRoleAssignmentMock( - array( + [ 'role' => $this->generateRoleMock( - array( + [ 'id' => $roleId1, - ) + ] ), - ) + ] ), $this->generateRoleAssignmentMock( - array( + [ 'role' => $this->generateRoleMock( - array( + [ 'id' => $roleId2, - ) + ] ), 'limitation' => $limitationForRole2, - ) + ] ), $this->generateRoleAssignmentMock( - array( + [ 'role' => $this->generateRoleMock( - array( + [ 'id' => $roleId3, - ) + ] ), 'limitation' => $limitationForRole3, - ) + ] ), - ); + ]; $this->roleServiceMock ->expects($this->once()) @@ -118,45 +118,45 @@ public function testSetIdentity() ->with($user, true) ->will($this->returnValue($returnedRoleAssignments)); - $this->assertSame(array(), $userContext->getParameters()); + $this->assertSame([], $userContext->getParameters()); $contextProvider = new RoleIdentify($this->repositoryMock); $contextProvider->updateUserContext($userContext); $userContextParams = $userContext->getParameters(); $this->assertArrayHasKey('roleIdList', $userContextParams); - $this->assertSame(array($roleId1, $roleId2, $roleId3), $userContextParams['roleIdList']); + $this->assertSame([$roleId1, $roleId2, $roleId3], $userContextParams['roleIdList']); $this->assertArrayHasKey('roleLimitationList', $userContextParams); $limitationIdentifierForRole2 = get_class($limitationForRole2); $limitationIdentifierForRole3 = get_class($limitationForRole3); $this->assertSame( - array( - "$roleId2-$limitationIdentifierForRole2" => array('/1/2', '/1/2/43'), - "$roleId3-$limitationIdentifierForRole3" => array('foo', 'bar'), - ), + [ + "$roleId2-$limitationIdentifierForRole2" => ['/1/2', '/1/2/43'], + "$roleId3-$limitationIdentifierForRole3" => ['foo', 'bar'], + ], $userContextParams['roleLimitationList'] ); } - private function generateRoleAssignmentMock(array $properties = array()) + private function generateRoleAssignmentMock(array $properties = []) { return $this ->getMockBuilder(UserRoleAssignment::class) - ->setConstructorArgs(array($properties)) + ->setConstructorArgs([$properties]) ->getMockForAbstractClass(); } - private function generateRoleMock(array $properties = array()) + private function generateRoleMock(array $properties = []) { return $this ->getMockBuilder(Role::class) - ->setConstructorArgs(array($properties)) + ->setConstructorArgs([$properties]) ->getMockForAbstractClass(); } - private function generateLimitationMock(array $properties = array()) + private function generateLimitationMock(array $properties = []) { $limitationMock = $this ->getMockBuilder(RoleLimitation::class) - ->setConstructorArgs(array($properties)) + ->setConstructorArgs([$properties]) ->getMockForAbstractClass(); $limitationMock ->expects($this->any()) diff --git a/tests/Proxy/TagAwareStoreTest.php b/tests/Proxy/TagAwareStoreTest.php index 98864433..02316290 100644 --- a/tests/Proxy/TagAwareStoreTest.php +++ b/tests/Proxy/TagAwareStoreTest.php @@ -1,8 +1,6 @@ store->getTagPath('location-123') . DIRECTORY_SEPARATOR . 'en' . sha1('someContent'); - $this->assertStringStartsWith(__DIR__ . DIRECTORY_SEPARATOR . 'ez' . DIRECTORY_SEPARATOR . '32' . DIRECTORY_SEPARATOR . '1-' . DIRECTORY_SEPARATOR . 'noitacol', $path); + $path = $this->store->getTagPath('location-123') . \DIRECTORY_SEPARATOR . 'en' . sha1('someContent'); + $this->assertStringStartsWith(__DIR__ . \DIRECTORY_SEPARATOR . 'ez' . \DIRECTORY_SEPARATOR . '32' . \DIRECTORY_SEPARATOR . '1-' . \DIRECTORY_SEPARATOR . 'noitacol', $path); } public function testGetStalePath() @@ -43,13 +41,13 @@ public function testGetStalePath() $this->markTestIncomplete('@todo Stale handling removed, needs adjustments once it is re added in new form'); // Generate the lock file to force using the stale cache dir $locationId = 123; - $prefix = TagAwareStore::TAG_CACHE_DIR . DIRECTORY_SEPARATOR . $locationId; - $prefixStale = TagAwareStore::TAG_CACHE_DIR . DIRECTORY_SEPARATOR . $locationId; + $prefix = TagAwareStore::TAG_CACHE_DIR . \DIRECTORY_SEPARATOR . $locationId; + $prefixStale = TagAwareStore::TAG_CACHE_DIR . \DIRECTORY_SEPARATOR . $locationId; $lockFile = $this->store->getLocationCacheLockName($locationId); file_put_contents($lockFile, getmypid()); - $path = $this->store->getPath($prefix . DIRECTORY_SEPARATOR . 'en' . sha1('someContent')); - $this->assertStringStartsWith(__DIR__ . DIRECTORY_SEPARATOR . $prefixStale, $path); + $path = $this->store->getPath($prefix . \DIRECTORY_SEPARATOR . 'en' . sha1('someContent')); + $this->assertStringStartsWith(__DIR__ . \DIRECTORY_SEPARATOR . $prefixStale, $path); @unlink($lockFile); } @@ -115,7 +113,7 @@ public function testPurgeByRequestMultipleLocations() $this->markTestIncomplete('@todo needs adjustments for new impl on top of tags'); $fs = $this->getFilesystemMock(); $this->store->setFilesystem($fs); - $locationIds = array(123, 456, 789); + $locationIds = [123, 456, 789]; $i = 0; foreach ($locationIds as $locationId) { $locationCacheDir = $this->store->getTagPath('location-' . $locationId); diff --git a/tests/PurgeClient/LocalPurgeClientTest.php b/tests/PurgeClient/LocalPurgeClientTest.php index 81205ed9..e52df555 100644 --- a/tests/PurgeClient/LocalPurgeClientTest.php +++ b/tests/PurgeClient/LocalPurgeClientTest.php @@ -1,8 +1,6 @@ headers->set('key', 'location-123 location-456 location-789'); diff --git a/tests/PurgeClient/RepositoryPrefixDecoratorTest.php b/tests/PurgeClient/RepositoryPrefixDecoratorTest.php index 348277c3..76f01485 100644 --- a/tests/PurgeClient/RepositoryPrefixDecoratorTest.php +++ b/tests/PurgeClient/RepositoryPrefixDecoratorTest.php @@ -1,8 +1,6 @@ cacheManager = $this->getMockBuilder(CacheManager::class) ->setConstructorArgs( - array( + [ $this->createMock(ProxyClientInterface::class), $this->createMock( UrlGeneratorInterface::class ), - ) + ] ) ->getMock(); $this->configResolver = $this->createMock(ConfigResolverInterface::class); @@ -58,7 +56,7 @@ public function testPurgeNoLocationIds() ->expects($this->never()) ->method('invalidate'); - $this->purgeClient->purge(array()); + $this->purgeClient->purge([]); } public function testPurgeOneLocationId() @@ -190,11 +188,11 @@ public function testPurgeWithAuthHeaderAndKey(array $locationIds = []) public function purgeTestProvider() { - return array( - array(array(123)), - array(array(123, 456)), - array(array(123, 456, 789)), - ); + return [ + [[123]], + [[123, 456]], + [[123, 456, 789]], + ]; } public function testPurgeAll() diff --git a/tests/SignalSlot/AbstractContentSlotTest.php b/tests/SignalSlot/AbstractContentSlotTest.php index d4091e31..9ae2af47 100644 --- a/tests/SignalSlot/AbstractContentSlotTest.php +++ b/tests/SignalSlot/AbstractContentSlotTest.php @@ -1,8 +1,6 @@