diff --git a/.php_cs b/.php_cs index d7b99bdd..c87f050d 100644 --- a/.php_cs +++ b/.php_cs @@ -4,7 +4,6 @@ return PhpCsFixer\Config::create() '@Symfony' => true, '@Symfony:risky' => true, 'concat_space' => ['spacing' => 'one'], - 'array_syntax' => false, 'simplified_null_return' => false, 'phpdoc_align' => false, 'phpdoc_separation' => false, @@ -17,6 +16,11 @@ return PhpCsFixer\Config::create() 'space_after_semicolon' => false, 'yoda_style' => false, 'no_break_comment' => false, + + // 2019 style updates with cs-fixer 2.14, all above are in sync with kernel + '@PHPUnit57Migration:risky' => true, + 'array_syntax' => ['syntax' => 'short'], + 'static_lambda' => true, ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/bundle/Cache/LegacyCachePurger.php b/bundle/Cache/LegacyCachePurger.php index 806b5d5e..ff081f46 100644 --- a/bundle/Cache/LegacyCachePurger.php +++ b/bundle/Cache/LegacyCachePurger.php @@ -62,16 +62,16 @@ private function getLegacyKernel() public function clear($cacheDir) { $this->getLegacyKernel()->runCallback( - function () { + static function () { $helper = new eZCacheHelper( $cli = eZCLI::instance(), $script = eZScript::instance( - array( + [ 'description' => 'eZ Publish Cache Handler', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true, - ) + ] ) ); $helper->clearItems(eZCache::fetchByTag('template,ini,i18n'), 'Legacy file cache (Template, ini and i18n)'); diff --git a/bundle/Cache/LegacySwitchableHttpCachePurger.php b/bundle/Cache/LegacySwitchableHttpCachePurger.php index d05bb2c0..5041b0a0 100644 --- a/bundle/Cache/LegacySwitchableHttpCachePurger.php +++ b/bundle/Cache/LegacySwitchableHttpCachePurger.php @@ -44,7 +44,7 @@ public function purgeAll() $this->gatewayCachePurger->purgeAll(); } - public function purgeForContent($contentId, $locationIds = array()) + public function purgeForContent($contentId, $locationIds = []) { if ($this->isSwitchedOff()) { return; diff --git a/bundle/Cache/PersistenceCachePurger.php b/bundle/Cache/PersistenceCachePurger.php index 859bfb11..46fe0cf2 100644 --- a/bundle/Cache/PersistenceCachePurger.php +++ b/bundle/Cache/PersistenceCachePurger.php @@ -116,12 +116,12 @@ public function content($locationIds = null, array $contentIds = null) if ($locationIds === null) { $this->cache->clear('content'); goto relatedCache; - } elseif (!is_array($locationIds)) { - $locationIds = array($locationIds); + } elseif (!\is_array($locationIds)) { + $locationIds = [$locationIds]; } if ($contentIds === null) { - $contentIds = array(); + $contentIds = []; } foreach ($locationIds as $id) { diff --git a/bundle/Cache/SwitchableHttpCachePurger.php b/bundle/Cache/SwitchableHttpCachePurger.php index e438a24b..47ecffc9 100644 --- a/bundle/Cache/SwitchableHttpCachePurger.php +++ b/bundle/Cache/SwitchableHttpCachePurger.php @@ -52,7 +52,7 @@ public function purgeAll() * @param int $contentId * @param array $locationIds */ - public function purgeForContent($contentId, $locationIds = array()) + public function purgeForContent($contentId, $locationIds = []) { if ($this->isSwitchedOff() || !method_exists($this->purgeClient, 'purgeForContent')) { return; diff --git a/bundle/Collector/TemplateDebugInfo.php b/bundle/Collector/TemplateDebugInfo.php index ecf1e8c0..79f902e4 100644 --- a/bundle/Collector/TemplateDebugInfo.php +++ b/bundle/Collector/TemplateDebugInfo.php @@ -23,7 +23,7 @@ class TemplateDebugInfo */ public static function getLegacyTemplatesList(\Closure $legacyKernel) { - $templateList = array('compact' => array(), 'full' => array()); + $templateList = ['compact' => [], 'full' => []]; // Only retrieve legacy templates list if the kernel has been booted at least once. if (!LegacyKernel::hasInstance()) { return $templateList; @@ -31,7 +31,7 @@ public static function getLegacyTemplatesList(\Closure $legacyKernel) try { $templateStats = $legacyKernel()->runCallback( - function () { + static function () { if (eZTemplate::isTemplatesUsageStatisticsEnabled()) { return eZTemplate::templatesUsageStatistics(); } else { @@ -53,7 +53,7 @@ function () { } catch (RuntimeException $e) { // Ignore the exception thrown by legacy kernel as this would break debug toolbar (and thus debug info display). // Furthermore, some legacy kernel handlers don't support runCallback (e.g. ezpKernelTreeMenu) - $templateStats = array(); + $templateStats = []; } foreach ($templateStats as $tplInfo) { @@ -61,10 +61,10 @@ function () { $actualTpl = $tplInfo['actual-template-name']; $fullPath = $tplInfo['template-filename']; - $templateList['full'][$actualTpl] = array( + $templateList['full'][$actualTpl] = [ 'loaded' => $requestedTpl, 'fullPath' => $fullPath, - ); + ]; if (!isset($templateList['compact'][$actualTpl])) { $templateList['compact'][$actualTpl] = 1; } else { diff --git a/bundle/Command/LegacyBundleInstallCommand.php b/bundle/Command/LegacyBundleInstallCommand.php index 20511392..a32eaf60 100644 --- a/bundle/Command/LegacyBundleInstallCommand.php +++ b/bundle/Command/LegacyBundleInstallCommand.php @@ -36,11 +36,11 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - $options = array( + $options = [ 'copy' => (bool)$input->getOption('copy'), 'relative' => (bool)$input->getOption('relative'), 'force' => (bool)$input->getOption('force'), - ); + ]; $legacyExtensionsLocator = $this->getContainer()->get('ezpublish_legacy.legacy_bundles.extension_locator'); $kernel = $this->getContainer()->get('kernel'); @@ -67,9 +67,9 @@ protected function execute(InputInterface $input, OutputInterface $output) * @throws \RuntimeException If a target link/directory exists and $options[force] isn't set to true * @return string The resulting link/directory */ - protected function linkLegacyExtension($extensionPath, array $options = array(), OutputInterface $output) + protected function linkLegacyExtension($extensionPath, array $options = [], OutputInterface $output) { - $options += array('force' => false, 'copy' => false, 'relative' => false); + $options += ['force' => false, 'copy' => false, 'relative' => false]; $filesystem = $this->getContainer()->get('filesystem'); $legacyRootDir = rtrim($this->getContainer()->getParameter('ezpublish_legacy.root_dir'), '/'); diff --git a/bundle/Command/LegacyConfigurationCommand.php b/bundle/Command/LegacyConfigurationCommand.php index bcde00ee..7a177892 100644 --- a/bundle/Command/LegacyConfigurationCommand.php +++ b/bundle/Command/LegacyConfigurationCommand.php @@ -22,11 +22,11 @@ protected function configure() $this ->setName('ezpublish:configure') ->setDefinition( - array( + [ new InputArgument('package', InputArgument::REQUIRED, 'Name of the installed package. Used to generate the settings group name. Example: ezdemo_site'), new InputArgument('adminsiteaccess', InputArgument::REQUIRED, 'Name of your admin siteaccess. Example: ezdemo_site_admin'), new InputOption('backup', null, InputOption::VALUE_NONE, 'Makes a backup of existing files if any'), - ) + ] ) ->setDescription('Creates the ezpublish 5 configuration based on an existing ezpublish_legacy') ->setHelp( diff --git a/bundle/Command/LegacyEmbedScriptCommand.php b/bundle/Command/LegacyEmbedScriptCommand.php index 71d4fd18..fb463d68 100644 --- a/bundle/Command/LegacyEmbedScriptCommand.php +++ b/bundle/Command/LegacyEmbedScriptCommand.php @@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $siteAccess = $input->getOption('siteaccess'); - if ($siteAccess && !in_array("--siteaccess=$siteAccess", $_SERVER['argv'])) { + if ($siteAccess && !\in_array("--siteaccess=$siteAccess", $_SERVER['argv'])) { $_SERVER['argv'][] = "--siteaccess=$siteAccess"; $GLOBALS['argv'][] = "--siteaccess=$siteAccess"; } diff --git a/bundle/Command/LegacyInitCommand.php b/bundle/Command/LegacyInitCommand.php index e0051342..d76f1186 100644 --- a/bundle/Command/LegacyInitCommand.php +++ b/bundle/Command/LegacyInitCommand.php @@ -20,9 +20,9 @@ protected function configure() $this ->setName('ezpublish:legacy:init') ->setDefinition( - array( + [ new InputArgument('src', InputArgument::OPTIONAL, 'The src directory for legacy files', 'src/legacy_files'), - ) + ] ) ->setDescription('Inits Platform installation for legacy usage') ->setHelp( @@ -105,7 +105,7 @@ protected function updateComposeJson(OutputInterface $output) return; } - if (!array_key_exists('legacy-scripts', $composerJson['scripts'])) { + if (!\array_key_exists('legacy-scripts', $composerJson['scripts'])) { $legacy_scripts = [ 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::installAssets', 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::installLegacyBundlesExtensions', @@ -116,7 +116,7 @@ protected function updateComposeJson(OutputInterface $output) $updateComposerJson = true; } - if (!array_key_exists('symfony-scripts', $composerJson['scripts'])) { + if (!\array_key_exists('symfony-scripts', $composerJson['scripts'])) { $composerJson['scripts']['symfony-scripts'] = ['@legacy-scripts']; $updateComposerJson = true; $errOutput->writeln(<<<'EOT' diff --git a/bundle/Command/LegacySrcSymlinkCommand.php b/bundle/Command/LegacySrcSymlinkCommand.php index 3177cdbd..d28d9c2f 100644 --- a/bundle/Command/LegacySrcSymlinkCommand.php +++ b/bundle/Command/LegacySrcSymlinkCommand.php @@ -23,9 +23,9 @@ protected function configure() $this ->setName('ezpublish:legacy:symlink') ->setDefinition( - array( + [ new InputArgument('src', InputArgument::OPTIONAL, 'The src directory for legacy files', 'src/legacy_files'), - ) + ] ) ->addOption('create', 'c', InputOption::VALUE_NONE, 'DEPRECATED: Use ezpublish:legacy:init instead!') ->addOption('force', null, InputOption::VALUE_NONE, 'Force symlinking folders even if target already exists') diff --git a/bundle/Command/LegacyWrapperInstallCommand.php b/bundle/Command/LegacyWrapperInstallCommand.php index bb1eb84d..615ab119 100644 --- a/bundle/Command/LegacyWrapperInstallCommand.php +++ b/bundle/Command/LegacyWrapperInstallCommand.php @@ -26,9 +26,9 @@ protected function configure() $this ->setName('ezpublish:legacy:assets_install') ->setDefinition( - array( + [ new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'web'), - ) + ] ) ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it') ->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks') @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $relative = $input->getOption('relative'); $force = (bool)$input->getOption('force'); - foreach (array('design', 'extension', 'share', 'var') as $folder) { + foreach (['design', 'extension', 'share', 'var'] as $folder) { $targetDir = "$targetArg/$folder"; $originDir = "$legacyRootDir/$folder"; @@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $output->writeln("Installing wrappers for eZ Publish legacy front controllers (rest & cluster) with path $legacyRootDir"); - foreach (array('index_rest.php', 'index_cluster.php') as $frontController) { + foreach (['index_rest.php', 'index_cluster.php'] as $frontController) { $newFrontController = "$targetArg/$frontController"; $filesystem->remove($newFrontController); diff --git a/bundle/Controller/LegacyRestController.php b/bundle/Controller/LegacyRestController.php index 36882cfb..bc738d8b 100644 --- a/bundle/Controller/LegacyRestController.php +++ b/bundle/Controller/LegacyRestController.php @@ -20,7 +20,7 @@ class LegacyRestController extends Controller */ protected $restKernel; - public function __construct(\Closure $restKernelHandler, Loader $legacyKernelFactory, array $options = array()) + public function __construct(\Closure $restKernelHandler, Loader $legacyKernelFactory, array $options = []) { $kernelClosure = $legacyKernelFactory->buildLegacyKernel($restKernelHandler); $this->restKernel = $kernelClosure(); @@ -41,7 +41,7 @@ public function restAction() return new Response( $result->getContent(), $result->hasAttribute('statusCode') ? $result->getAttribute('statusCode') : 200, - $result->hasAttribute('headers') ? $result->getAttribute('headers') : array() + $result->hasAttribute('headers') ? $result->getAttribute('headers') : [] ); } } diff --git a/bundle/Controller/LegacySetupController.php b/bundle/Controller/LegacySetupController.php index 7b631b2a..8163f002 100644 --- a/bundle/Controller/LegacySetupController.php +++ b/bundle/Controller/LegacySetupController.php @@ -96,17 +96,17 @@ public function init() case 'Welcome': case 'SystemCheck': $this->getLegacyKernel()->runCallback( - function () { + static function () { eZINI::injectSettings( - array( - 'setup.ini' => array( + [ + 'setup.ini' => [ // checked folders are relative to the ezpublish_legacy folder - 'directory_permissions' => array( + 'directory_permissions' => [ 'CheckList' => '../app/logs;../app/cache;../app/config;' . eZINI::instance('setup.ini')->variable('directory_permissions', 'CheckList'), - ), - ), - ) + ], + ], + ] ); } ); @@ -122,8 +122,8 @@ function () { // Clear INI cache since setup has written new files $this->getLegacyKernel()->runCallback( - function () { - eZINI::injectSettings(array()); + static function () { + eZINI::injectSettings([]); eZCache::clearByTag('ini'); eZINI::resetAllInstances(); } diff --git a/bundle/Controller/LegacyTreeMenuController.php b/bundle/Controller/LegacyTreeMenuController.php index 5382ce5b..89adcfe5 100644 --- a/bundle/Controller/LegacyTreeMenuController.php +++ b/bundle/Controller/LegacyTreeMenuController.php @@ -19,7 +19,7 @@ class LegacyTreeMenuController extends Controller */ protected $treeMenuKernel; - public function __construct(\Closure $treeMenuKernelHandler, Loader $legacyKernelFactory, array $options = array()) + public function __construct(\Closure $treeMenuKernelHandler, Loader $legacyKernelFactory, array $options = []) { $kernelClosure = $legacyKernelFactory->buildLegacyKernel($treeMenuKernelHandler); $this->treeMenuKernel = $kernelClosure(); diff --git a/bundle/Controller/WebsiteToolbarController.php b/bundle/Controller/WebsiteToolbarController.php index c3493e70..7d1f0ed9 100644 --- a/bundle/Controller/WebsiteToolbarController.php +++ b/bundle/Controller/WebsiteToolbarController.php @@ -92,27 +92,27 @@ public function websiteToolbarAction($locationId = null, $originalSemanticPathIn $template = 'design:parts/website_toolbar_versionview.tpl'; $previewedContent = $authValueObject = $this->previewHelper->getPreviewedContent(); $previewedVersionInfo = $previewedContent->versionInfo; - $parameters = array( + $parameters = [ 'object' => $previewedContent, 'version' => $previewedVersionInfo, 'language' => $previewedVersionInfo->initialLanguageCode, 'is_creator' => $previewedVersionInfo->creatorId === $this->getRepository()->getCurrentUser()->id, - ); + ]; } elseif ($locationId === null) { return $response; } else { $authValueObject = $this->loadContentByLocationId($locationId); $template = 'design:parts/website_toolbar.tpl'; - $parameters = array( + $parameters = [ 'current_node_id' => $locationId, 'redirect_uri' => $originalSemanticPathInfo ? $originalSemanticPathInfo : $request->attributes->get('semanticPathinfo'), - ); + ]; } $authorizationAttribute = new AuthorizationAttribute( 'websitetoolbar', 'use', - array('valueObject' => $authValueObject) + ['valueObject' => $authValueObject] ); if (!$this->authChecker->isGranted($authorizationAttribute)) { diff --git a/bundle/DependencyInjection/Compiler/LegacyBundlesPass.php b/bundle/DependencyInjection/Compiler/LegacyBundlesPass.php index 49e6ca65..c6d96d0b 100644 --- a/bundle/DependencyInjection/Compiler/LegacyBundlesPass.php +++ b/bundle/DependencyInjection/Compiler/LegacyBundlesPass.php @@ -34,7 +34,7 @@ public function process(ContainerBuilder $container) $locator = $container->get('ezpublish_legacy.legacy_bundles.extension_locator'); - $extensionNames = array(); + $extensionNames = []; foreach ($this->kernel->getBundles() as $bundle) { $extensionNames += array_flip($locator->getExtensionNames($bundle)); } diff --git a/bundle/DependencyInjection/Compiler/LegacyPass.php b/bundle/DependencyInjection/Compiler/LegacyPass.php index dfbefca1..3893d63a 100644 --- a/bundle/DependencyInjection/Compiler/LegacyPass.php +++ b/bundle/DependencyInjection/Compiler/LegacyPass.php @@ -29,10 +29,10 @@ public function process(ContainerBuilder $container) $definition->addMethodCall( 'addConverter', - array( + [ new Reference($id), $attribute['for'], - ) + ] ); } } diff --git a/bundle/DependencyInjection/Compiler/RememberMeListenerPass.php b/bundle/DependencyInjection/Compiler/RememberMeListenerPass.php index 99554544..1f357b62 100644 --- a/bundle/DependencyInjection/Compiler/RememberMeListenerPass.php +++ b/bundle/DependencyInjection/Compiler/RememberMeListenerPass.php @@ -22,6 +22,6 @@ public function process(ContainerBuilder $container) $container->findDefinition('security.authentication.listener.rememberme') ->setClass('eZ\Bundle\EzPublishLegacyBundle\Security\RememberMeListener') - ->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver'))); + ->addMethodCall('setConfigResolver', [new Reference('ezpublish.config.resolver')]); } } diff --git a/bundle/DependencyInjection/Compiler/TwigPass.php b/bundle/DependencyInjection/Compiler/TwigPass.php index 3c612853..168a8a05 100644 --- a/bundle/DependencyInjection/Compiler/TwigPass.php +++ b/bundle/DependencyInjection/Compiler/TwigPass.php @@ -27,6 +27,6 @@ public function process(ContainerBuilder $container) // Mentioned side effects are losing extensions/loaders addition for which method calls are added in the TwigEnvironmentPass $container->getDefinition('twig') ->setClass('eZ\Publish\Core\MVC\Legacy\Templating\Twig\Environment') - ->addMethodCall('setEzLegacyEngine', array(new Reference('templating.engine.eztpl'))); + ->addMethodCall('setEzLegacyEngine', [new Reference('templating.engine.eztpl')]); } } diff --git a/bundle/DependencyInjection/Configuration.php b/bundle/DependencyInjection/Configuration.php index e4fec070..72d62ccc 100644 --- a/bundle/DependencyInjection/Configuration.php +++ b/bundle/DependencyInjection/Configuration.php @@ -24,7 +24,7 @@ public function getConfigTreeBuilder() ->scalarNode('root_dir') ->validate() ->ifTrue( - function ($v) { + static function ($v) { return !file_exists($v); } ) diff --git a/bundle/DependencyInjection/Configuration/LegacyConfigResolver.php b/bundle/DependencyInjection/Configuration/LegacyConfigResolver.php index 36d0fe4b..9a0f5b39 100644 --- a/bundle/DependencyInjection/Configuration/LegacyConfigResolver.php +++ b/bundle/DependencyInjection/Configuration/LegacyConfigResolver.php @@ -80,7 +80,7 @@ public function getParameter($paramName, $namespace = null, $scope = null) list($iniGroup, $paramName) = explode('.', $paramName, 2); return $this->getLegacyKernel()->runCallback( - function () use ($iniGroup, $paramName, $namespace, $scope) { + static function () use ($iniGroup, $paramName, $namespace, $scope) { if (isset($scope)) { $ini = eZINI::getSiteAccessIni($scope, "$namespace.ini"); } else { @@ -115,7 +115,7 @@ public function getGroup($groupName, $namespace = null, $scope = null) $namespace = str_replace('.ini', '', $namespace); return $this->getLegacyKernel()->runCallback( - function () use ($groupName, $namespace, $scope) { + static function () use ($groupName, $namespace, $scope) { if (isset($scope)) { $ini = eZINI::getSiteAccessIni($scope, "$namespace.ini"); } else { @@ -155,7 +155,7 @@ public function hasParameter($paramName, $namespace = null, $scope = null) list($iniGroup, $paramName) = explode('.', $paramName, 2); return $this->getLegacyKernel()->runCallback( - function () use ($iniGroup, $paramName, $namespace, $scope) { + static function () use ($iniGroup, $paramName, $namespace, $scope) { if (isset($scope)) { $ini = eZINI::getSiteAccessIni($scope, "$namespace.ini"); } else { diff --git a/bundle/DependencyInjection/EzPublishLegacyExtension.php b/bundle/DependencyInjection/EzPublishLegacyExtension.php index 7f2a445b..636805ce 100644 --- a/bundle/DependencyInjection/EzPublishLegacyExtension.php +++ b/bundle/DependencyInjection/EzPublishLegacyExtension.php @@ -36,7 +36,7 @@ public function load(array $configs, ContainerBuilder $container) // Conditionally load HTTP cache services compatible with // ezsystems/ezplatform-http-cache based on availability of its bundle $activatedBundles = $container->getParameter('kernel.bundles'); - array_key_exists('EzSystemsPlatformHttpCacheBundle', $activatedBundles) ? + \array_key_exists('EzSystemsPlatformHttpCacheBundle', $activatedBundles) ? $loader->load('http_cache/services.yml') : $loader->load('http_cache/legacy_services.yml'); @@ -67,7 +67,7 @@ public function load(array $configs, ContainerBuilder $container) $processor = new ConfigurationProcessor($container, 'ezpublish_legacy'); $processor->mapConfig( $config, - function (array $scopeSettings, $currentScope, ContextualizerInterface $contextualizer) { + static function (array $scopeSettings, $currentScope, ContextualizerInterface $contextualizer) { if (isset($scopeSettings['templating']['view_layout'])) { $contextualizer->setContextualParameter('view_default_layout', $currentScope, $scopeSettings['templating']['view_layout']); } diff --git a/bundle/EventListener/ConfigScopeListener.php b/bundle/EventListener/ConfigScopeListener.php index bdddc1c5..3e1298d2 100644 --- a/bundle/EventListener/ConfigScopeListener.php +++ b/bundle/EventListener/ConfigScopeListener.php @@ -27,10 +27,10 @@ public function __construct(Loader $kernelLoader) public static function getSubscribedEvents() { - return array( + return [ MVCEvents::CONFIG_SCOPE_CHANGE => 'onConfigScopeChange', MVCEvents::CONFIG_SCOPE_RESTORE => 'onConfigScopeChange', - ); + ]; } public function onConfigScopeChange(ScopeChangeEvent $event) diff --git a/bundle/EventListener/CsrfTokenResponseListener.php b/bundle/EventListener/CsrfTokenResponseListener.php index eb7fbf13..d52c88de 100644 --- a/bundle/EventListener/CsrfTokenResponseListener.php +++ b/bundle/EventListener/CsrfTokenResponseListener.php @@ -28,9 +28,9 @@ class CsrfTokenResponseListener implements EventSubscriberInterface { public static function getSubscribedEvents() { - return array( + return [ KernelEvents::RESPONSE => 'onKernelResponse', - ); + ]; } /** diff --git a/bundle/EventListener/LegacyKernelListener.php b/bundle/EventListener/LegacyKernelListener.php index b78ea603..5ac042bb 100644 --- a/bundle/EventListener/LegacyKernelListener.php +++ b/bundle/EventListener/LegacyKernelListener.php @@ -48,7 +48,7 @@ public static function getSubscribedEvents() public function onKernelReset(PreResetLegacyKernelEvent $event) { $event->getLegacyKernel()->runCallback( - function () { + static function () { eZINI::resetAllInstances(); }, true, diff --git a/bundle/EventListener/RequestListener.php b/bundle/EventListener/RequestListener.php index 6f594fa6..1285ce49 100644 --- a/bundle/EventListener/RequestListener.php +++ b/bundle/EventListener/RequestListener.php @@ -46,9 +46,9 @@ public function __construct(ConfigResolverInterface $configResolver, Repository public static function getSubscribedEvents() { - return array( + return [ KernelEvents::REQUEST => 'onKernelRequest', - ); + ]; } /** diff --git a/bundle/EventListener/RestListener.php b/bundle/EventListener/RestListener.php index 46c7e0a3..197483df 100644 --- a/bundle/EventListener/RestListener.php +++ b/bundle/EventListener/RestListener.php @@ -37,9 +37,9 @@ public function __construct($csrfTokenIntention) */ public static function getSubscribedEvents() { - return array( + return [ RestEvents::REST_CSRF_TOKEN_VALIDATED => 'setCsrfIntention', - ); + ]; } /** diff --git a/bundle/EventListener/SetupListener.php b/bundle/EventListener/SetupListener.php index 53d52461..f6a7cefb 100644 --- a/bundle/EventListener/SetupListener.php +++ b/bundle/EventListener/SetupListener.php @@ -34,11 +34,11 @@ public function __construct(RouterInterface $router, $defaultSiteAccess) public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('onKernelRequestSetup', 190), - ), - ); + return [ + KernelEvents::REQUEST => [ + ['onKernelRequestSetup', 190], + ], + ]; } /** diff --git a/bundle/EzPublishLegacyBundle.php b/bundle/EzPublishLegacyBundle.php index 8d61d40b..04a80c80 100644 --- a/bundle/EzPublishLegacyBundle.php +++ b/bundle/EzPublishLegacyBundle.php @@ -38,8 +38,8 @@ public function boot() } // Deactivate eZComponents loading from legacy autoload.php as they are already loaded - if (!defined('EZCBASE_ENABLED')) { - define('EZCBASE_ENABLED', false); + if (!\defined('EZCBASE_ENABLED')) { + \define('EZCBASE_ENABLED', false); } require_once $this->container->getParameter('ezpublish_legacy.root_dir') . '/autoload.php'; diff --git a/bundle/Features/Context/SetupWizard/Context.php b/bundle/Features/Context/SetupWizard/Context.php index ba49f6cd..a7aec905 100644 --- a/bundle/Features/Context/SetupWizard/Context.php +++ b/bundle/Features/Context/SetupWizard/Context.php @@ -12,14 +12,14 @@ use eZ\Bundle\EzPublishLegacyBundle\Features\Context\Legacy; use Behat\Behat\Context\Step; use Behat\Gherkin\Node\TableNode; -use PHPUnit_Framework_Assert as Assertion; +use PHPUnit\Framework\Assert as Assertion; class Context extends Legacy { /** * @var array This var should have the association between title in setup and package */ - protected $packages = array(); + protected $packages = []; /** * Initialize parameters. @@ -28,14 +28,14 @@ public function __construct() { parent::__construct(); - $this->pageIdentifierMap += array( + $this->pageIdentifierMap += [ 'setup wizard' => '/ezsetup', - ); + ]; - $this->packages += array( + $this->packages += [ 'ez publish demo site' => 'ezdemo_site', 'ez publish demo site (without demo content)' => 'ezdemo_site_clean', - ); + ]; } /** diff --git a/bundle/FieldType/Image/IO/IOServiceFactory.php b/bundle/FieldType/Image/IO/IOServiceFactory.php index bf78c046..c1ca309b 100644 --- a/bundle/FieldType/Image/IO/IOServiceFactory.php +++ b/bundle/FieldType/Image/IO/IOServiceFactory.php @@ -40,12 +40,12 @@ public function __construct(IOServiceInterface $publishedIOService, IOServiceInt */ public function buildService($class) { - $options = array( + $options = [ 'var_dir' => $this->configResolver->getParameter('var_dir'), 'storage_dir' => $this->configResolver->getParameter('storage_dir'), 'draft_images_dir' => $this->configResolver->getParameter('image.versioned_images_dir'), 'published_images_dir' => $this->configResolver->getParameter('image.published_images_dir'), - ); + ]; return new $class($this->publishedIOService, $this->draftIOService, $options); } diff --git a/bundle/LegacyBundles/LegacyExtensionsLocator.php b/bundle/LegacyBundles/LegacyExtensionsLocator.php index 5fc21cd1..38795d56 100644 --- a/bundle/LegacyBundles/LegacyExtensionsLocator.php +++ b/bundle/LegacyBundles/LegacyExtensionsLocator.php @@ -19,10 +19,10 @@ public function getExtensionDirectories($bundlePath) $legacyPath = "$bundlePath/ezpublish_legacy/"; if (!is_dir($legacyPath)) { - return array(); + return []; } - $return = array(); + $return = []; /** @var $item DirectoryIterator */ foreach (new DirectoryIterator($legacyPath) as $item) { if (!$item->isDir() || $item->isDot()) { @@ -42,7 +42,7 @@ public function getExtensionNames(BundleInterface $bundle) $extensions = $this->getExtensionDirectories($bundle->getPath()); array_walk( $extensions, - function (&$path) { + static function (&$path) { $path = basename($path); } ); diff --git a/bundle/LegacyMapper/Configuration.php b/bundle/LegacyMapper/Configuration.php index cbce15fd..85ddf168 100644 --- a/bundle/LegacyMapper/Configuration.php +++ b/bundle/LegacyMapper/Configuration.php @@ -80,7 +80,7 @@ public function __construct( UrlAliasGenerator $urlAliasGenerator, DatabaseHandler $legacyDbHandler, AliasCleanerInterface $aliasCleaner, - array $options = array() + array $options = [] ) { if (!$gatewayCachePurger instanceof GatewayCachePurger && !$gatewayCachePurger instanceof PurgeClientInterface) { throw new RuntimeException( @@ -114,9 +114,9 @@ public function setEnabled($isEnabled) public static function getSubscribedEvents() { - return array( - LegacyEvents::PRE_BUILD_LEGACY_KERNEL => array('onBuildKernel', 128), - ); + return [ + LegacyEvents::PRE_BUILD_LEGACY_KERNEL => ['onBuildKernel', 128], + ]; } /** @@ -131,9 +131,9 @@ public function onBuildKernel(PreBuildKernelEvent $event) } $databaseSettings = $this->legacyDbHandler->getConnection()->getParams(); - $settings = array(); + $settings = []; foreach ( - array( + [ 'host' => 'Server', 'port' => 'Port', 'user' => 'User', @@ -141,18 +141,18 @@ public function onBuildKernel(PreBuildKernelEvent $event) 'dbname' => 'Database', 'unix_socket' => 'Socket', 'driver' => 'DatabaseImplementation', - ) as $key => $iniKey + ] as $key => $iniKey ) { if (isset($databaseSettings[$key])) { $iniValue = $databaseSettings[$key]; switch ($key) { case 'driver': - $driverMap = array( + $driverMap = [ 'pdo_mysql' => 'ezmysqli', 'pdo_pgsql' => 'ezpostgresql', 'oci8' => 'ezoracle', - ); + ]; if (!isset($driverMap[$iniValue])) { throw new RuntimeException( "Could not map database driver to Legacy Stack database implementation.\n" . @@ -179,10 +179,10 @@ public function onBuildKernel(PreBuildKernelEvent $event) // Image settings $settings += $this->getImageSettings(); // File settings - $settings += array( + $settings += [ 'site.ini/FileSettings/VarDir' => $this->configResolver->getParameter('var_dir'), 'site.ini/FileSettings/StorageDir' => $this->configResolver->getParameter('storage_dir'), - ); + ]; // Multisite settings (PathPrefix and co) $settings += $this->getMultiSiteSettings(); @@ -218,43 +218,43 @@ public function onBuildKernel(PreBuildKernelEvent $event) // Register http cache content/cache event listener $ezpEvent = ezpEvent::getInstance(); - $ezpEvent->attach('content/cache', array($this->gatewayCachePurger, 'purge')); - $ezpEvent->attach('content/cache/all', array($this->gatewayCachePurger, 'purgeAll')); + $ezpEvent->attach('content/cache', [$this->gatewayCachePurger, 'purge']); + $ezpEvent->attach('content/cache/all', [$this->gatewayCachePurger, 'purgeAll']); // Register persistence cache event listeners - $ezpEvent->attach('content/cache', array($this->persistenceCachePurger, 'content')); - $ezpEvent->attach('content/cache/all', array($this->persistenceCachePurger, 'all')); - $ezpEvent->attach('content/cache/version', array($this->persistenceCachePurger, 'contentVersion')); - $ezpEvent->attach('content/class/cache/all', array($this->persistenceCachePurger, 'contentType')); - $ezpEvent->attach('content/class/cache', array($this->persistenceCachePurger, 'contentType')); - $ezpEvent->attach('content/class/group/cache', array($this->persistenceCachePurger, 'contentTypeGroup')); - $ezpEvent->attach('content/section/cache', array($this->persistenceCachePurger, 'section')); - $ezpEvent->attach('user/cache/all', array($this->persistenceCachePurger, 'user')); - $ezpEvent->attach('content/translations/cache', array($this->persistenceCachePurger, 'languages')); - $ezpEvent->attach('content/state/assign', array($this->persistenceCachePurger, 'stateAssign')); + $ezpEvent->attach('content/cache', [$this->persistenceCachePurger, 'content']); + $ezpEvent->attach('content/cache/all', [$this->persistenceCachePurger, 'all']); + $ezpEvent->attach('content/cache/version', [$this->persistenceCachePurger, 'contentVersion']); + $ezpEvent->attach('content/class/cache/all', [$this->persistenceCachePurger, 'contentType']); + $ezpEvent->attach('content/class/cache', [$this->persistenceCachePurger, 'contentType']); + $ezpEvent->attach('content/class/group/cache', [$this->persistenceCachePurger, 'contentTypeGroup']); + $ezpEvent->attach('content/section/cache', [$this->persistenceCachePurger, 'section']); + $ezpEvent->attach('user/cache/all', [$this->persistenceCachePurger, 'user']); + $ezpEvent->attach('content/translations/cache', [$this->persistenceCachePurger, 'languages']); + $ezpEvent->attach('content/state/assign', [$this->persistenceCachePurger, 'stateAssign']); // Register image alias removal listeners - $ezpEvent->attach('image/removeAliases', array($this->aliasCleaner, 'removeAliases')); - $ezpEvent->attach('image/trashAliases', array($this->aliasCleaner, 'removeAliases')); - $ezpEvent->attach('image/purgeAliases', array($this->aliasCleaner, 'removeAliases')); + $ezpEvent->attach('image/removeAliases', [$this->aliasCleaner, 'removeAliases']); + $ezpEvent->attach('image/trashAliases', [$this->aliasCleaner, 'removeAliases']); + $ezpEvent->attach('image/purgeAliases', [$this->aliasCleaner, 'removeAliases']); } private function getImageSettings() { - $imageSettings = array( + $imageSettings = [ // Basic settings 'image.ini/FileSettings/TemporaryDir' => $this->configResolver->getParameter('image.temporary_dir'), 'image.ini/FileSettings/PublishedImages' => $this->configResolver->getParameter('image.published_images_dir'), 'image.ini/FileSettings/VersionedImages' => $this->configResolver->getParameter('image.versioned_images_dir'), - 'image.ini/AliasSettings/AliasList' => array(), + 'image.ini/AliasSettings/AliasList' => [], // ImageMagick configuration 'image.ini/ImageMagick/IsEnabled' => $this->options['imagemagick_enabled'] ? 'true' : 'false', 'image.ini/ImageMagick/ExecutablePath' => $this->options['imagemagick_executable_path'], 'image.ini/ImageMagick/Executable' => $this->options['imagemagick_executable'], 'image.ini/ImageMagick/PreParameters' => $this->configResolver->getParameter('imagemagick.pre_parameters'), 'image.ini/ImageMagick/PostParameters' => $this->configResolver->getParameter('imagemagick.post_parameters'), - 'image.ini/ImageMagick/Filters' => array(), - ); + 'image.ini/ImageMagick/Filters' => [], + ]; // Aliases configuration $imageVariations = $this->configResolver->getParameter('image_variations'); @@ -273,7 +273,7 @@ private function getImageSettings() } foreach ($this->options['imagemagick_filters'] as $filterName => $filter) { - $imageSettings['image.ini/ImageMagick/Filters'][] = "$filterName=" . strtr($filter, array('{' => '%', '}' => '')); + $imageSettings['image.ini/ImageMagick/Filters'][] = "$filterName=" . strtr($filter, ['{' => '%', '}' => '']); } return $imageSettings; @@ -286,7 +286,7 @@ private function getMultiSiteSettings() $defaultPage = $this->configResolver->getParameter('default_page'); if ($rootLocationId === null) { // return SiteSettings if there is no MultiSite (rootLocation is not defined) - $result = array(); + $result = []; if ($indexPage !== null) { $result['site.ini/SiteSettings/IndexPage'] = $indexPage; } @@ -308,26 +308,26 @@ private function getMultiSiteSettings() } $pathPrefixExcludeItems = array_map( - function ($value) { + static function ($value) { return trim($value, '/'); }, $this->configResolver->getParameter('content.tree_root.excluded_uri_prefixes') ); - return array( + return [ 'site.ini/SiteAccessSettings/PathPrefix' => $pathPrefix, 'site.ini/SiteAccessSettings/PathPrefixExclude' => $pathPrefixExcludeItems, 'logfile.ini/AccessLogFileSettings/PathPrefix' => $pathPrefix, 'site.ini/SiteSettings/IndexPage' => $indexPage !== null ? $indexPage : "/content/view/full/$rootLocationId/", 'site.ini/SiteSettings/DefaultPage' => $defaultPage !== null ? $defaultPage : "/content/view/full/$rootLocationId/", - ); + ]; } private function getClusterSettings() { - $clusterSettings = array(); + $clusterSettings = []; if ($this->container->hasParameter('dfs_nfs_path')) { - $clusterSettings += array( + $clusterSettings += [ 'file.ini/ClusteringSettings/FileHandler' => 'eZDFSFileHandler', 'file.ini/eZDFSClusteringSettings/MountPointPath' => $this->container->getParameter('dfs_nfs_path'), 'file.ini/eZDFSClusteringSettings/DBHost' => $this->container->getParameter('dfs_database_host'), @@ -335,7 +335,7 @@ private function getClusterSettings() 'file.ini/eZDFSClusteringSettings/DBName' => $this->container->getParameter('dfs_database_name'), 'file.ini/eZDFSClusteringSettings/DBUser' => $this->container->getParameter('dfs_database_user'), 'file.ini/eZDFSClusteringSettings/DBPassword' => $this->container->getParameter('dfs_database_password'), - ); + ]; } return $clusterSettings; diff --git a/bundle/LegacyMapper/LegacyBundles.php b/bundle/LegacyMapper/LegacyBundles.php index 9b8258b3..bd67aba4 100644 --- a/bundle/LegacyMapper/LegacyBundles.php +++ b/bundle/LegacyMapper/LegacyBundles.php @@ -37,7 +37,7 @@ class LegacyBundles implements EventSubscriberInterface public function __construct( ConfigResolverInterface $configResolver, - array $options = array() + array $options = [] ) { $this->configResolver = $configResolver; $this->options = $options; @@ -55,9 +55,9 @@ public function setEnabled($isEnabled) public static function getSubscribedEvents() { - return array( - LegacyEvents::PRE_BUILD_LEGACY_KERNEL => array('onBuildKernel', 128), - ); + return [ + LegacyEvents::PRE_BUILD_LEGACY_KERNEL => ['onBuildKernel', 128], + ]; } /** @@ -77,7 +77,7 @@ public function onBuildKernel(PreBuildKernelEvent $event) return; } - $settings = array('site.ini/ExtensionSettings/ActiveExtensions' => $this->options['extensions']); + $settings = ['site.ini/ExtensionSettings/ActiveExtensions' => $this->options['extensions']]; $event->getParameters()->set( 'injected-merge-settings', diff --git a/bundle/LegacyMapper/Security.php b/bundle/LegacyMapper/Security.php index 1c24f617..4bc37cf7 100644 --- a/bundle/LegacyMapper/Security.php +++ b/bundle/LegacyMapper/Security.php @@ -67,10 +67,10 @@ public function setEnabled($enabled) public static function getSubscribedEvents() { - return array( + return [ LegacyEvents::POST_BUILD_LEGACY_KERNEL => 'onKernelBuilt', LegacyEvents::PRE_BUILD_LEGACY_KERNEL_WEB => 'onLegacyKernelWebBuild', - ); + ]; } /** @@ -92,7 +92,7 @@ public function onKernelBuilt(PostBuildKernelEvent $event) $currentUser = $this->repository->getCurrentUser(); $event->getLegacyKernel()->runCallback( - function () use ($currentUser) { + static function () use ($currentUser) { $legacyUser = eZUser::fetch($currentUser->id); eZUser::setCurrentlyLoggedInUser($legacyUser, $legacyUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE); }, @@ -125,12 +125,12 @@ public function onLegacyKernelWebBuild(PreBuildKernelWebHandlerEvent $event) return; } - $injectedMergeSettings = $event->getParameters()->get('injected-merge-settings', array()); - $accessRules = array( + $injectedMergeSettings = $event->getParameters()->get('injected-merge-settings', []); + $accessRules = [ 'access;disable', 'module;user/login', 'module;user/logout', - ); + ]; // Merge existing settings with the new ones if needed. if (isset($injectedMergeSettings['site.ini/SiteAccessRules/Rules'])) { $accessRules = array_merge($injectedMergeSettings['site.ini/SiteAccessRules/Rules'], $accessRules); diff --git a/bundle/LegacyMapper/Session.php b/bundle/LegacyMapper/Session.php index fadeb736..8e6c3ad3 100644 --- a/bundle/LegacyMapper/Session.php +++ b/bundle/LegacyMapper/Session.php @@ -46,9 +46,9 @@ public function __construct(SessionStorageInterface $sessionStorage, $sessionSto public static function getSubscribedEvents() { - return array( - LegacyEvents::PRE_BUILD_LEGACY_KERNEL => array('onBuildKernelHandler', 128), - ); + return [ + LegacyEvents::PRE_BUILD_LEGACY_KERNEL => ['onBuildKernelHandler', 128], + ]; } /** @@ -59,14 +59,14 @@ public static function getSubscribedEvents() */ public function onBuildKernelHandler(PreBuildKernelEvent $event) { - $sessionInfos = array( + $sessionInfos = [ 'configured' => false, 'started' => false, 'name' => false, 'namespace' => false, 'has_previous' => false, 'storage' => false, - ); + ]; if (isset($this->session)) { $request = $this->getCurrentRequest(); $sessionInfos['configured'] = true; @@ -82,13 +82,13 @@ public function onBuildKernelHandler(PreBuildKernelEvent $event) // Deactivate session cookie settings in legacy kernel. // This will force using settings defined in Symfony. - $sessionSettings = array( + $sessionSettings = [ 'site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false, - ); + ]; $legacyKernelParameters->set( 'injected-settings', $sessionSettings + (array)$legacyKernelParameters->get('injected-settings') diff --git a/bundle/LegacyMapper/SiteAccess.php b/bundle/LegacyMapper/SiteAccess.php index f73b258d..016b820f 100644 --- a/bundle/LegacyMapper/SiteAccess.php +++ b/bundle/LegacyMapper/SiteAccess.php @@ -22,18 +22,18 @@ class SiteAccess implements EventSubscriberInterface { use ContainerAwareTrait; - protected $options = array(); + protected $options = []; - public function __construct(array $options = array()) + public function __construct(array $options = []) { $this->options = $options; } public static function getSubscribedEvents() { - return array( - LegacyEvents::PRE_BUILD_LEGACY_KERNEL_WEB => array('onBuildKernelWebHandler', 128), - ); + return [ + LegacyEvents::PRE_BUILD_LEGACY_KERNEL_WEB => ['onBuildKernelWebHandler', 128], + ]; } /** @@ -45,7 +45,7 @@ public function onBuildKernelWebHandler(PreBuildKernelWebHandlerEvent $event) { $siteAccess = $this->container->get('ezpublish.siteaccess'); $request = $event->getRequest(); - $uriPart = array(); + $uriPart = []; // Convert matching type switch ($siteAccess->matchingType) { @@ -104,19 +104,19 @@ public function onBuildKernelWebHandler(PreBuildKernelWebHandlerEvent $event) throw new \RuntimeException('Compound matcher used but not submatchers found.'); } - if (count($subMatchers) == 2 && isset($subMatchers['Map\Host']) && isset($subMatchers['Map\URI'])) { + if (\count($subMatchers) == 2 && isset($subMatchers['Map\Host']) && isset($subMatchers['Map\URI'])) { $legacyAccessType = eZSiteAccess::TYPE_HTTP_HOST_URI; - $uriPart = array($subMatchers['Map\URI']->getMapKey()); + $uriPart = [$subMatchers['Map\URI']->getMapKey()]; } } $event->getParameters()->set( 'siteaccess', - array( + [ 'name' => $siteAccess->name, 'type' => $legacyAccessType, 'uri_part' => $uriPart, - ) + ] ); } @@ -130,6 +130,6 @@ protected function getFragmentPathItems() return explode('/', trim($this->options['fragment_path'], '/')); } - return array('_fragment'); + return ['_fragment']; } } diff --git a/bundle/LegacyResponse/LegacyResponseManager.php b/bundle/LegacyResponse/LegacyResponseManager.php index d95d153b..443026e6 100644 --- a/bundle/LegacyResponse/LegacyResponseManager.php +++ b/bundle/LegacyResponse/LegacyResponseManager.php @@ -86,7 +86,7 @@ public function generateResponseFromModuleResult(ezpKernelResult $result) $response = $this->render( $this->legacyLayout, - array('module_result' => $moduleResult) + ['module_result' => $moduleResult] ); $response->setModuleResult($moduleResult); @@ -168,7 +168,7 @@ public function generateRedirectResponse(ezpKernelRedirect $redirectResult) * * @return \eZ\Bundle\EzPublishLegacyBundle\LegacyResponse A LegacyResponse instance */ - private function render($view, array $parameters = array()) + private function render($view, array $parameters = []) { $response = new LegacyResponse(); $response->setContent($this->templateEngine->render($view, $parameters)); diff --git a/bundle/Rest/ResponseWriter.php b/bundle/Rest/ResponseWriter.php index 80aae3cd..4473f83c 100644 --- a/bundle/Rest/ResponseWriter.php +++ b/bundle/Rest/ResponseWriter.php @@ -32,10 +32,10 @@ public function handleResponse() } // automatically add content-length header - $this->headers['Content-Length'] = strlen($this->response->body); + $this->headers['Content-Length'] = \strlen($this->response->body); ezpKernelRest::setResponse( - new ezpKernelResult($this->response->body, array('headers' => $this->headers, 'statusCode' => $responseCode)) + new ezpKernelResult($this->response->body, ['headers' => $this->headers, 'statusCode' => $responseCode]) ); } } diff --git a/bundle/Routing/FallbackRouter.php b/bundle/Routing/FallbackRouter.php index 5bfc448e..fc38a6ae 100644 --- a/bundle/Routing/FallbackRouter.php +++ b/bundle/Routing/FallbackRouter.php @@ -102,7 +102,7 @@ public function getRouteCollection() * * @api */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) + public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) { if ($name === self::ROUTE_NAME) { if (!isset($parameters['module_uri'])) { @@ -129,10 +129,10 @@ public function matchRequest(Request $request) . $request->attributes->get('viewParametersString', '') . '?' . $request->getQueryString(); - return array( + return [ '_route' => self::ROUTE_NAME, '_controller' => 'ezpublish_legacy.controller:indexAction', 'module_uri' => $moduleUri, - ); + ]; } } diff --git a/bundle/Routing/UrlGenerator.php b/bundle/Routing/UrlGenerator.php index 03fe3d8e..b329fe57 100644 --- a/bundle/Routing/UrlGenerator.php +++ b/bundle/Routing/UrlGenerator.php @@ -55,7 +55,7 @@ public function doGenerate($legacyModuleUri, array $parameters) if (strpos($legacyModuleUri, '/') === 0) { $legacyModuleUri = substr($legacyModuleUri, 1); } - if (strrpos($legacyModuleUri, '/') === (strlen($legacyModuleUri) - 1)) { + if (strrpos($legacyModuleUri, '/') === (\strlen($legacyModuleUri) - 1)) { $legacyModuleUri = substr($legacyModuleUri, 0, -1); } @@ -67,7 +67,7 @@ public function doGenerate($legacyModuleUri, array $parameters) list($moduleName, $viewName) = explode('/', $legacyModuleUri); return $this->getLegacyKernel()->runCallback( - function () use ($legacyModuleUri, $moduleName, $viewName, $parameters, $queryString) { + static function () use ($legacyModuleUri, $moduleName, $viewName, $parameters, $queryString) { $module = eZModule::findModule($moduleName); if (!$module instanceof eZModule) { throw new \InvalidArgumentException("Legacy module '$moduleName' doesn't exist. Cannot generate URL."); @@ -84,7 +84,7 @@ function () use ($legacyModuleUri, $moduleName, $viewName, $parameters, $querySt continue; } - if (is_bool($paramValue)) { + if (\is_bool($paramValue)) { $paramValue = (int)$paramValue; } diff --git a/bundle/SetupWizard/ConfigurationConverter.php b/bundle/SetupWizard/ConfigurationConverter.php index 9f68e73d..0ab39bd8 100644 --- a/bundle/SetupWizard/ConfigurationConverter.php +++ b/bundle/SetupWizard/ConfigurationConverter.php @@ -61,38 +61,38 @@ public function fromLegacy($sitePackage, $adminSiteaccess) $settings['ezpublish']['siteaccess']['default_siteaccess'] = $defaultSiteaccess; $siteList = $this->getParameter('SiteAccessSettings', 'AvailableSiteAccessList'); - if (!is_array($siteList) || empty($siteList)) { + if (!\is_array($siteList) || empty($siteList)) { throw new InvalidArgumentException('siteList', 'can not be empty'); } - if (!in_array($adminSiteaccess, $siteList)) { + if (!\in_array($adminSiteaccess, $siteList)) { throw new InvalidArgumentException('adminSiteaccess', "Siteaccess $adminSiteaccess wasn't found in SiteAccessSettings.AvailableSiteAccessList"); } $settings['ezpublish']['siteaccess']['list'] = $siteList; - $settings['ezpublish']['siteaccess']['groups'] = array(); + $settings['ezpublish']['siteaccess']['groups'] = []; $groupName = $sitePackage . '_group'; $settings['ezpublish']['siteaccess']['groups'][$groupName] = $siteList; $settings['ezpublish']['siteaccess']['match'] = $this->resolveMatching(); - $settings['ezpublish']['system'] = array(); - $settings['ezpublish']['system'][$groupName] = array(); + $settings['ezpublish']['system'] = []; + $settings['ezpublish']['system'][$groupName] = []; - $settings['ezpublish']['system'][$defaultSiteaccess] = array(); - $settings['ezpublish']['system'][$adminSiteaccess] = array(); + $settings['ezpublish']['system'][$defaultSiteaccess] = []; + $settings['ezpublish']['system'][$adminSiteaccess] = []; // Database settings $databaseSettings = $this->getGroup('DatabaseSettings', 'site.ini', $defaultSiteaccess); $repositoryName = "{$defaultSiteaccess}_repository"; - $settings['doctrine'] = array( - 'dbal' => array( - 'connections' => array( + $settings['doctrine'] = [ + 'dbal' => [ + 'connections' => [ "{$repositoryName}_connection" => $this->getDoctrineSettings($databaseSettings), - ), - ), - ); - $settings['ezpublish']['repositories'] = array( - $repositoryName => array('engine' => 'legacy', 'connection' => "{$repositoryName}_connection"), - ); + ], + ], + ]; + $settings['ezpublish']['repositories'] = [ + $repositoryName => ['engine' => 'legacy', 'connection' => "{$repositoryName}_connection"], + ]; $settings['ezpublish']['system'][$groupName]['repository'] = $repositoryName; // If package is not supported, all siteaccesses will have individually legacy_mode to true, forcing legacy fallback @@ -147,7 +147,7 @@ public function fromLegacy($sitePackage, $adminSiteaccess) $this->getParameter('Session', 'SessionNameHandler', 'site.ini', $siteaccess) === 'custom' && $this->getParameter('Session', 'SessionNamePerSiteAccess', 'site.ini', $siteaccess) !== 'enabled' ) { - $settings['ezpublish']['system'][$siteaccess]['session'] = array('name' => $this->getParameter('Session', 'SessionNamePrefix', 'site.ini')); + $settings['ezpublish']['system'][$siteaccess]['session'] = ['name' => $this->getParameter('Session', 'SessionNamePrefix', 'site.ini')]; } } @@ -168,7 +168,7 @@ public function fromLegacy($sitePackage, $adminSiteaccess) */ protected function getDoctrineSettings(array $databaseSettings) { - $databaseMapping = array( + $databaseMapping = [ 'ezmysqli' => 'pdo_mysql', 'eZMySQLiDB' => 'pdo_mysql', 'ezmysql' => 'pdo_mysql', @@ -179,7 +179,7 @@ protected function getDoctrineSettings(array $databaseSettings) 'pgsql' => 'pdo_pgsql', 'oracle' => 'oci8', 'ezoracle' => 'oci8', - ); + ]; $databaseType = $databaseSettings['DatabaseImplementation']; if (isset($databaseMapping[$databaseType])) { @@ -187,14 +187,14 @@ protected function getDoctrineSettings(array $databaseSettings) } $databasePassword = $databaseSettings['Password'] != '' ? $databaseSettings['Password'] : null; - $doctrineSettings = array( + $doctrineSettings = [ 'driver' => $databaseType, 'host' => $databaseSettings['Server'], 'user' => $databaseSettings['User'], 'password' => $databasePassword, 'dbname' => $databaseSettings['Database'], 'charset' => 'UTF8', - ); + ]; if (isset($databaseSettings['Port']) && !empty($databaseSettings['Port'])) { $doctrineSettings['port'] = $databaseSettings['Port']; } @@ -220,17 +220,17 @@ protected function getDoctrineSettings(array $databaseSettings) protected function getStashCacheSettings() { // Should only contain one out of the box - $handlers = array(); + $handlers = []; $inMemory = false; - $handlerSetting = array(); + $handlerSetting = []; if (FileSystemDriver::isAvailable()) { $handlers[] = 'FileSystem'; $inMemory = true; // If running on Windows, use "crc32" keyHashFunction if (stripos(php_uname(), 'win') === 0) { - $handlerSetting['FileSystem'] = array( + $handlerSetting['FileSystem'] = [ 'keyHashFunction' => 'crc32', - ); + ]; } } else { // '/dev/null' fallback driver, no cache at all @@ -238,16 +238,16 @@ protected function getStashCacheSettings() $inMemory = true; } - return array( - 'caches' => array( - 'default' => array( + return [ + 'caches' => [ + 'default' => [ 'drivers' => $handlers, // inMemory will enable/disable "Ephemeral", not allowed as separate handler in stash-bundle 'inMemory' => $inMemory, 'registerDoctrineAdapter' => false, - ) + $handlerSetting, - ), - ); + ] + $handlerSetting, + ], + ]; } /** @@ -261,7 +261,7 @@ protected function getStashCacheSettings() */ protected function getLanguages(array $siteList, $groupName) { - $result = array(); + $result = []; $allSame = true; $previousSA = null; foreach ($siteList as $siteaccess) { @@ -274,7 +274,7 @@ protected function getLanguages(array $siteList, $groupName) $previousSA = $siteaccess; } if ($allSame) { - return array($groupName => $result[$previousSA]); + return [$groupName => $result[$previousSA]]; } return $result; @@ -292,7 +292,7 @@ protected function getLanguages(array $siteList, $groupName) */ protected function getImageVariations(array $siteList, $groupName) { - $result = array(); + $result = []; $allSame = true; $previousSA = null; foreach ($siteList as $siteaccess) { @@ -303,7 +303,7 @@ protected function getImageVariations(array $siteList, $groupName) $previousSA = $siteaccess; } if ($allSame) { - return array($groupName => $result[$previousSA]); + return [$groupName => $result[$previousSA]]; } return $result; @@ -318,18 +318,18 @@ protected function getImageVariations(array $siteList, $groupName) */ protected function getImageVariationsForSiteaccess($siteaccess) { - $variations = array(); + $variations = []; $imageAliasesList = $this->getGroup('AliasSettings', 'image.ini', $siteaccess); foreach ($imageAliasesList['AliasList'] as $imageAliasIdentifier) { - $variationSettings = array('reference' => null, 'filters' => array()); + $variationSettings = ['reference' => null, 'filters' => []]; $aliasSettings = $this->getGroup($imageAliasIdentifier, 'image.ini', $siteaccess); if (isset($aliasSettings['Reference']) && $aliasSettings['Reference'] != '') { $variationSettings['reference'] = $aliasSettings['Reference']; } - if (isset($aliasSettings['Filters']) && is_array($aliasSettings['Filters'])) { + if (isset($aliasSettings['Filters']) && \is_array($aliasSettings['Filters'])) { // parse filters. Format: filtername=param1;param2...paramN foreach ($aliasSettings['Filters'] as $filterString) { - $filteringSettings = array(); + $filteringSettings = []; if (strstr($filterString, '=') !== false) { list($filteringSettings['name'], $filterParams) = explode('=', $filterString); @@ -338,7 +338,7 @@ protected function getImageVariationsForSiteaccess($siteaccess) // make sure integers are actually integers, not strings array_walk( $filterParams, - function (&$value) { + static function (&$value) { if (preg_match('/^[0-9]+$/', $value)) { $value = (int)$value; } @@ -378,10 +378,10 @@ public function getGroup($groupName, $file = null, $siteaccess = null) } return $this->legacyKernel->runCallback( - function () use ($file, $groupName, $siteaccess) { + static function () use ($file, $groupName, $siteaccess) { // @todo: do reset injected settings everytime // and make sure to restore the previous injected settings - eZINI::injectSettings(array()); + eZINI::injectSettings([]); return eZSiteAccess::getIni($siteaccess, $file)->group($groupName); }, @@ -411,10 +411,10 @@ public function getParameter($groupName, $parameterName, $file = null, $siteacce } return $this->legacyKernel->runCallback( - function () use ($file, $groupName, $parameterName, $siteaccess) { + static function () use ($file, $groupName, $parameterName, $siteaccess) { // @todo: do reset injected settings everytime // and make sure to restore the previous injected settings - eZINI::injectSettings(array()); + eZINI::injectSettings([]); return eZSiteAccess::getIni($siteaccess, $file) ->variable($groupName, $parameterName); @@ -428,7 +428,7 @@ protected function resolveMatching() { $siteaccessSettings = $this->getGroup('SiteAccessSettings'); - $matching = array(); + $matching = []; $match = false; foreach (explode(';', $siteaccessSettings['MatchOrder']) as $matchMethod) { switch ($matchMethod) { @@ -442,7 +442,7 @@ protected function resolveMatching() $match = false; break; case 'port': - $match = array('Map\Port' => $this->getGroup('PortAccessSettings')); + $match = ['Map\Port' => $this->getGroup('PortAccessSettings')]; break; } if ($match !== false) { @@ -460,16 +460,16 @@ protected function resolveUriMatching($siteaccessSettings) return false; case 'map': - return array('Map\\URI' => $this->resolveMapMatch($siteaccessSettings['URIMatchMapItems'])); + return ['Map\\URI' => $this->resolveMapMatch($siteaccessSettings['URIMatchMapItems'])]; case 'element': - return array('URIElement' => $siteaccessSettings['URIMatchElement']); + return ['URIElement' => $siteaccessSettings['URIMatchElement']]; case 'text': - return array('URIText' => $this->resolveTextMatch($siteaccessSettings, 'URIMatchSubtextPre', 'URIMatchSubtextPost')); + return ['URIText' => $this->resolveTextMatch($siteaccessSettings, 'URIMatchSubtextPre', 'URIMatchSubtextPost')]; case 'regexp': - return array('Regex\\URI' => array($siteaccessSettings['URIMatchRegexp'], $siteaccessSettings['URIMatchRegexpItem'])); + return ['Regex\\URI' => [$siteaccessSettings['URIMatchRegexp'], $siteaccessSettings['URIMatchRegexpItem']]]; } } @@ -488,16 +488,16 @@ protected function resolveHostMatching($siteaccessSettings) return false; case 'map': - return array('Map\\Host' => $this->resolveMapMatch($siteaccessSettings['HostMatchMapItems'])); + return ['Map\\Host' => $this->resolveMapMatch($siteaccessSettings['HostMatchMapItems'])]; case 'element': - return array('HostElement' => $siteaccessSettings['HostMatchElement']); + return ['HostElement' => $siteaccessSettings['HostMatchElement']]; case 'text': - return array('HostText' => $this->resolveTextMatch($siteaccessSettings, 'HostMatchSubtextPre', 'HostMatchSubtextPost')); + return ['HostText' => $this->resolveTextMatch($siteaccessSettings, 'HostMatchSubtextPre', 'HostMatchSubtextPost')]; case 'regexp': - return array('Regex\\Host' => array($siteaccessSettings['HostMatchRegexp'], $siteaccessSettings['HostMatchRegexpItem'])); + return ['Regex\\Host' => [$siteaccessSettings['HostMatchRegexp'], $siteaccessSettings['HostMatchRegexpItem']]]; default: throw new InvalidArgumentException('HostMatchType', "Invalid value for legacy setting site.ini '{$siteaccessSettings['HostMatchType']}'"); @@ -506,7 +506,7 @@ protected function resolveHostMatching($siteaccessSettings) protected function resolveTextMatch($siteaccessSettings, $prefixKey, $suffixKey) { - $settings = array(); + $settings = []; if (isset($siteaccessSettings[$prefixKey])) { $settings['prefix'] = $siteaccessSettings[$prefixKey]; } @@ -519,10 +519,10 @@ protected function resolveTextMatch($siteaccessSettings, $prefixKey, $suffixKey) protected function resolveMapMatch($mapArray) { - $map = array(); + $map = []; foreach ($mapArray as $mapItem) { $elements = explode(';', $mapItem); - $map[$elements[0]] = count($elements) > 2 ? array_slice($elements, 1) : $elements[1]; + $map[$elements[0]] = \count($elements) > 2 ? \array_slice($elements, 1) : $elements[1]; } return $map; diff --git a/bundle/SetupWizard/ConfigurationDumper.php b/bundle/SetupWizard/ConfigurationDumper.php index 2d43ac6f..2c68a981 100644 --- a/bundle/SetupWizard/ConfigurationDumper.php +++ b/bundle/SetupWizard/ConfigurationDumper.php @@ -79,9 +79,9 @@ public function dump(array $configArray, $options = ConfigDumperInterface::OPT_D foreach (array_keys($this->envs) as $env) { $configFile = "$configPath/ezpublish_{$env}.yml"; // Add the import statement for the root YAML file - $envConfigArray = array( - 'imports' => array(array('resource' => 'ezpublish.yml')), - ); + $envConfigArray = [ + 'imports' => [['resource' => 'ezpublish.yml']], + ]; // File already exists, handle possible options if ($this->fs->exists($configFile) && $options & static::OPT_BACKUP_CONFIG) { diff --git a/bundle/Tests/Cache/PersistenceCachePurgerTest.php b/bundle/Tests/Cache/PersistenceCachePurgerTest.php index 54185422..a91faad0 100644 --- a/bundle/Tests/Cache/PersistenceCachePurgerTest.php +++ b/bundle/Tests/Cache/PersistenceCachePurgerTest.php @@ -140,14 +140,14 @@ public function testClearAllDisabled() */ public function testClearAllContent() { - $map = array( - array('content', null), - array(['content', 'info', 'remoteId'], null), - array('urlAlias', null), - array('location', null), - ); + $map = [ + ['content', null], + [['content', 'info', 'remoteId'], null], + ['urlAlias', null], + ['location', null], + ]; $this->cacheService - ->expects($this->exactly(count($map))) + ->expects($this->exactly(\count($map))) ->method('clear') ->will($this->returnValueMap($map)); $this->assertNull($this->cachePurger->content()); @@ -170,11 +170,11 @@ public function testClearContent() ->method('load') ->will( $this->returnValueMap( - array( - array($locationId1, $this->buildLocation($locationId1, $contentId1)), - array($locationId2, $this->buildLocation($locationId2, $contentId2)), - array($locationId3, $this->buildLocation($locationId3, $contentId3)), - ) + [ + [$locationId1, $this->buildLocation($locationId1, $contentId1)], + [$locationId2, $this->buildLocation($locationId2, $contentId2)], + [$locationId3, $this->buildLocation($locationId3, $contentId3)], + ] ) ); @@ -183,20 +183,20 @@ public function testClearContent() ->method('clear') ->will( $this->returnValueMap( - array( - array('content', $contentId1, null), - array('content', 'info', $contentId1, null), - array('content', $contentId2, null), - array('content', 'info', $contentId2, null), - array('content', $contentId3, null), - array('content', 'info', $contentId3, null), - array('urlAlias', null), - array('location', null), - ) + [ + ['content', $contentId1, null], + ['content', 'info', $contentId1, null], + ['content', $contentId2, null], + ['content', 'info', $contentId2, null], + ['content', $contentId3, null], + ['content', 'info', $contentId3, null], + ['urlAlias', null], + ['location', null], + ] ) ); - $locationIds = array($locationId1, $locationId2, $locationId3); + $locationIds = [$locationId1, $locationId2, $locationId3]; $this->assertSame($locationIds, $this->cachePurger->content($locationIds)); } @@ -217,17 +217,17 @@ public function testClearOneContent() ->method('clear') ->will( $this->returnValueMap( - array( - array('content', $contentId, null), - array('content', 'info', $contentId, null), - array('content', 'info', 'remoteId', null), - array('urlAlias', null), - array('location', null), - ) + [ + ['content', $contentId, null], + ['content', 'info', $contentId, null], + ['content', 'info', 'remoteId', null], + ['urlAlias', null], + ['location', null], + ] ) ); - $this->assertSame(array($locationId), $this->cachePurger->content($locationId)); + $this->assertSame([$locationId], $this->cachePurger->content($locationId)); } /** @@ -238,20 +238,20 @@ public function testClearOneContent() private function buildLocation($locationId, $contentId) { return new Location( - array( + [ 'id' => $locationId, 'contentId' => $contentId, - ) + ] ); } /** - * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType - * * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::content */ public function testClearContentFail() { + $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentType::class); + $this->cachePurger->content(new \stdClass()); } @@ -282,12 +282,12 @@ public function testClearContentType() } /** - * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType - * * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::contentType */ public function testClearContentTypeFail() { + $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentType::class); + $this->cachePurger->contentType(new \stdClass()); } @@ -301,10 +301,10 @@ public function testClearContentTypeGroupAll() ->method('clear') ->will( $this->returnValueMap( - array( - array('contentTypeGroup', null), - array('contentType', null), - ) + [ + ['contentTypeGroup', null], + ['contentType', null], + ] ) ); @@ -321,10 +321,10 @@ public function testClearContentTypeGroup() ->method('clear') ->will( $this->returnValueMap( - array( - array('contentTypeGroup', 123, null), - array('contentType', null), - ) + [ + ['contentTypeGroup', 123, null], + ['contentType', null], + ] ) ); @@ -332,12 +332,12 @@ public function testClearContentTypeGroup() } /** - * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType - * * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::contentTypeGroup */ public function testClearContentTypeGroupFail() { + $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentType::class); + $this->cachePurger->contentTypeGroup(new \stdClass()); } @@ -368,12 +368,12 @@ public function testClearSection() } /** - * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType - * * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::section */ public function testClearSectionFail() { + $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentType::class); + $this->cachePurger->section(new \stdClass()); } @@ -391,15 +391,15 @@ public function testClearLanguages() ->method('clear') ->will( $this->returnValueMap( - array( - array($languageId1, null), - array($languageId2, null), - array($languageId3, null), - ) + [ + [$languageId1, null], + [$languageId2, null], + [$languageId3, null], + ] ) ); - $this->cachePurger->languages(array($languageId1, $languageId2, $languageId3)); + $this->cachePurger->languages([$languageId1, $languageId2, $languageId3]); } /** @@ -414,9 +414,9 @@ public function testClearOneLanguage() ->method('clear') ->will( $this->returnValueMap( - array( - array($languageId, null), - ) + [ + [$languageId, null], + ] ) ); @@ -450,12 +450,12 @@ public function testClearUser() } /** - * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType - * * @covers \eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger::user */ public function testClearUserFail() { + $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentType::class); + $this->cachePurger->user(new \stdClass()); } } diff --git a/bundle/Tests/Cache/SwitchableHttpCachePurgerTest.php b/bundle/Tests/Cache/SwitchableHttpCachePurgerTest.php index 8b6426ce..11a54a25 100644 --- a/bundle/Tests/Cache/SwitchableHttpCachePurgerTest.php +++ b/bundle/Tests/Cache/SwitchableHttpCachePurgerTest.php @@ -62,6 +62,6 @@ public function testPurgeAllSwitchedOff() private function getCacheElements() { - return array(1, 2, 3); + return [1, 2, 3]; } } diff --git a/bundle/Tests/DependencyInjection/Compiler/LegacyBundlesPassTest.php b/bundle/Tests/DependencyInjection/Compiler/LegacyBundlesPassTest.php index d3d1b086..23647b12 100644 --- a/bundle/Tests/DependencyInjection/Compiler/LegacyBundlesPassTest.php +++ b/bundle/Tests/DependencyInjection/Compiler/LegacyBundlesPassTest.php @@ -34,17 +34,17 @@ public function testCompilerPass() $this->getKernelMock() ->expects($this->any()) ->method('getBundles') - ->will($this->returnValue(array($bundle1, $bundle2))); + ->will($this->returnValue([$bundle1, $bundle2])); $this->getLocatorMock() ->expects($this->any()) ->method('getExtensionNames') ->will( $this->returnValueMap( - array( - array($bundle1, array('legacy_extension_a', 'legacy_extension_b')), - array($bundle2, array('legacy_extension_b', 'legacy_extension_c')), - ) + [ + [$bundle1, ['legacy_extension_a', 'legacy_extension_b']], + [$bundle2, ['legacy_extension_b', 'legacy_extension_c']], + ] ) ); $this->container->set( @@ -55,7 +55,7 @@ public function testCompilerPass() $this->assertContainerBuilderHasParameter( 'ezpublish_legacy.legacy_bundles_extensions', - array('legacy_extension_a', 'legacy_extension_b', 'legacy_extension_c') + ['legacy_extension_a', 'legacy_extension_b', 'legacy_extension_c'] ); } diff --git a/bundle/Tests/DependencyInjection/Configuration/LegacyConfigResolverTest.php b/bundle/Tests/DependencyInjection/Configuration/LegacyConfigResolverTest.php index d17da647..a4697444 100644 --- a/bundle/Tests/DependencyInjection/Configuration/LegacyConfigResolverTest.php +++ b/bundle/Tests/DependencyInjection/Configuration/LegacyConfigResolverTest.php @@ -31,7 +31,7 @@ protected function setUp() { parent::setUp(); $legacyKernel = $this->legacyKernel = $this->createMock(ezpKernelHandler::class); - $kernelClosure = function () use ($legacyKernel) { + $kernelClosure = static function () use ($legacyKernel) { return $legacyKernel; }; @@ -69,18 +69,17 @@ public function testHasParameter($paramName, $namespace, $expected) public function hasParameterProvider() { - return array( - array('Foo.Bar', null, true), - array('Foo.Bar.baz', null, false), - array('Foo.Babar', 'foo.ini', true), - ); + return [ + ['Foo.Bar', null, true], + ['Foo.Bar.baz', null, false], + ['Foo.Babar', 'foo.ini', true], + ]; } - /** - * @expectedException \eZ\Publish\Core\MVC\Exception\ParameterNotFoundException - */ public function testGetParameterInvalidParam() { + $this->expectException(\eZ\Publish\Core\MVC\Exception\ParameterNotFoundException::class); + $this->legacyKernel ->expects($this->never()) ->method('runCallback'); @@ -102,18 +101,17 @@ public function testGetParameter($paramName, $namespace, $value) public function getParameterProvider() { - return array( - array('Foo.Bar', null, 'something'), - array('Foo.Bar.baz', null, array('blabla')), - array('Foo.Babar', 'foo.ini', 'enabled'), - ); + return [ + ['Foo.Bar', null, 'something'], + ['Foo.Bar.baz', null, ['blabla']], + ['Foo.Babar', 'foo.ini', 'enabled'], + ]; } - /** - * @expectedException \eZ\Publish\Core\MVC\Exception\ParameterNotFoundException - */ public function testGetNonExistentParameter() { + $this->expectException(\eZ\Publish\Core\MVC\Exception\ParameterNotFoundException::class); + $paramName = 'Foo.Bar'; $namespace = 'foo'; $this->legacyKernel diff --git a/bundle/Tests/DependencyInjection/EzPublishLegacyExtensionTest.php b/bundle/Tests/DependencyInjection/EzPublishLegacyExtensionTest.php index 661d3097..43c6d7a6 100644 --- a/bundle/Tests/DependencyInjection/EzPublishLegacyExtensionTest.php +++ b/bundle/Tests/DependencyInjection/EzPublishLegacyExtensionTest.php @@ -17,9 +17,9 @@ class EzPublishLegacyExtensionTest extends AbstractExtensionTestCase { protected function getContainerExtensions() { - return array( + return [ new EzPublishLegacyExtension(), - ); + ]; } protected function setUp() @@ -38,26 +38,25 @@ public function testBundleNotEnabled() $this->assertFalse($this->container->hasAlias('ezpublish_legacy.kernel')); } - /** - * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException - */ public function testWrongRootDir() { + $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); + $this->load( - array( + [ 'enabled' => true, 'root_dir' => '/some/inexistent/directory', - ) + ] ); } public function testDefaultConfigValues() { $this->load( - array( + [ 'enabled' => true, 'root_dir' => __DIR__, - ) + ] ); $this->assertContainerBuilderHasParameter('ezpublish_legacy.enabled', true); $this->assertContainerBuilderHasParameter('ezpublish_legacy.root_dir', __DIR__); @@ -73,31 +72,31 @@ public function testDefaultConfigValues() public function testViewLayout() { - ConfigurationProcessor::setAvailableSiteAccesses(array('sa1', 'sa2', 'sa3')); - $groupsBySiteAccess = array( - 'sa2' => array('sa_group'), - ); + ConfigurationProcessor::setAvailableSiteAccesses(['sa1', 'sa2', 'sa3']); + $groupsBySiteAccess = [ + 'sa2' => ['sa_group'], + ]; ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteAccess); $layoutSa1 = 'view_layout_for_sa1.html.twig'; $layoutSaGroup = 'view_layout_for_sa_group.html.twig'; $defaultLayout = 'EzPublishLegacyBundle::legacy_view_default_pagelayout.html.twig'; - $config = array( + $config = [ 'enabled' => true, 'root_dir' => __DIR__, - 'system' => array( - 'sa1' => array( - 'templating' => array( + 'system' => [ + 'sa1' => [ + 'templating' => [ 'view_layout' => $layoutSa1, - ), - ), - 'sa_group' => array( - 'templating' => array( + ], + ], + 'sa_group' => [ + 'templating' => [ 'view_layout' => $layoutSaGroup, - ), - ), - ), - ); + ], + ], + ], + ]; $this->load($config); $this->assertContainerBuilderHasParameter('ezpublish_legacy.default.view_default_layout', $defaultLayout); @@ -112,31 +111,31 @@ public function testViewLayout() public function testGlobalLayout() { - ConfigurationProcessor::setAvailableSiteAccesses(array('sa1', 'sa2', 'sa3')); - $groupsBySiteAccess = array( - 'sa2' => array('sa_group'), - ); + ConfigurationProcessor::setAvailableSiteAccesses(['sa1', 'sa2', 'sa3']); + $groupsBySiteAccess = [ + 'sa2' => ['sa_group'], + ]; ConfigurationProcessor::setGroupsBySiteAccess($groupsBySiteAccess); $layoutSa1 = 'module_layout_for_sa1.html.twig'; $layoutSaGroup = 'module_layout_for_sa_group.html.twig'; $defaultLayout = null; - $config = array( + $config = [ 'enabled' => true, 'root_dir' => __DIR__, - 'system' => array( - 'sa1' => array( - 'templating' => array( + 'system' => [ + 'sa1' => [ + 'templating' => [ 'module_layout' => $layoutSa1, - ), - ), - 'sa_group' => array( - 'templating' => array( + ], + ], + 'sa_group' => [ + 'templating' => [ 'module_layout' => $layoutSaGroup, - ), - ), - ), - ); + ], + ], + ], + ]; $this->load($config); $this->assertContainerBuilderHasParameter('ezpublish_legacy.default.module_default_layout', $defaultLayout); diff --git a/bundle/Tests/EventListener/ConfigScopeListenerTest.php b/bundle/Tests/EventListener/ConfigScopeListenerTest.php index 45be5619..b955bfaf 100644 --- a/bundle/Tests/EventListener/ConfigScopeListenerTest.php +++ b/bundle/Tests/EventListener/ConfigScopeListenerTest.php @@ -20,10 +20,10 @@ class ConfigScopeListenerTest extends TestCase public function testGetSubscribedEvents() { $this->assertSame( - array( + [ MVCEvents::CONFIG_SCOPE_CHANGE => 'onConfigScopeChange', MVCEvents::CONFIG_SCOPE_RESTORE => 'onConfigScopeChange', - ), + ], ConfigScopeListener::getSubscribedEvents() ); } diff --git a/bundle/Tests/EventListener/RequestListenerTest.php b/bundle/Tests/EventListener/RequestListenerTest.php index a64e5264..7832a53e 100644 --- a/bundle/Tests/EventListener/RequestListenerTest.php +++ b/bundle/Tests/EventListener/RequestListenerTest.php @@ -51,9 +51,9 @@ protected function setUp() public function testGetSubscribedEvents() { $this->assertSame( - array( + [ KernelEvents::REQUEST => 'onKernelRequest', - ), + ], Requestlistener::getSubscribedEvents() ); } diff --git a/bundle/Tests/EventListener/SetupListenerTest.php b/bundle/Tests/EventListener/SetupListenerTest.php index 6ad8f568..f6479084 100644 --- a/bundle/Tests/EventListener/SetupListenerTest.php +++ b/bundle/Tests/EventListener/SetupListenerTest.php @@ -33,11 +33,11 @@ protected function setUp() public function testSubscribedEvents() { $this->assertSame( - array( - KernelEvents::REQUEST => array( - array('onKernelRequestSetup', 190), - ), - ), + [ + KernelEvents::REQUEST => [ + ['onKernelRequestSetup', 190], + ], + ], $this->getListener()->getSubscribedEvents() ); } diff --git a/bundle/Tests/FieldType/Page/PageServiceTest.php b/bundle/Tests/FieldType/Page/PageServiceTest.php index 16309923..88a9066e 100644 --- a/bundle/Tests/FieldType/Page/PageServiceTest.php +++ b/bundle/Tests/FieldType/Page/PageServiceTest.php @@ -17,33 +17,33 @@ class PageServiceTest extends BaseTest protected function getZoneDefinition() { - return parent::getZoneDefinition() + array( - 'layoutLegacy1' => array( + return parent::getZoneDefinition() + [ + 'layoutLegacy1' => [ 'zoneTypeName' => 'Layout legacy 1', - 'zones' => array( - 'main' => array('name' => 'Global zone'), - ), + 'zones' => [ + 'main' => ['name' => 'Global zone'], + ], 'zoneThumbnail' => 'globalzone_layout.gif', 'template' => 'legacytemplate.tpl', - 'availableForClasses' => array('frontpage'), - ), - 'layoutLegacy2' => array( + 'availableForClasses' => ['frontpage'], + ], + 'layoutLegacy2' => [ 'zoneTypeName' => 'Layout legacy 2', - 'zones' => array( - 'main' => array('name' => 'Global zone'), - ), + 'zones' => [ + 'main' => ['name' => 'Global zone'], + ], 'zoneThumbnail' => 'globalzone_layout.gif', 'template' => 'design:foo/legacytemplate.tpl', - 'availableForClasses' => array('frontpage'), - ), - ); + 'availableForClasses' => ['frontpage'], + ], + ]; } public function getLayoutTemplateProvider() { - return parent::getLayoutTemplateProvider() + array( - array('layoutLegacy1', 'design:zone/legacytemplate.tpl'), - array('layoutLegacy2', 'design:zone/foo/legacytemplate.tpl'), - ); + return parent::getLayoutTemplateProvider() + [ + ['layoutLegacy1', 'design:zone/legacytemplate.tpl'], + ['layoutLegacy2', 'design:zone/foo/legacytemplate.tpl'], + ]; } } diff --git a/bundle/Tests/LegacyBundles/LegacyExtensionsLocatorTest.php b/bundle/Tests/LegacyBundles/LegacyExtensionsLocatorTest.php index 0cdd9b03..d212a116 100644 --- a/bundle/Tests/LegacyBundles/LegacyExtensionsLocatorTest.php +++ b/bundle/Tests/LegacyBundles/LegacyExtensionsLocatorTest.php @@ -29,10 +29,10 @@ public function testGetExtensionDirectories() $locator = new LegacyExtensionsLocator($this->vfsRoot); self::assertEquals( - array( + [ vfsStream::url('eZ/TestBundle/ezpublish_legacy/extension1'), vfsStream::url('eZ/TestBundle/ezpublish_legacy/extension2'), - ), + ], $locator->getExtensionDirectories(vfsStream::url('eZ/TestBundle/')) ); } @@ -42,7 +42,7 @@ public function testGetExtensionDirectoriesNoLegacy() $locator = new LegacyExtensionsLocator($this->vfsRoot); self::assertEquals( - array(), + [], $locator->getExtensionDirectories(vfsStream::url('No/Such/Bundle/')) ); } @@ -57,34 +57,34 @@ public function testGetExtensionsNames() $bundle->expects($this->once()) ->method('getLegacyExtensionsNames') - ->willReturn(array('extension3')); + ->willReturn(['extension3']); $locator = new LegacyExtensionsLocator($this->vfsRoot); self::assertEquals( - array( + [ 'extension1', 'extension2', 'extension3', - ), + ], $locator->getExtensionNames($bundle) ); } protected function initVfs() { - $structure = array( - 'eZ' => array( - 'TestBundle' => array( - 'ezpublish_legacy' => array( - 'extension1' => array('extension.xml' => ''), - 'extension2' => array('extension.xml' => ''), - 'not_extension' => array(), - ), - 'Resources' => array('config' => array()), - ), - ), - ); + $structure = [ + 'eZ' => [ + 'TestBundle' => [ + 'ezpublish_legacy' => [ + 'extension1' => ['extension.xml' => ''], + 'extension2' => ['extension.xml' => ''], + 'not_extension' => [], + ], + 'Resources' => ['config' => []], + ], + ], + ]; $this->vfsRoot = vfsStream::setup('_root_', null, $structure); } } diff --git a/bundle/Tests/LegacyMapper/SecurityTest.php b/bundle/Tests/LegacyMapper/SecurityTest.php index a4f374dd..c62a8c6a 100644 --- a/bundle/Tests/LegacyMapper/SecurityTest.php +++ b/bundle/Tests/LegacyMapper/SecurityTest.php @@ -62,10 +62,10 @@ protected function setUp() public function testGetSubscribedEvents() { $this->assertSame( - array( + [ LegacyEvents::POST_BUILD_LEGACY_KERNEL => 'onKernelBuilt', LegacyEvents::PRE_BUILD_LEGACY_KERNEL_WEB => 'onLegacyKernelWebBuild', - ), + ], Security::getSubscribedEvents() ); } @@ -75,7 +75,7 @@ public function testOnKernelBuiltNotWebBasedHandler() $kernelHandler = $this->createMock(ezpKernelHandler::class); $legacyKernel = $this ->getMockBuilder(Kernel::class) - ->setConstructorArgs(array($kernelHandler, 'foo', 'bar')) + ->setConstructorArgs([$kernelHandler, 'foo', 'bar']) ->getMock(); $event = new PostBuildKernelEvent($legacyKernel, $kernelHandler); @@ -95,7 +95,7 @@ public function testOnKernelBuiltWithLegacyMode() $kernelHandler = $this->createMock(ezpWebBasedKernelHandler::class); $legacyKernel = $this ->getMockBuilder(Kernel::class) - ->setConstructorArgs(array($kernelHandler, 'foo', 'bar')) + ->setConstructorArgs([$kernelHandler, 'foo', 'bar']) ->getMock(); $event = new PostBuildKernelEvent($legacyKernel, $kernelHandler); @@ -120,7 +120,7 @@ public function testOnKernelBuiltDisabled() $kernelHandler = $this->createMock(ezpWebBasedKernelHandler::class); $legacyKernel = $this ->getMockBuilder(Kernel::class) - ->setConstructorArgs(array($kernelHandler, 'foo', 'bar')) + ->setConstructorArgs([$kernelHandler, 'foo', 'bar']) ->getMock(); $event = new PostBuildKernelEvent($legacyKernel, $kernelHandler); @@ -141,7 +141,7 @@ public function testOnKerneBuiltNotAuthenticated() $kernelHandler = $this->createMock(ezpWebBasedKernelHandler::class); $legacyKernel = $this ->getMockBuilder(Kernel::class) - ->setConstructorArgs(array($kernelHandler, 'foo', 'bar')) + ->setConstructorArgs([$kernelHandler, 'foo', 'bar']) ->getMock(); $event = new PostBuildKernelEvent($legacyKernel, $kernelHandler); @@ -179,7 +179,7 @@ public function testOnKernelBuilt() $kernelHandler = $this->createMock(ezpWebBasedKernelHandler::class); $legacyKernel = $this ->getMockBuilder(Kernel::class) - ->setConstructorArgs(array($kernelHandler, 'foo', 'bar')) + ->setConstructorArgs([$kernelHandler, 'foo', 'bar']) ->getMock(); $event = new PostBuildKernelEvent($legacyKernel, $kernelHandler); @@ -228,14 +228,14 @@ private function generateUser($userId) $versionInfo ->expects($this->any()) ->method('getContentInfo') - ->will($this->returnValue(new ContentInfo(array('id' => $userId)))); + ->will($this->returnValue(new ContentInfo(['id' => $userId]))); $content = $this->getMockForAbstractClass(Content::class); $content ->expects($this->any()) ->method('getVersionInfo') ->will($this->returnValue($versionInfo)); - return new User(array('content' => $content)); + return new User(['content' => $content]); } public function testOnLegacyKernelWebBuildLegacyMode() @@ -246,7 +246,7 @@ public function testOnLegacyKernelWebBuildLegacyMode() ->with('legacy_mode') ->will($this->returnValue(true)); - $parameters = array('foo' => 'bar'); + $parameters = ['foo' => 'bar']; $event = new PreBuildKernelWebHandlerEvent(new ParameterBag($parameters), new Request()); $listener = new Security($this->repository, $this->configResolver, $this->tokenStorage, $this->authChecker); $listener->onLegacyKernelWebBuild($event); @@ -272,79 +272,79 @@ public function testOnLegacyKernelWebBuild(array $previousSettings, array $expec public function onLegacyKernelWebBuildProvider() { - return array( - array( - array(), - array( - 'injected-merge-settings' => array( - 'site.ini/SiteAccessRules/Rules' => array( + return [ + [ + [], + [ + 'injected-merge-settings' => [ + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;user/login', 'module;user/logout', - ), - ), - ), - ), - array( - array( + ], + ], + ], + ], + [ + [ 'foo' => 'bar', - 'some' => array('thing'), - ), - array( + 'some' => ['thing'], + ], + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'site.ini/SiteAccessRules/Rules' => array( + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;user/login', 'module;user/logout', - ), - ), - ), - ), - array( - array( + ], + ], + ], + ], + [ + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'Empire' => array('Darth Vader', 'Emperor', 'Moff Tarkin'), - 'Rebellion' => array('Luke Skywalker', 'Leïa Organa', 'Obi-Wan Kenobi', 'Han Solo'), + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'Empire' => ['Darth Vader', 'Emperor', 'Moff Tarkin'], + 'Rebellion' => ['Luke Skywalker', 'Leïa Organa', 'Obi-Wan Kenobi', 'Han Solo'], 'Chewbacca' => 'Arrrrrhhhhhh!', - ), - ), - array( + ], + ], + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'Empire' => array('Darth Vader', 'Emperor', 'Moff Tarkin'), - 'Rebellion' => array('Luke Skywalker', 'Leïa Organa', 'Obi-Wan Kenobi', 'Han Solo'), + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'Empire' => ['Darth Vader', 'Emperor', 'Moff Tarkin'], + 'Rebellion' => ['Luke Skywalker', 'Leïa Organa', 'Obi-Wan Kenobi', 'Han Solo'], 'Chewbacca' => 'Arrrrrhhhhhh!', - 'site.ini/SiteAccessRules/Rules' => array( + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;user/login', 'module;user/logout', - ), - ), - ), - ), - array( - array( + ], + ], + ], + ], + [ + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'site.ini/SiteAccessRules/Rules' => array( + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;ezinfo/about', 'access;enable', 'module;foo', - ), - ), - ), - array( + ], + ], + ], + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'site.ini/SiteAccessRules/Rules' => array( + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;ezinfo/about', 'access;enable', @@ -352,28 +352,28 @@ public function onLegacyKernelWebBuildProvider() 'access;disable', 'module;user/login', 'module;user/logout', - ), - ), - ), - ), - array( - array( + ], + ], + ], + ], + [ + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'site.ini/SiteAccessRules/Rules' => array( + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;ezinfo/about', 'access;enable', 'module;foo', - ), - ), - ), - array( + ], + ], + ], + [ 'foo' => 'bar', - 'some' => array('thing'), - 'injected-merge-settings' => array( - 'site.ini/SiteAccessRules/Rules' => array( + 'some' => ['thing'], + 'injected-merge-settings' => [ + 'site.ini/SiteAccessRules/Rules' => [ 'access;disable', 'module;ezinfo/about', 'access;enable', @@ -381,10 +381,10 @@ public function onLegacyKernelWebBuildProvider() 'access;disable', 'module;user/login', 'module;user/logout', - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; } } diff --git a/bundle/Tests/LegacyMapper/SessionTest.php b/bundle/Tests/LegacyMapper/SessionTest.php index 51621413..5e2fcd5a 100644 --- a/bundle/Tests/LegacyMapper/SessionTest.php +++ b/bundle/Tests/LegacyMapper/SessionTest.php @@ -47,7 +47,7 @@ protected function setUp() $this->session = $this->createMock(SessionInterface::class); $this->request = $this ->getMockBuilder(Request::class) - ->setMethods(array('hasPreviousSession')) + ->setMethods(['hasPreviousSession']) ->getMock(); $this->requestStack = new RequestStack(); $this->requestStack->push($this->request); @@ -56,9 +56,9 @@ protected function setUp() public function testGetSubscribedEvents() { $this->assertSame( - array( - LegacyEvents::PRE_BUILD_LEGACY_KERNEL => array('onBuildKernelHandler', 128), - ), + [ + LegacyEvents::PRE_BUILD_LEGACY_KERNEL => ['onBuildKernelHandler', 128], + ], SessionMapper::getSubscribedEvents() ); } @@ -70,23 +70,23 @@ public function testOnBuildKernelHandlerNoSession() $sessionMapper->onBuildKernelHandler($event); $this->assertSame( - array( - 'session' => array( + [ + 'session' => [ 'configured' => false, 'started' => false, 'name' => false, 'namespace' => false, 'has_previous' => false, 'storage' => false, - ), - 'injected-settings' => array( + ], + 'injected-settings' => [ 'site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false, - ), - ), + ], + ], $event->getParameters()->all() ); } @@ -115,34 +115,34 @@ public function testOnBuildKernelHandler($sessionName, $isStarted, $storageKey, $sessionMapper->onBuildKernelHandler($event); $this->assertSame( - array( - 'session' => array( + [ + 'session' => [ 'configured' => true, 'started' => $isStarted, 'name' => $sessionName, 'namespace' => $storageKey, 'has_previous' => $hasPreviousSession, 'storage' => $this->sessionStorage, - ), - 'injected-settings' => array( + ], + 'injected-settings' => [ 'site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false, - ), - ), + ], + ], $event->getParameters()->all() ); } public function buildKernelProvider() { - return array( - array('some_session_name', false, '_symfony', true), - array('my_session', true, '_symfony', false), - array('my_session', true, 'foobar', true), - array('eZSESSID', true, '_ezpublish', true), - ); + return [ + ['some_session_name', false, '_symfony', true], + ['my_session', true, '_symfony', false], + ['my_session', true, 'foobar', true], + ['eZSESSID', true, '_ezpublish', true], + ]; } } diff --git a/bundle/Tests/LegacyResponse/LegacyResponseManagerTest.php b/bundle/Tests/LegacyResponse/LegacyResponseManagerTest.php index 7a799219..dfbab4cd 100644 --- a/bundle/Tests/LegacyResponse/LegacyResponseManagerTest.php +++ b/bundle/Tests/LegacyResponse/LegacyResponseManagerTest.php @@ -53,23 +53,23 @@ public function testGenerateResponseAccessDenied($errorCode, $errorMessage) $manager = new LegacyResponseManager($this->templateEngine, $this->configResolver, new RequestStack()); $content = 'foobar'; - $moduleResult = array( + $moduleResult = [ 'content' => $content, 'errorCode' => $errorCode, 'errorMessage' => $errorMessage, - ); - $kernelResult = new ezpKernelResult($content, array('module_result' => $moduleResult)); + ]; + $kernelResult = new ezpKernelResult($content, ['module_result' => $moduleResult]); $manager->generateResponseFromModuleResult($kernelResult); } public function generateResponseAccessDeniedProvider() { - return array( - array('401', 'Unauthorized access'), - array('403', 'Forbidden'), - array('403', null), - array('401', null), - ); + return [ + ['401', 'Unauthorized access'], + ['403', 'Forbidden'], + ['403', null], + ['401', null], + ]; } /** @@ -85,10 +85,10 @@ public function testGenerateResponseNotFound($legacyMode, $notFoundHttpConversio ->method('getParameter') ->will( $this->returnValueMap( - array( - array('legacy_mode', null, null, $legacyMode), - array('not_found_http_conversion', 'ezpublish_legacy', null, $notFoundHttpConversion), - ) + [ + ['legacy_mode', null, null, $legacyMode], + ['not_found_http_conversion', 'ezpublish_legacy', null, $notFoundHttpConversion], + ] ) ); if ($expectException) { @@ -97,12 +97,12 @@ public function testGenerateResponseNotFound($legacyMode, $notFoundHttpConversio } $manager = new LegacyResponseManager($this->templateEngine, $this->configResolver, new RequestStack()); $content = 'foobar'; - $moduleResult = array( + $moduleResult = [ 'content' => $content, 'errorCode' => 404, 'errorMessage' => 'Not found', - ); - $kernelResult = new ezpKernelResult($content, array('module_result' => $moduleResult)); + ]; + $kernelResult = new ezpKernelResult($content, ['module_result' => $moduleResult]); $response = $manager->generateResponseFromModuleResult($kernelResult); if (!$expectException) { $this->assertSame($moduleResult['errorCode'], $response->getStatusCode()); @@ -111,11 +111,11 @@ public function testGenerateResponseNotFound($legacyMode, $notFoundHttpConversio public function generateResponseNotFoundProvider() { - return array( - array(true, true, false), - array(false, true, true), - array(false, false, false), - ); + return [ + [true, true, false], + [false, true, true], + [false, false, false], + ]; } public function testLegacyResultHasLayout() @@ -155,10 +155,10 @@ public function testGenerateResponseNoCustomLayout($customLayout, $legacyMode, $ ->method('getParameter') ->will( $this->returnValueMap( - array( - array('module_default_layout', 'ezpublish_legacy', null, $customLayout), - array('legacy_mode', null, null, $legacyMode), - ) + [ + ['module_default_layout', 'ezpublish_legacy', null, $customLayout], + ['legacy_mode', null, null, $legacyMode], + ] ) ); $this->templateEngine @@ -174,15 +174,15 @@ public function testGenerateResponseNoCustomLayout($customLayout, $legacyMode, $ $manager = new LegacyResponseManager($this->templateEngine, $this->configResolver, $requestStack); $content = 'foobar'; - $moduleResult = array( + $moduleResult = [ 'content' => $content, 'errorCode' => 200, - ); + ]; if ($moduleResultLayout) { $moduleResult['pagelayout'] = 'design:some_page_layout.tpl'; } - $kernelResult = new ezpKernelResult($content, array('module_result' => $moduleResult)); + $kernelResult = new ezpKernelResult($content, ['module_result' => $moduleResult]); $response = $manager->generateResponseFromModuleResult($kernelResult); $this->assertInstanceOf(LegacyResponse::class, $response); @@ -192,14 +192,14 @@ public function testGenerateResponseNoCustomLayout($customLayout, $legacyMode, $ public function generateResponseNoCustomLayoutProvider() { - return array( - array(null, false, false, false), - array('foo.html.twig', true, false, false), - array('foo.html.twig', false, true, false), - array(null, false, true, false), - array(null, true, true, false), - array(null, false, false, false, true), - ); + return [ + [null, false, false, false], + ['foo.html.twig', true, false, false], + ['foo.html.twig', false, true, false], + [null, false, true, false], + [null, true, true, false], + [null, false, false, false, true], + ]; } /** @@ -208,33 +208,33 @@ public function generateResponseNoCustomLayoutProvider() public function testGenerateResponseWithCustomLayout($customLayout, $content) { $contentWithLayout = "
$content
"; - $moduleResult = array( + $moduleResult = [ 'content' => $content, 'errorCode' => 200, - ); + ]; $this->configResolver ->expects($this->any()) ->method('getParameter') ->will( $this->returnValueMap( - array( - array('module_default_layout', 'ezpublish_legacy', null, $customLayout), - array('legacy_mode', null, null, false), - ) + [ + ['module_default_layout', 'ezpublish_legacy', null, $customLayout], + ['legacy_mode', null, null, false], + ] ) ); $this->templateEngine ->expects($this->once()) ->method('render') - ->with($customLayout, array('module_result' => $moduleResult)) + ->with($customLayout, ['module_result' => $moduleResult]) ->will($this->returnValue($contentWithLayout)); $requestStack = new RequestStack(); $requestStack->push(new Request()); $manager = new LegacyResponseManager($this->templateEngine, $this->configResolver, $requestStack); - $kernelResult = new ezpKernelResult($content, array('module_result' => $moduleResult)); + $kernelResult = new ezpKernelResult($content, ['module_result' => $moduleResult]); $response = $manager->generateResponseFromModuleResult($kernelResult); $this->assertInstanceOf(LegacyResponse::class, $response); @@ -245,15 +245,15 @@ public function testGenerateResponseWithCustomLayout($customLayout, $content) public function generateResponseWithCustomLayoutProvider() { - return array( - array('foo.html.twig', 'Hello world!'), - array('foo.html.twig', 'שלום עולם!'), - array('bar.html.twig', 'こんにちは、世界'), - array('i_am_a_custom_layout.html.twig', 'Know what? I\'m a legacy content!'), - array('custom.twig', 'I love content management.'), - array('custom.twig', '私は、コンテンツ管理が大好きです。'), - array('custom.twig', 'אני אוהב את ניהול תוכן.'), - ); + return [ + ['foo.html.twig', 'Hello world!'], + ['foo.html.twig', 'שלום עולם!'], + ['bar.html.twig', 'こんにちは、世界'], + ['i_am_a_custom_layout.html.twig', 'Know what? I\'m a legacy content!'], + ['custom.twig', 'I love content management.'], + ['custom.twig', '私は、コンテンツ管理が大好きです。'], + ['custom.twig', 'אני אוהב את ניהול תוכן.'], + ]; } /** @@ -272,12 +272,12 @@ public function testGenerateRedirectResponse($uri, $redirectStatus, $expectedSta public function generateRedirectResponseProvider() { - return array( - array('/foo', null, 302, null), - array('/foo', '302', 302, 'bar'), - array('/foo/bar', '301: blablabla', 301, 'Hello world!'), - array('/foo/bar?some=thing&toto=titi', '303: See other', 303, 'こんにちは、世界!'), - ); + return [ + ['/foo', null, 302, null], + ['/foo', '302', 302, 'bar'], + ['/foo/bar', '301: blablabla', 301, 'Hello world!'], + ['/foo/bar?some=thing&toto=titi', '303: See other', 303, 'こんにちは、世界!'], + ]; } public function testMapHeaders() @@ -285,15 +285,15 @@ public function testMapHeaders() $etag = '86fb269d190d2c85f6e0468ceca42a20'; $date = new DateTime(); $dateForCache = $date->format('D, d M Y H:i:s') . ' GMT'; - $headers = array('X-Foo: Bar', "Etag: $etag", "Last-Modified: $dateForCache", "Expires: $dateForCache"); + $headers = ['X-Foo: Bar', "Etag: $etag", "Last-Modified: $dateForCache", "Expires: $dateForCache"]; // Partially mock the manager to simulate calls to header_remove() $manager = $this->getMockBuilder(LegacyResponseManager::class) - ->setConstructorArgs(array($this->templateEngine, $this->configResolver, new RequestStack())) - ->setMethods(array('removeHeader')) + ->setConstructorArgs([$this->templateEngine, $this->configResolver, new RequestStack()]) + ->setMethods(['removeHeader']) ->getMock(); $manager - ->expects($this->exactly(count($headers))) + ->expects($this->exactly(\count($headers))) ->method('removeHeader'); /** @var \eZ\Bundle\EzPublishLegacyBundle\LegacyResponse\LegacyResponseManager|\PHPUnit_Framework_MockObject_MockObject $manager */ $response = new LegacyResponse(); @@ -308,11 +308,11 @@ public function testMapHeaders() public function testEmptyHeaderValueShouldNotRaiseNotice() { $manager = $this->getMockBuilder(LegacyResponseManager::class) - ->setConstructorArgs(array($this->templateEngine, $this->configResolver, new RequestStack())) - ->setMethods(array('removeHeader')) + ->setConstructorArgs([$this->templateEngine, $this->configResolver, new RequestStack()]) + ->setMethods(['removeHeader']) ->getMock(); /** @var \eZ\Bundle\EzPublishLegacyBundle\LegacyResponse\LegacyResponseManager|\PHPUnit_Framework_MockObject_MockObject $manager */ - $headers = array('X-Foo: Bar', 'Pragma:'); + $headers = ['X-Foo: Bar', 'Pragma:']; $response = new LegacyResponse(); $manager->mapHeaders($headers, $response); diff --git a/bundle/Tests/Routing/DefaultRouterTest.php b/bundle/Tests/Routing/DefaultRouterTest.php index 77e6068b..8793ce6e 100644 --- a/bundle/Tests/Routing/DefaultRouterTest.php +++ b/bundle/Tests/Routing/DefaultRouterTest.php @@ -19,18 +19,17 @@ protected function getRouterClass() return DefaultRouter::class; } - /** - * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException - */ public function testMatchRequestLegacyMode() { + $this->expectException(\Symfony\Component\Routing\Exception\ResourceNotFoundException::class); + $pathinfo = '/siteaccess/foo/bar'; $semanticPathinfo = '/foo/bar'; $request = Request::create($pathinfo); $request->attributes->set('semanticPathinfo', $semanticPathinfo); /** @var \PHPUnit_Framework_MockObject_MockObject|\eZ\Bundle\EzPublishLegacyBundle\Routing\DefaultRouter $router */ - $router = $this->generateRouter(array('match')); + $router = $this->generateRouter(['match']); $this->configResolver ->expects($this->once()) @@ -38,7 +37,7 @@ public function testMatchRequestLegacyMode() ->with('legacy_mode') ->will($this->returnValue(true)); - $matchedParameters = array('_route' => 'my_route'); + $matchedParameters = ['_route' => 'my_route']; $router ->expects($this->once()) ->method('match') @@ -56,10 +55,10 @@ public function testMatchRequestLegacyModeAuthorizedRoute() $request->attributes->set('semanticPathinfo', $semanticPathinfo); /** @var \PHPUnit_Framework_MockObject_MockObject|\eZ\Bundle\EzPublishLegacyBundle\Routing\DefaultRouter $router */ - $router = $this->generateRouter(array('match')); - $router->setLegacyAwareRoutes(array('my_legacy_aware_route')); + $router = $this->generateRouter(['match']); + $router->setLegacyAwareRoutes(['my_legacy_aware_route']); - $matchedParameters = array('_route' => 'my_legacy_aware_route'); + $matchedParameters = ['_route' => 'my_legacy_aware_route']; $router ->expects($this->once()) ->method('match') diff --git a/bundle/Tests/SetupWizard/ConfigurationConverterTest.php b/bundle/Tests/SetupWizard/ConfigurationConverterTest.php index edb21315..fc3964a2 100644 --- a/bundle/Tests/SetupWizard/ConfigurationConverterTest.php +++ b/bundle/Tests/SetupWizard/ConfigurationConverterTest.php @@ -43,11 +43,11 @@ protected function getConfigurationConverterMock(array $constructorParams) public function testFromLegacy($package, $adminSiteaccess, $mockParameters, $expectedResult, $exception = null) { $configurationConverter = $this->getConfigurationConverterMock( - array( + [ $this->getLegacyConfigResolverMock(), $this->getLegacyKernelMock(), - array($package), - ) + [$package], + ] ); foreach ($mockParameters as $method => $callbackMap) { $configurationConverter->expects($this->any()) @@ -86,187 +86,187 @@ public function testFromLegacy($package, $adminSiteaccess, $mockParameters, $exp */ protected function convertMapToCallback($callbackMap) { - return function () use ($callbackMap) { + return static function () use ($callbackMap) { foreach ($callbackMap as $map) { - $mapArguments = array_slice($map, 0, -1); + $mapArguments = \array_slice($map, 0, -1); // pad the call arguments array with nulls to match the map - $callArguments = array_pad(func_get_args(), count($mapArguments), null); + $callArguments = array_pad(\func_get_args(), \count($mapArguments), null); - if (count(array_diff($callArguments, $mapArguments)) == 0) { - $return = $map[count($map) - 1]; - if (is_callable($return)) { + if (\count(array_diff($callArguments, $mapArguments)) == 0) { + $return = $map[\count($map) - 1]; + if (\is_callable($return)) { return $return(); } else { return $return; } } } - throw new \Exception('No callback match found for ' . var_export(func_get_args(), true)); + throw new \Exception('No callback match found for ' . var_export(\func_get_args(), true)); }; } public function providerForTestFromLegacy() { - define('IDX_PACKAGE', 0); - define('IDX_ADMIN_SITEACCESS', 1); - define('IDX_MOCK_PARAMETERS', 2); - define('IDX_EXPECTED_RESULT', 3); - define('IDX_EXCEPTION', 4); - - $commonResult = array( - 'doctrine' => array( - 'dbal' => array( - 'connections' => array( - 'eng_repository_connection' => array( + \define('IDX_PACKAGE', 0); + \define('IDX_ADMIN_SITEACCESS', 1); + \define('IDX_MOCK_PARAMETERS', 2); + \define('IDX_EXPECTED_RESULT', 3); + \define('IDX_EXCEPTION', 4); + + $commonResult = [ + 'doctrine' => [ + 'dbal' => [ + 'connections' => [ + 'eng_repository_connection' => [ 'driver' => 'pdo_mysql', 'user' => 'root', 'password' => null, 'host' => 'localhost', 'dbname' => 'ezdemo', 'charset' => 'UTF8', - ), - ), - ), - ), - 'ez_publish_legacy' => array( + ], + ], + ], + ], + 'ez_publish_legacy' => [ 'enabled' => true, - 'system' => array( - 'ezdemo_site_admin' => array( + 'system' => [ + 'ezdemo_site_admin' => [ 'legacy_mode' => true, - ), - ), - ), - 'ezpublish' => array( - 'repositories' => array( - 'eng_repository' => array('engine' => 'legacy', 'connection' => 'eng_repository_connection'), - ), - 'siteaccess' => array( + ], + ], + ], + 'ezpublish' => [ + 'repositories' => [ + 'eng_repository' => ['engine' => 'legacy', 'connection' => 'eng_repository_connection'], + ], + 'siteaccess' => [ 'default_siteaccess' => 'eng', - 'list' => array( + 'list' => [ 0 => 'eng', 1 => 'ezdemo_site', 2 => 'ezdemo_site_admin', - ), - 'groups' => array( - 'ezdemo_group' => array( + ], + 'groups' => [ + 'ezdemo_group' => [ 0 => 'eng', 1 => 'ezdemo_site', 2 => 'ezdemo_site_admin', - ), - ), - 'match' => array('URIElement' => 1), - ), - 'system' => array( - 'ezdemo_group' => array( + ], + ], + 'match' => ['URIElement' => 1], + ], + 'system' => [ + 'ezdemo_group' => [ 'repository' => 'eng_repository', 'var_dir' => 'var/ezdemo_site', - 'languages' => array('eng-GB'), - ), - 'eng' => array(), - 'ezdemo_site_admin' => array(), - ), + 'languages' => ['eng-GB'], + ], + 'eng' => [], + 'ezdemo_site_admin' => [], + ], - 'imagemagick' => array( + 'imagemagick' => [ 'enabled' => true, 'path' => '/usr/bin/convert', - ), - ), - 'stash' => array( - 'caches' => array( - 'default' => array( - 'drivers' => array('FileSystem'), // If this fails then APC or Memcached is enabled on PHP-CLI + ], + ], + 'stash' => [ + 'caches' => [ + 'default' => [ + 'drivers' => ['FileSystem'], // If this fails then APC or Memcached is enabled on PHP-CLI 'inMemory' => true, 'registerDoctrineAdapter' => false, - ), - ), - ), - ); + ], + ], + ], + ]; $exceptionType = InvalidArgumentException::class; - $commonMockParameters = array( - 'getParameter' => array( - 'SiteSettingsDefaultAccess' => array('SiteSettings', 'DefaultAccess', null, null, 'eng'), - 'SiteAccessSettingsAvailableSiteAccessList' => array('SiteAccessSettings', 'AvailableSiteAccessList', null, null, array('eng', 'ezdemo_site', 'ezdemo_site_admin')), - 'FileSettingsVarDir' => array('FileSettings', 'VarDir', 'site.ini', 'eng', 'var/ezdemo_site'), - 'FileSettingsStorageDir' => array('FileSettings', 'StorageDir', 'site.ini', 'eng', 'storage'), - 'ImageMagickIsEnabled' => array('ImageMagick', 'IsEnabled', 'image.ini', 'eng', 'true'), - 'ImageMagickExecutablePath' => array('ImageMagick', 'ExecutablePath', 'image.ini', 'eng', '/usr/bin'), - 'ImageMagickExecutable' => array('ImageMagick', 'Executable', 'image.ini', 'eng', 'convert'), - 'Languages_eng' => array('RegionalSettings', 'SiteLanguageList', 'site.ini', 'eng', array('eng-GB')), - 'Languages_demo' => array('RegionalSettings', 'SiteLanguageList', 'site.ini', 'ezdemo_site', array('eng-GB')), - 'Languages_admin' => array('RegionalSettings', 'SiteLanguageList', 'site.ini', 'ezdemo_site_admin', array('eng-GB')), - 'SessionNameHandler_eng' => array('Session', 'SessionNameHandler', 'site.ini', 'eng', 'default'), - 'SessionNameHandler_demo' => array('Session', 'SessionNameHandler', 'site.ini', 'ezdemo_site', 'default'), - 'SessionNameHandler_admin' => array('Session', 'SessionNameHandler', 'site.ini', 'ezdemo_site_admin', 'default'), - 'SessionName' => array('Session', 'SessionNamePrefix', 'site.ini', null, 'eZSESSID'), - ), - 'getGroup' => array( - 'SiteAccessSettings' => array( + $commonMockParameters = [ + 'getParameter' => [ + 'SiteSettingsDefaultAccess' => ['SiteSettings', 'DefaultAccess', null, null, 'eng'], + 'SiteAccessSettingsAvailableSiteAccessList' => ['SiteAccessSettings', 'AvailableSiteAccessList', null, null, ['eng', 'ezdemo_site', 'ezdemo_site_admin']], + 'FileSettingsVarDir' => ['FileSettings', 'VarDir', 'site.ini', 'eng', 'var/ezdemo_site'], + 'FileSettingsStorageDir' => ['FileSettings', 'StorageDir', 'site.ini', 'eng', 'storage'], + 'ImageMagickIsEnabled' => ['ImageMagick', 'IsEnabled', 'image.ini', 'eng', 'true'], + 'ImageMagickExecutablePath' => ['ImageMagick', 'ExecutablePath', 'image.ini', 'eng', '/usr/bin'], + 'ImageMagickExecutable' => ['ImageMagick', 'Executable', 'image.ini', 'eng', 'convert'], + 'Languages_eng' => ['RegionalSettings', 'SiteLanguageList', 'site.ini', 'eng', ['eng-GB']], + 'Languages_demo' => ['RegionalSettings', 'SiteLanguageList', 'site.ini', 'ezdemo_site', ['eng-GB']], + 'Languages_admin' => ['RegionalSettings', 'SiteLanguageList', 'site.ini', 'ezdemo_site_admin', ['eng-GB']], + 'SessionNameHandler_eng' => ['Session', 'SessionNameHandler', 'site.ini', 'eng', 'default'], + 'SessionNameHandler_demo' => ['Session', 'SessionNameHandler', 'site.ini', 'ezdemo_site', 'default'], + 'SessionNameHandler_admin' => ['Session', 'SessionNameHandler', 'site.ini', 'ezdemo_site_admin', 'default'], + 'SessionName' => ['Session', 'SessionNamePrefix', 'site.ini', null, 'eZSESSID'], + ], + 'getGroup' => [ + 'SiteAccessSettings' => [ 'SiteAccessSettings', null, null, - array('MatchOrder' => 'uri', 'URIMatchType' => 'element', 'URIMatchElement' => 1), - ), - 'DatabaseSettings' => array( + ['MatchOrder' => 'uri', 'URIMatchType' => 'element', 'URIMatchElement' => 1], + ], + 'DatabaseSettings' => [ 'DatabaseSettings', 'site.ini', 'eng', - array('DatabaseImplementation' => 'ezmysqli', 'Server' => 'localhost', 'User' => 'root', 'Password' => '', 'Database' => 'ezdemo'), - ), - 'AliasSettings' => array( + ['DatabaseImplementation' => 'ezmysqli', 'Server' => 'localhost', 'User' => 'root', 'Password' => '', 'Database' => 'ezdemo'], + ], + 'AliasSettings' => [ 'AliasSettings', 'image.ini', 'eng', - array('AliasList' => array('large', 'infoboximage')), - ), - 'AliasSettings_demo' => array( + ['AliasList' => ['large', 'infoboximage']], + ], + 'AliasSettings_demo' => [ 'AliasSettings', 'image.ini', 'ezdemo_site', - array('AliasList' => array('large', 'infoboximage')), - ), - 'AliasSettings_admin' => array( + ['AliasList' => ['large', 'infoboximage']], + ], + 'AliasSettings_admin' => [ 'AliasSettings', 'image.ini', 'ezdemo_site_admin', - array('AliasList' => array('large', 'infoboximage')), - ), - 'large' => array( + ['AliasList' => ['large', 'infoboximage']], + ], + 'large' => [ 'large', 'image.ini', 'eng', - array('Reference' => '', 'Filters' => array('geometry/scaledownonly=360;440')), - ), - 'infoboximage' => array( + ['Reference' => '', 'Filters' => ['geometry/scaledownonly=360;440']], + ], + 'infoboximage' => [ 'infoboximage', 'image.ini', 'eng', - array('Reference' => '', 'Filters' => array('geometry/scalewidth=75', 'flatten')), - ), - 'large_demo' => array( + ['Reference' => '', 'Filters' => ['geometry/scalewidth=75', 'flatten']], + ], + 'large_demo' => [ 'large', 'image.ini', 'ezdemo_site', - array('Reference' => '', 'Filters' => array('geometry/scaledownonly=360;440')), - ), - 'infoboximage_demo' => array( + ['Reference' => '', 'Filters' => ['geometry/scaledownonly=360;440']], + ], + 'infoboximage_demo' => [ 'infoboximage', 'image.ini', 'ezdemo_site', - array('Reference' => '', 'Filters' => array('geometry/scalewidth=75', 'flatten')), - ), - 'large_admin' => array( + ['Reference' => '', 'Filters' => ['geometry/scalewidth=75', 'flatten']], + ], + 'large_admin' => [ 'large', 'image.ini', 'ezdemo_site_admin', - array('Reference' => '', 'Filters' => array('geometry/scaledownonly=360;440')), - ), - 'infoboximage_admin' => array( + ['Reference' => '', 'Filters' => ['geometry/scaledownonly=360;440']], + ], + 'infoboximage_admin' => [ 'infoboximage', 'image.ini', 'ezdemo_site_admin', - array('Reference' => '', 'Filters' => array('geometry/scalewidth=75', 'flatten')), - ), - 'ImageMagick' => array( + ['Reference' => '', 'Filters' => ['geometry/scalewidth=75', 'flatten']], + ], + 'ImageMagick' => [ 'ImageMagick', 'image.ini', 'eng', - array('Filters' => array('geometry/scale=-geometry %1x%2', 'geometry/scalewidth=-geometry %1')), - ), - ), - ); + ['Filters' => ['geometry/scale=-geometry %1x%2', 'geometry/scalewidth=-geometry %1']], + ], + ], + ]; - $baseData = array('ezdemo', 'ezdemo_site_admin', $commonMockParameters, $commonResult); + $baseData = ['ezdemo', 'ezdemo_site_admin', $commonMockParameters, $commonResult]; - $data = array(); + $data = []; $data[] = $baseData; // empty site list => invalid argument exception $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['SiteSettingsSiteList'] = array('SiteSettings', 'SiteList', null, null, array()); + $element[IDX_MOCK_PARAMETERS]['getParameter']['SiteSettingsSiteList'] = ['SiteSettings', 'SiteList', null, null, []]; $element[IDX_EXCEPTION] = $exceptionType; $data[] = $element; // imagemagick disabled $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['ImageMagickIsEnabled'] = array('ImageMagick', 'IsEnabled', 'eng', 'image.ini', 'false'); + $element[IDX_MOCK_PARAMETERS]['getParameter']['ImageMagickIsEnabled'] = ['ImageMagick', 'IsEnabled', 'eng', 'image.ini', 'false']; $element[IDX_EXPECTED_RESULT]['ezpublish']['imagemagick']['enabled'] = false; unset($element[IDX_EXPECTED_RESULT]['ezpublish']['imagemagick']['path']); unset($element[IDX_EXPECTED_RESULT]['ezpublish']['imagemagick']['filters']); @@ -280,35 +280,35 @@ public function providerForTestFromLegacy() // host match, with map $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getGroup']['SiteAccessSettings'] = array( - 'SiteAccessSettings', null, null, array( + $element[IDX_MOCK_PARAMETERS]['getGroup']['SiteAccessSettings'] = [ + 'SiteAccessSettings', null, null, [ 'MatchOrder' => 'host', 'HostMatchType' => 'map', - 'HostMatchMapItems' => array('site.com;eng', 'admin.site.com;ezdemo_site_admin'), - ), - ); - $element[IDX_EXPECTED_RESULT]['ezpublish']['siteaccess']['match'] = array( - 'Map\\Host' => array('site.com' => 'eng', 'admin.site.com' => 'ezdemo_site_admin'), - ); + 'HostMatchMapItems' => ['site.com;eng', 'admin.site.com;ezdemo_site_admin'], + ], + ]; + $element[IDX_EXPECTED_RESULT]['ezpublish']['siteaccess']['match'] = [ + 'Map\\Host' => ['site.com' => 'eng', 'admin.site.com' => 'ezdemo_site_admin'], + ]; $data[] = $element; // host match, with map $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getGroup']['SiteAccessSettings'] = array( - 'SiteAccessSettings', null, null, array( + $element[IDX_MOCK_PARAMETERS]['getGroup']['SiteAccessSettings'] = [ + 'SiteAccessSettings', null, null, [ 'MatchOrder' => 'host', 'HostMatchType' => 'map', - 'HostMatchMapItems' => array('site.com;eng', 'admin.site.com;ezdemo_site_admin'), - ), - ); - $element[IDX_EXPECTED_RESULT]['ezpublish']['siteaccess']['match'] = array( - 'Map\\Host' => array('site.com' => 'eng', 'admin.site.com' => 'ezdemo_site_admin'), - ); + 'HostMatchMapItems' => ['site.com;eng', 'admin.site.com;ezdemo_site_admin'], + ], + ]; + $element[IDX_EXPECTED_RESULT]['ezpublish']['siteaccess']['match'] = [ + 'Map\\Host' => ['site.com' => 'eng', 'admin.site.com' => 'ezdemo_site_admin'], + ]; $data[] = $element; // customized storage dir $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['FileSettingsStorageDir'] = array('FileSettings', 'StorageDir', 'site.ini', 'eng', 'customstorage'); + $element[IDX_MOCK_PARAMETERS]['getParameter']['FileSettingsStorageDir'] = ['FileSettings', 'StorageDir', 'site.ini', 'eng', 'customstorage']; $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_group']['storage_dir'] = 'customstorage'; $data[] = $element; @@ -321,12 +321,12 @@ public function providerForTestFromLegacy() // different alias list for ezdemo_site_admin // each siteaccess has its own variations list $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getGroup']['AliasSettings_admin'] = array( + $element[IDX_MOCK_PARAMETERS]['getGroup']['AliasSettings_admin'] = [ 'AliasSettings', 'image.ini', 'ezdemo_site_admin', - array( - 'AliasList' => array('large'), - ), - ); + [ + 'AliasList' => ['large'], + ], + ]; unset($element[IDX_MOCK_PARAMETERS]['getGroup']['infoboximage_admin']); $data[] = $element; @@ -334,36 +334,36 @@ public function providerForTestFromLegacy() // different parameter for an alias in ezdemo_site_admin // each siteaccess has its own variations list $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getGroup']['large_admin'] = array( + $element[IDX_MOCK_PARAMETERS]['getGroup']['large_admin'] = [ 'large', 'image.ini', 'ezdemo_site_admin', - array( + [ 'Reference' => '', - 'Filters' => array('geometry/scaledownonly=100;100'), - ), - ); + 'Filters' => ['geometry/scaledownonly=100;100'], + ], + ]; $data[] = $element; // several languages and same for all SA // still only a languages setting in ezdemo_group $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_eng'][4] = array('eng-GB', 'fre-FR'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_demo'][4] = array('eng-GB', 'fre-FR'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_admin'][4] = array('eng-GB', 'fre-FR'); + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_eng'][4] = ['eng-GB', 'fre-FR']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_demo'][4] = ['eng-GB', 'fre-FR']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_admin'][4] = ['eng-GB', 'fre-FR']; - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_group']['languages'] = array('eng-GB', 'fre-FR'); + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_group']['languages'] = ['eng-GB', 'fre-FR']; $data[] = $element; // several languages and same list for all SA but not the same order // no more languages setting in ezdemo_group, one by SA $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_eng'][4] = array('eng-GB', 'fre-FR'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_demo'][4] = array('fre-FR', 'eng-GB'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_admin'][4] = array('eng-GB', 'fre-FR'); + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_eng'][4] = ['eng-GB', 'fre-FR']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_demo'][4] = ['fre-FR', 'eng-GB']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_admin'][4] = ['eng-GB', 'fre-FR']; - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['eng']['languages'] = array('eng-GB', 'fre-FR'); - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site']['languages'] = array('fre-FR', 'eng-GB'); - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site_admin']['languages'] = array('eng-GB', 'fre-FR'); + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['eng']['languages'] = ['eng-GB', 'fre-FR']; + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site']['languages'] = ['fre-FR', 'eng-GB']; + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site_admin']['languages'] = ['eng-GB', 'fre-FR']; unset($element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_group']['languages']); $data[] = $element; @@ -371,24 +371,24 @@ public function providerForTestFromLegacy() // several languages and different lists for each SA // no more languages setting in ezdemo_group, one by SA $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_eng'][4] = array('eng-GB', 'fre-FR'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_demo'][4] = array('Entish', 'Valarin', 'Elvish'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_admin'][4] = array('Khuzdul', 'Sindarin'); + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_eng'][4] = ['eng-GB', 'fre-FR']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_demo'][4] = ['Entish', 'Valarin', 'Elvish']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['Languages_admin'][4] = ['Khuzdul', 'Sindarin']; - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['eng']['languages'] = array('eng-GB', 'fre-FR'); - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site']['languages'] = array('Entish', 'Valarin', 'Elvish'); - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site_admin']['languages'] = array('Khuzdul', 'Sindarin'); + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['eng']['languages'] = ['eng-GB', 'fre-FR']; + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site']['languages'] = ['Entish', 'Valarin', 'Elvish']; + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site_admin']['languages'] = ['Khuzdul', 'Sindarin']; unset($element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_group']['languages']); $data[] = $element; // session name $element = $baseData; - $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNameHandler_eng'] = array('Session', 'SessionNameHandler', 'site.ini', 'eng', 'custom'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNameHandler_demo'] = array('Session', 'SessionNameHandler', 'site.ini', 'ezdemo_site', 'custom'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNamePerSiteAccess_eng'] = array('Session', 'SessionNamePerSiteAccess', 'site.ini', 'eng', 'enabled'); - $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNamePerSiteAccess_demo'] = array('Session', 'SessionNamePerSiteAccess', 'site.ini', 'ezdemo_site', 'disabled'); - $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site']['session'] = array('name' => 'eZSESSID'); + $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNameHandler_eng'] = ['Session', 'SessionNameHandler', 'site.ini', 'eng', 'custom']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNameHandler_demo'] = ['Session', 'SessionNameHandler', 'site.ini', 'ezdemo_site', 'custom']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNamePerSiteAccess_eng'] = ['Session', 'SessionNamePerSiteAccess', 'site.ini', 'eng', 'enabled']; + $element[IDX_MOCK_PARAMETERS]['getParameter']['SessionNamePerSiteAccess_demo'] = ['Session', 'SessionNamePerSiteAccess', 'site.ini', 'ezdemo_site', 'disabled']; + $element[IDX_EXPECTED_RESULT]['ezpublish']['system']['ezdemo_site']['session'] = ['name' => 'eZSESSID']; $data[] = $element; return $data; @@ -399,11 +399,11 @@ public function providerForTestFromLegacy() * * @return \PHPUnit_Framework_MockObject_MockObject|\eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Configuration\LegacyConfigResolver */ - protected function getLegacyConfigResolverMock(array $methodsToMock = array()) + protected function getLegacyConfigResolverMock(array $methodsToMock = []) { $mock = $this ->getMockBuilder(LegacyConfigResolver::class) - ->setMethods(array_merge($methodsToMock, array('getParameter', 'getGroup'))) + ->setMethods(array_merge($methodsToMock, ['getParameter', 'getGroup'])) ->disableOriginalConstructor() ->getMock(); @@ -421,7 +421,7 @@ protected function getLegacyKernelMock() ->method('runCallback') ->will($this->returnValue(ezpKernelResult::class)); - $closureMock = function () use ($legacyKernelMock) { + $closureMock = static function () use ($legacyKernelMock) { return $legacyKernelMock; }; diff --git a/bundle/Tests/SetupWizard/ConfigurationDumperTest.php b/bundle/Tests/SetupWizard/ConfigurationDumperTest.php index 7aac7523..45078511 100644 --- a/bundle/Tests/SetupWizard/ConfigurationDumperTest.php +++ b/bundle/Tests/SetupWizard/ConfigurationDumperTest.php @@ -37,7 +37,7 @@ protected function setUp() $this->cacheDir = __DIR__ . '/cache'; $this->configDir = __DIR__ . '/config'; @mkdir($this->configDir); - $this->envs = array('dev', 'prod'); + $this->envs = ['dev', 'prod']; } protected function tearDown() @@ -62,33 +62,33 @@ private function expectsCacheClear() public function dumpProvider() { - return array( - array( - array( + return [ + [ + [ 'foo' => 'bar', 'baz' => null, 'flag' => true, - 'myArray' => array(1, 2, 3), - 'myHash' => array('this' => 'that', 'these' => 'those'), - ), - ), - array( - array( + 'myArray' => [1, 2, 3], + 'myHash' => ['this' => 'that', 'these' => 'those'], + ], + ], + [ + [ 'foo' => 'bar', 'flag' => true, - 'someArray' => array(1, 2, 3), - 'nestedArray' => array( - 'anotherArray' => array('one', 'two', 'three'), - 'anotherHash' => array( + 'someArray' => [1, 2, 3], + 'nestedArray' => [ + 'anotherArray' => ['one', 'two', 'three'], + 'anotherHash' => [ 'someKey' => 123, 'anotherFlag' => false, 'nullValue' => null, - 'emptyArray' => array(), - ), - ), - ), - ), - ); + 'emptyArray' => [], + ], + ], + ], + ], + ]; } private function assertConfigFileValid(array $configArray) @@ -98,13 +98,13 @@ private function assertConfigFileValid(array $configArray) $this->assertEquals($configArray, Yaml::parse(file_get_contents($configFile))); } - private function assertEnvConfigFilesValid(array $configArray = array()) + private function assertEnvConfigFilesValid(array $configArray = []) { $configArray = array_merge_recursive( $configArray, - array( - 'imports' => array(array('resource' => 'ezpublish.yml')), - ) + [ + 'imports' => [['resource' => 'ezpublish.yml']], + ] ); foreach ($this->envs as $env) { @@ -161,7 +161,7 @@ public function testDumpBackupFile(array $configArray) private function expectBackup() { $this->fs - ->expects($this->exactly(count($this->envs) + 1)) + ->expects($this->exactly(\count($this->envs) + 1)) ->method('copy') ->with( $this->logicalAnd( diff --git a/bundle/Tests/SiteAccess/LegacyMapperTest.php b/bundle/Tests/SiteAccess/LegacyMapperTest.php index cbf5eb8b..8277baf9 100644 --- a/bundle/Tests/SiteAccess/LegacyMapperTest.php +++ b/bundle/Tests/SiteAccess/LegacyMapperTest.php @@ -100,246 +100,246 @@ public function testOnSiteAccessMatchUriPart($pathinfo, $semanticPathinfo, $view public function siteAccessMatchProvider() { // args: $pathinfo, $semanticPathinfo, $siteaccess, $expectedAccess - return array( - array( + return [ + [ '/some/pathinfo', '/some/pathinfo', new SiteAccess('foo', 'default'), - array( + [ 'name' => 'foo', 'type' => 1, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/some%C3%BCtf/path', '/someütf/path', new SiteAccess('foo', 'default'), - array( + [ 'name' => 'foo', 'type' => 1, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/env/matching', '/env/matching', new SiteAccess('foo', 'env'), - array( + [ 'name' => 'foo', 'type' => 7, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/urimap/matching', '/urimap/matching', new SiteAccess('foo', 'uri:map'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/foo/urimap/matching', '/urimap/matching', new SiteAccess('foo', 'uri:map'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo'), - ), - ), - array( + 'uri_part' => ['foo'], + ], + ], + [ '/foo/', '/', new SiteAccess('foo', 'uri:map'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo'), - ), - ), - array( + 'uri_part' => ['foo'], + ], + ], + [ '/foo', '/', new SiteAccess('foo', 'uri:map'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo'), - ), - ), - array( + 'uri_part' => ['foo'], + ], + ], + [ '/urielement/matching', '/urielement/matching', new SiteAccess('foo', 'uri:element'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/foo/bar/urielement/matching', '/urielement/matching', new SiteAccess('foo', 'uri:element'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo', 'bar'), - ), - ), - array( + 'uri_part' => ['foo', 'bar'], + ], + ], + [ '/foo/bar/baz/urielement/matching', '/urielement/matching', new SiteAccess('foo', 'uri:element'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo', 'bar', 'baz'), - ), - ), - array( + 'uri_part' => ['foo', 'bar', 'baz'], + ], + ], + [ '/foo/', '/', new SiteAccess('foo', 'uri:element'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo'), - ), - ), - array( + 'uri_part' => ['foo'], + ], + ], + [ '/foo', '/', new SiteAccess('foo', 'uri:element'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array('foo'), - ), - ), - array( + 'uri_part' => ['foo'], + ], + ], + [ '/uritext/matching', '/uritext/matching', new SiteAccess('foo', 'uri:text'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/uriregex/matching', '/uriregex/matching', new SiteAccess('foo', 'uri:regexp'), - array( + [ 'name' => 'foo', 'type' => 2, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/hostmap/matching', '/hostmap/matching', new SiteAccess('foo', 'host:map'), - array( + [ 'name' => 'foo', 'type' => 4, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/hostelement/matching', '/hostelement/matching', new SiteAccess('foo', 'host:element'), - array( + [ 'name' => 'foo', 'type' => 4, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/hosttext/matching', '/hosttext/matching', new SiteAccess('foo', 'host:text'), - array( + [ 'name' => 'foo', 'type' => 4, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/hostregex/matching', '/hostregex/matching', new SiteAccess('foo', 'host:regexp'), - array( + [ 'name' => 'foo', 'type' => 4, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/port/matching', '/port/matching', new SiteAccess('foo', 'port'), - array( + [ 'name' => 'foo', 'type' => 3, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/custom/matching', '/custom/matching', new SiteAccess('foo', 'custom_match'), - array( + [ 'name' => 'foo', 'type' => 10, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/_fragment', '/', new SiteAccess('site', 'default'), - array( + [ 'name' => 'site', 'type' => 1, - 'uri_part' => array(), - ), - ), - ); + 'uri_part' => [], + ], + ], + ]; } public function siteAccessParamStringMatchProvider() { - return array( - array( + return [ + [ '/some/pathinfo/(param)/foo', '/some/pathinfo', '/(param)/foo', new SiteAccess('foo', 'default'), - array( + [ 'name' => 'foo', 'type' => 1, - 'uri_part' => array(), - ), - ), - array( + 'uri_part' => [], + ], + ], + [ '/some/pathinfo/(param)/foo/b%C3%A4r', '/some/pathinfo', '/(param)/foo/bär', new SiteAccess('foo', 'default'), - array( + [ 'name' => 'foo', 'type' => 1, - 'uri_part' => array(), - ), - ), - ); + 'uri_part' => [], + ], + ], + ]; } /** @@ -347,11 +347,11 @@ public function siteAccessParamStringMatchProvider() * * @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\HttpFoundation\Request */ - private function getRequestMock(array $methodsToMock = array()) + private function getRequestMock(array $methodsToMock = []) { return $this ->getMockBuilder(Request::class) - ->setMethods(array_merge(array('getPathInfo'), $methodsToMock)) + ->setMethods(array_merge(['getPathInfo'], $methodsToMock)) ->getMock(); } @@ -360,7 +360,7 @@ private function getRequestMock(array $methodsToMock = array()) * * @return \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\DependencyInjection\ContainerInterface */ - private function getContainerMock(array $methodsToMock = array()) + private function getContainerMock(array $methodsToMock = []) { return $this ->getMockBuilder(ContainerInterface::class) diff --git a/mvc/EventListener/APIContentExceptionListener.php b/mvc/EventListener/APIContentExceptionListener.php index de16913f..b6601744 100644 --- a/mvc/EventListener/APIContentExceptionListener.php +++ b/mvc/EventListener/APIContentExceptionListener.php @@ -47,9 +47,9 @@ public function __construct(LegacyContentViewProvider $legacyCVP, LegacyLocation public static function getSubscribedEvents() { - return array( + return [ MVCEvents::API_CONTENT_EXCEPTION => 'onAPIContentException', - ); + ]; } public function onAPIContentException(APIContentExceptionEvent $event) @@ -60,7 +60,7 @@ public function onAPIContentException(APIContentExceptionEvent $event) if (isset($this->logger)) { $this->logger->notice( 'Missing field converter in legacy storage engine, forwarding to legacy kernel.', - array('content' => $contentMeta) + ['content' => $contentMeta] ); } @@ -68,18 +68,18 @@ public function onAPIContentException(APIContentExceptionEvent $event) $contentView->setViewType($contentMeta['viewType']); if (isset($contentMeta['locationId'])) { - $contentView->setLocation(new Location(array('id' => $contentMeta['locationId']))); + $contentView->setLocation(new Location(['id' => $contentMeta['locationId']])); $event->setContentView($this->legacyLVP->getView($contentView)); } elseif (isset($contentMeta['contentId'])) { $contentView->setContent( new Content( - array( + [ 'versionInfo' => new VersionInfo( - array( - 'contentInfo' => new ContentInfo(array('id' => $contentMeta['contentId'])), - ) + [ + 'contentInfo' => new ContentInfo(['id' => $contentMeta['contentId']]), + ] ), - ) + ] ) ); $event->setContentView($this->legacyCVP->getView($contentView)); diff --git a/mvc/Image/AliasGenerator.php b/mvc/Image/AliasGenerator.php index cf12e5a1..0c395f9a 100644 --- a/mvc/Image/AliasGenerator.php +++ b/mvc/Image/AliasGenerator.php @@ -65,7 +65,7 @@ protected function getLegacyKernel() * * @return \eZ\Publish\SPI\Variation\Values\ImageVariation */ - public function getVariation(Field $field, VersionInfo $versionInfo, $variationName, array $parameters = array()) + public function getVariation(Field $field, VersionInfo $versionInfo, $variationName, array $parameters = []) { $variationIdentifier = "$field->id-$versionInfo->versionNo-$variationName"; if (isset($this->variations[$variationIdentifier])) { @@ -77,7 +77,7 @@ public function getVariation(Field $field, VersionInfo $versionInfo, $variationN $allVariations = &$this->variations; return $this->getLegacyKernel()->runCallback( - function () use ($field, $versionInfo, $variationName, &$allAliasHandlers, &$allVariations, $variationIdentifier) { + static function () use ($field, $versionInfo, $variationName, &$allAliasHandlers, &$allVariations, $variationIdentifier) { $aliasHandlerIdentifier = "$field->id-$versionInfo->versionNo"; if (!isset($allAliasHandlers[$aliasHandlerIdentifier])) { $allAliasHandlers[$aliasHandlerIdentifier] = new eZImageAliasHandler( @@ -93,7 +93,7 @@ function () use ($field, $versionInfo, $variationName, &$allAliasHandlers, &$all } $allVariations[$variationIdentifier] = new ImageVariation( - array( + [ 'name' => $variationName, 'fileName' => $aliasArray['filename'], 'dirPath' => $aliasArray['dirpath'], @@ -104,7 +104,7 @@ function () use ($field, $versionInfo, $variationName, &$allAliasHandlers, &$all 'width' => $aliasArray['width'], 'height' => $aliasArray['height'], 'imageId' => sprintf('%d-%d', $versionInfo->contentInfo->id, $field->id), - ) + ] ); return $allVariations[$variationIdentifier]; diff --git a/mvc/Kernel/CLIHandler.php b/mvc/Kernel/CLIHandler.php index c99895c7..2e321aed 100644 --- a/mvc/Kernel/CLIHandler.php +++ b/mvc/Kernel/CLIHandler.php @@ -49,11 +49,11 @@ class CLIHandler implements ezpKernelHandler * @param \eZ\Publish\Core\MVC\Symfony\SiteAccess $siteAccess * @param \Symfony\Component\DependencyInjection\ContainerInterface $container */ - public function __construct(array $settings = array(), SiteAccess $siteAccess = null, ContainerInterface $container = null) + public function __construct(array $settings = [], SiteAccess $siteAccess = null, ContainerInterface $container = null) { $this->container = $container; if (isset($settings['injected-settings'])) { - $injectedSettings = array(); + $injectedSettings = []; foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) { list($file, $section, $setting) = explode('/', $keySetting); $injectedSettings[$file][$section][$setting] = $injectedSetting; @@ -64,7 +64,7 @@ public function __construct(array $settings = array(), SiteAccess $siteAccess = } if (isset($settings['injected-merge-settings'])) { - $injectedSettings = array(); + $injectedSettings = []; foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) { list($file, $section, $setting) = explode('/', $keySetting); $injectedSettings[$file][$section][$setting] = $injectedSetting; @@ -106,7 +106,7 @@ public function run() // start output buffering before including legacy script to filter unwanted output. ob_start( - function ($buffer) { + static function ($buffer) { static $startFlag = false; // remove shebang line from start of script, if any if (!$startFlag) { diff --git a/mvc/Kernel/Loader.php b/mvc/Kernel/Loader.php index bea81dea..f979a226 100644 --- a/mvc/Kernel/Loader.php +++ b/mvc/Kernel/Loader.php @@ -121,7 +121,7 @@ public function buildLegacyKernel($legacyKernelHandler) $logger = $this->logger; $that = $this; - return function () use ($legacyKernelHandler, $legacyRootDir, $webrootDir, $eventDispatcher, $logger, $that) { + return static function () use ($legacyKernelHandler, $legacyRootDir, $webrootDir, $eventDispatcher, $logger, $that) { if (LegacyKernel::hasInstance()) { return LegacyKernel::instance(); } @@ -150,7 +150,7 @@ public function buildLegacyKernel($legacyKernelHandler) * * @return \Closure */ - public function buildLegacyKernelHandlerWeb($webHandlerClass, array $defaultLegacyOptions = array()) + public function buildLegacyKernelHandlerWeb($webHandlerClass, array $defaultLegacyOptions = []) { $legacyRootDir = $this->legacyRootDir; $webrootDir = $this->webrootDir; @@ -221,7 +221,7 @@ public function buildLegacyKernelHandlerCLI() $container = $this->container; $that = $this; - return function () use ($legacyRootDir, $container, $eventDispatcher, $that) { + return static function () use ($legacyRootDir, $container, $eventDispatcher, $that) { if (!$that->getCLIHandler()) { $currentDir = getcwd(); chdir($legacyRootDir); @@ -264,10 +264,10 @@ public function buildLegacyKernelHandlerTreeMenu() { return $this->buildLegacyKernelHandlerWeb( $this->container->getParameter('ezpublish_legacy.kernel_handler.treemenu.class'), - array( + [ 'use-cache-headers' => false, 'use-exceptions' => true, - ) + ] ); } diff --git a/mvc/Security/Firewall/LoginCleanupListener.php b/mvc/Security/Firewall/LoginCleanupListener.php index 1e4ce255..4cf1046a 100644 --- a/mvc/Security/Firewall/LoginCleanupListener.php +++ b/mvc/Security/Firewall/LoginCleanupListener.php @@ -60,9 +60,9 @@ public function onFilterResponse(FilterResponseEvent $e) public static function getSubscribedEvents() { - return array( + return [ SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin', KernelEvents::RESPONSE => 'onFilterResponse', - ); + ]; } } diff --git a/mvc/Security/Firewall/SSOListener.php b/mvc/Security/Firewall/SSOListener.php index c6489a24..0bf2429a 100644 --- a/mvc/Security/Firewall/SSOListener.php +++ b/mvc/Security/Firewall/SSOListener.php @@ -61,7 +61,7 @@ protected function getPreAuthenticatedData(Request $request) $logger = $this->logger; $legacyUser = $legacyKernel->runCallback( - function () use ($logger) { + static function () use ($logger) { foreach (eZINI::instance()->variable('UserSettings', 'SingleSignOnHandlerArray') as $ssoHandlerName) { $className = 'eZ' . $ssoHandlerName . 'SSOHandler'; if (!class_exists($className)) { @@ -88,14 +88,14 @@ function () use ($logger) { // No matched user with legacy. if (!$legacyUser instanceof eZUser) { - return array('', ''); + return ['', '']; } $user = new User( $this->userService->loadUser($legacyUser->attribute('contentobject_id')), - array('ROLE_USER') + ['ROLE_USER'] ); - return array($user, $user->getPassword()); + return [$user, $user->getPassword()]; } } diff --git a/mvc/Security/LegacyToken.php b/mvc/Security/LegacyToken.php index 330a36fc..a865fc6f 100644 --- a/mvc/Security/LegacyToken.php +++ b/mvc/Security/LegacyToken.php @@ -30,7 +30,7 @@ public function __construct(TokenInterface $innerToken) public function serialize() { - return serialize(array($this->innerToken)); + return serialize([$this->innerToken]); } public function unserialize($serialized) diff --git a/mvc/Session/LegacySessionProxy.php b/mvc/Session/LegacySessionProxy.php index 7eac6547..ec2932e6 100644 --- a/mvc/Session/LegacySessionProxy.php +++ b/mvc/Session/LegacySessionProxy.php @@ -80,8 +80,8 @@ public function write($sessionId, $data) public function destroy($sessionId) { $this->getLegacyKernel()->runCallback( - function () use ($sessionId) { - ezpEvent::getInstance()->notify('session/destroy', array($sessionId)); + static function () use ($sessionId) { + ezpEvent::getInstance()->notify('session/destroy', [$sessionId]); }, false ); @@ -94,14 +94,14 @@ public function gc($maxlifetime) $sessionHandler = $this->sessionHandler; return $this->getLegacyKernel()->runCallback( - function () use ($maxlifetime, $sessionHandler) { - ezpEvent::getInstance()->notify('session/gc', array($maxlifetime)); + static function () use ($maxlifetime, $sessionHandler) { + ezpEvent::getInstance()->notify('session/gc', [$maxlifetime]); $db = eZDB::instance(); - eZSession::triggerCallback('gc_pre', array($db, $maxlifetime)); + eZSession::triggerCallback('gc_pre', [$db, $maxlifetime]); $success = $sessionHandler->gc($maxlifetime); - eZSession::triggerCallback('gc_post', array($db, $maxlifetime)); + eZSession::triggerCallback('gc_post', [$db, $maxlifetime]); return $success; }, diff --git a/mvc/Session/LegacySessionStorage.php b/mvc/Session/LegacySessionStorage.php index e3d8c0e1..50941f11 100644 --- a/mvc/Session/LegacySessionStorage.php +++ b/mvc/Session/LegacySessionStorage.php @@ -88,14 +88,14 @@ public function regenerate($destroy = false, $lifetime = null) if ($success && !$destroy) { $kernelClosure = $this->legacyKernelClosure; $kernelClosure()->runCallback( - function () use ($oldSessionId, $newSessionId) { - ezpEvent::getInstance()->notify('session/regenerate', array($oldSessionId, $newSessionId)); + static function () use ($oldSessionId, $newSessionId) { + ezpEvent::getInstance()->notify('session/regenerate', [$oldSessionId, $newSessionId]); $db = eZDB::instance(); $escOldKey = $db->escapeString($oldSessionId); $escNewKey = $db->escapeString($newSessionId); $escUserID = $db->escapeString(eZSession::userID()); - eZSession::triggerCallback('regenerate_pre', array($db, $escNewKey, $escOldKey, $escUserID)); - eZSession::triggerCallback('regenerate_post', array($db, $escNewKey, $escOldKey, $escUserID)); + eZSession::triggerCallback('regenerate_pre', [$db, $escNewKey, $escOldKey, $escUserID]); + eZSession::triggerCallback('regenerate_post', [$db, $escNewKey, $escOldKey, $escUserID]); }, false, false diff --git a/mvc/SignalSlot/AbstractLegacyObjectStateSlot.php b/mvc/SignalSlot/AbstractLegacyObjectStateSlot.php index 7d54a0ce..321b1935 100644 --- a/mvc/SignalSlot/AbstractLegacyObjectStateSlot.php +++ b/mvc/SignalSlot/AbstractLegacyObjectStateSlot.php @@ -26,7 +26,7 @@ abstract class AbstractLegacyObjectStateSlot extends AbstractLegacySlot public function receive(Signal $signal) { $this->runLegacyKernelCallback( - function () { + static function () { // Passing null as $cacheItem parameter is not used by this method eZCache::clearStateLimitations(null); } diff --git a/mvc/SignalSlot/LegacyAssignSectionSlot.php b/mvc/SignalSlot/LegacyAssignSectionSlot.php index 78592e90..3ada3f7c 100644 --- a/mvc/SignalSlot/LegacyAssignSectionSlot.php +++ b/mvc/SignalSlot/LegacyAssignSectionSlot.php @@ -30,9 +30,9 @@ public function receive(Signal $signal) }// @todo Error Logging? No exception seem to be defined for this case $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId); - eZSearch::updateObjectsSection(array($signal->contentId), $signal->sectionId); + eZSearch::updateObjectsSection([$signal->contentId], $signal->sectionId); eZContentObject::clearCache(); // Clear all object memory cache to free memory } ); diff --git a/mvc/SignalSlot/LegacyAssignUserToUserGroupSlot.php b/mvc/SignalSlot/LegacyAssignUserToUserGroupSlot.php index 18861923..d78b9560 100644 --- a/mvc/SignalSlot/LegacyAssignUserToUserGroupSlot.php +++ b/mvc/SignalSlot/LegacyAssignUserToUserGroupSlot.php @@ -29,7 +29,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentCacheManager::clearAllContentCache(); eZRole::expireCache(); } diff --git a/mvc/SignalSlot/LegacyCopyContentSlot.php b/mvc/SignalSlot/LegacyCopyContentSlot.php index 86c1a9f8..0dfd3c90 100644 --- a/mvc/SignalSlot/LegacyCopyContentSlot.php +++ b/mvc/SignalSlot/LegacyCopyContentSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->dstContentId); eZContentOperationCollection::registerSearchObject($signal->dstContentId); eZContentObject::clearCache(); // Clear all object memory cache to free memory diff --git a/mvc/SignalSlot/LegacyCreateLanguageSlot.php b/mvc/SignalSlot/LegacyCreateLanguageSlot.php index 6b5723c2..f9856fbe 100644 --- a/mvc/SignalSlot/LegacyCreateLanguageSlot.php +++ b/mvc/SignalSlot/LegacyCreateLanguageSlot.php @@ -28,7 +28,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentLanguage::expireCache(); } ); diff --git a/mvc/SignalSlot/LegacyCreateLocationSlot.php b/mvc/SignalSlot/LegacyCreateLocationSlot.php index 4c425d90..32bc288d 100644 --- a/mvc/SignalSlot/LegacyCreateLocationSlot.php +++ b/mvc/SignalSlot/LegacyCreateLocationSlot.php @@ -30,8 +30,8 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { - eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId, true, array($signal->locationId)); + static function () use ($signal) { + eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId, true, [$signal->locationId]); $object = eZContentObject::fetch($signal->contentId); eZSearch::addNodeAssignment($object->mainNodeID(), $signal->contentId, $signal->locationId); eZContentObject::clearCache(); // Clear all object memory cache to free memory diff --git a/mvc/SignalSlot/LegacyCreateUserSlot.php b/mvc/SignalSlot/LegacyCreateUserSlot.php index 1386c8c9..0f4fde17 100644 --- a/mvc/SignalSlot/LegacyCreateUserSlot.php +++ b/mvc/SignalSlot/LegacyCreateUserSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->userId); eZContentOperationCollection::registerSearchObject($signal->userId); eZContentObject::clearCache(); // Clear all object memory cache to free memory diff --git a/mvc/SignalSlot/LegacyDeleteContentSlot.php b/mvc/SignalSlot/LegacyDeleteContentSlot.php index 89605a3d..af8e408f 100644 --- a/mvc/SignalSlot/LegacyDeleteContentSlot.php +++ b/mvc/SignalSlot/LegacyDeleteContentSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId); eZSearch::removeObjectById($signal->contentId, null); eZContentObject::clearCache(); // Clear all object memory cache to free memory diff --git a/mvc/SignalSlot/LegacyDeleteLanguageSlot.php b/mvc/SignalSlot/LegacyDeleteLanguageSlot.php index 4ebe7d2c..429032f2 100644 --- a/mvc/SignalSlot/LegacyDeleteLanguageSlot.php +++ b/mvc/SignalSlot/LegacyDeleteLanguageSlot.php @@ -28,7 +28,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentLanguage::expireCache(); } ); diff --git a/mvc/SignalSlot/LegacyDeleteLocationSlot.php b/mvc/SignalSlot/LegacyDeleteLocationSlot.php index afa836c6..cc8be9f3 100644 --- a/mvc/SignalSlot/LegacyDeleteLocationSlot.php +++ b/mvc/SignalSlot/LegacyDeleteLocationSlot.php @@ -31,7 +31,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { // First clear object memory cache to prevent false detection of possibly deleted Content eZContentObject::clearCache($signal->contentId); @@ -43,8 +43,8 @@ function () use ($signal) { eZSearch::removeObjectById($signal->contentId); } - eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId, true, array($signal->locationId)); - eZSearch::removeNodes(array($signal->locationId)); + eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId, true, [$signal->locationId]); + eZSearch::removeNodes([$signal->locationId]); eZContentObject::clearCache(); // Clear all object memory cache to free memory } ); diff --git a/mvc/SignalSlot/LegacyDeleteVersionSlot.php b/mvc/SignalSlot/LegacyDeleteVersionSlot.php index c1093590..253cf87b 100644 --- a/mvc/SignalSlot/LegacyDeleteVersionSlot.php +++ b/mvc/SignalSlot/LegacyDeleteVersionSlot.php @@ -31,7 +31,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId); eZSearch::removeObjectById($signal->contentId, null); eZContentOperationCollection::registerSearchObject($signal->contentId); diff --git a/mvc/SignalSlot/LegacyDisableLanguageSlot.php b/mvc/SignalSlot/LegacyDisableLanguageSlot.php index d0ef2167..62716f47 100644 --- a/mvc/SignalSlot/LegacyDisableLanguageSlot.php +++ b/mvc/SignalSlot/LegacyDisableLanguageSlot.php @@ -28,7 +28,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentLanguage::expireCache(); } ); diff --git a/mvc/SignalSlot/LegacyEnableLanguageSlot.php b/mvc/SignalSlot/LegacyEnableLanguageSlot.php index dcbd4e47..b43f3b4f 100644 --- a/mvc/SignalSlot/LegacyEnableLanguageSlot.php +++ b/mvc/SignalSlot/LegacyEnableLanguageSlot.php @@ -28,7 +28,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentLanguage::expireCache(); } ); diff --git a/mvc/SignalSlot/LegacyHideLocationSlot.php b/mvc/SignalSlot/LegacyHideLocationSlot.php index c740438b..b524488f 100644 --- a/mvc/SignalSlot/LegacyHideLocationSlot.php +++ b/mvc/SignalSlot/LegacyHideLocationSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { $node = eZContentObjectTreeNode::fetch($signal->locationId); eZContentObjectTreeNode::clearViewCacheForSubtree($node); eZSearch::updateNodeVisibility($signal->locationId, 'hide'); diff --git a/mvc/SignalSlot/LegacyMoveSubtreeSlot.php b/mvc/SignalSlot/LegacyMoveSubtreeSlot.php index 5da307fe..40350f7a 100644 --- a/mvc/SignalSlot/LegacyMoveSubtreeSlot.php +++ b/mvc/SignalSlot/LegacyMoveSubtreeSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { $node = eZContentObjectTreeNode::fetch($signal->locationId); eZContentObjectTreeNode::clearViewCacheForSubtree($node); eZContentOperationCollection::registerSearchObject($node->attribute('contentobject_id')); diff --git a/mvc/SignalSlot/LegacyPublishContentTypeDraftSlot.php b/mvc/SignalSlot/LegacyPublishContentTypeDraftSlot.php index de4b13de..b0c7cfdf 100644 --- a/mvc/SignalSlot/LegacyPublishContentTypeDraftSlot.php +++ b/mvc/SignalSlot/LegacyPublishContentTypeDraftSlot.php @@ -28,7 +28,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZExpiryHandler::registerShutdownFunction(); $handler = eZExpiryHandler::instance(); $time = time(); diff --git a/mvc/SignalSlot/LegacyPublishVersionSlot.php b/mvc/SignalSlot/LegacyPublishVersionSlot.php index c86030be..f3023736 100644 --- a/mvc/SignalSlot/LegacyPublishVersionSlot.php +++ b/mvc/SignalSlot/LegacyPublishVersionSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId); eZContentOperationCollection::registerSearchObject($signal->contentId); eZContentObject::clearCache(); // Clear all object memory cache to free memory diff --git a/mvc/SignalSlot/LegacySetContentStateSlot.php b/mvc/SignalSlot/LegacySetContentStateSlot.php index 386bdfd7..76c1934e 100644 --- a/mvc/SignalSlot/LegacySetContentStateSlot.php +++ b/mvc/SignalSlot/LegacySetContentStateSlot.php @@ -30,9 +30,9 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId); - eZSearch::updateObjectState($signal->contentId, array($signal->objectStateId)); + eZSearch::updateObjectState($signal->contentId, [$signal->objectStateId]); eZContentObject::clearCache(); // Clear all object memory cache to free memory } ); diff --git a/mvc/SignalSlot/LegacySwapLocationSlot.php b/mvc/SignalSlot/LegacySwapLocationSlot.php index 51049a29..10787225 100644 --- a/mvc/SignalSlot/LegacySwapLocationSlot.php +++ b/mvc/SignalSlot/LegacySwapLocationSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->content1Id); eZContentCacheManager::clearContentCacheIfNeeded($signal->content2Id); eZSearch::swapNode($signal->location1Id, $signal->location2Id); diff --git a/mvc/SignalSlot/LegacyUnassignUserFromUserGroupSlot.php b/mvc/SignalSlot/LegacyUnassignUserFromUserGroupSlot.php index 1732019d..8beb8f0f 100644 --- a/mvc/SignalSlot/LegacyUnassignUserFromUserGroupSlot.php +++ b/mvc/SignalSlot/LegacyUnassignUserFromUserGroupSlot.php @@ -29,7 +29,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentCacheManager::clearAllContentCache(); eZRole::expireCache(); } diff --git a/mvc/SignalSlot/LegacyUnhideLocationSlot.php b/mvc/SignalSlot/LegacyUnhideLocationSlot.php index d6468e23..b63f88ce 100644 --- a/mvc/SignalSlot/LegacyUnhideLocationSlot.php +++ b/mvc/SignalSlot/LegacyUnhideLocationSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { $node = eZContentObjectTreeNode::fetch($signal->locationId); eZContentObjectTreeNode::clearViewCacheForSubtree($node); eZSearch::updateNodeVisibility($signal->locationId, 'show'); diff --git a/mvc/SignalSlot/LegacyUpdateLanguageNameSlot.php b/mvc/SignalSlot/LegacyUpdateLanguageNameSlot.php index 82c98b2c..077ae527 100644 --- a/mvc/SignalSlot/LegacyUpdateLanguageNameSlot.php +++ b/mvc/SignalSlot/LegacyUpdateLanguageNameSlot.php @@ -28,7 +28,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () { + static function () { eZContentLanguage::expireCache(); } ); diff --git a/mvc/SignalSlot/LegacyUpdateLocationSlot.php b/mvc/SignalSlot/LegacyUpdateLocationSlot.php index ee9a1891..fca4c2af 100644 --- a/mvc/SignalSlot/LegacyUpdateLocationSlot.php +++ b/mvc/SignalSlot/LegacyUpdateLocationSlot.php @@ -29,7 +29,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->contentId); eZContentObject::clearCache(); // Clear all object memory cache to free memory } diff --git a/mvc/SignalSlot/LegacyUpdateUserSlot.php b/mvc/SignalSlot/LegacyUpdateUserSlot.php index 35e597af..6b0e6a4e 100644 --- a/mvc/SignalSlot/LegacyUpdateUserSlot.php +++ b/mvc/SignalSlot/LegacyUpdateUserSlot.php @@ -30,7 +30,7 @@ public function receive(Signal $signal) } $this->runLegacyKernelCallback( - function () use ($signal) { + static function () use ($signal) { eZContentCacheManager::clearContentCacheIfNeeded($signal->userId); eZContentOperationCollection::registerSearchObject($signal->userId); eZContentObject::clearCache(); // Clear all object memory cache to free memory diff --git a/mvc/Templating/Adapter/BlockAdapter.php b/mvc/Templating/Adapter/BlockAdapter.php index 504b6655..1f3ce1eb 100644 --- a/mvc/Templating/Adapter/BlockAdapter.php +++ b/mvc/Templating/Adapter/BlockAdapter.php @@ -19,7 +19,7 @@ class BlockAdapter extends DefinitionBasedAdapter { protected function definition() { - return array( + return [ 'id' => 'id', 'name' => 'name', 'action' => 'action', @@ -30,19 +30,19 @@ protected function definition() 'view' => 'view', 'overflow_id' => 'overflowId', 'zone_id' => 'zoneId', - 'valid_items' => function (Block $block) { + 'valid_items' => static function (Block $block) { return eZFlowPool::validItems($block->id); }, - 'valid_nodes' => function (Block $block) { + 'valid_nodes' => static function (Block $block) { return eZFlowPool::validNodes($block->id); }, - 'archived_items' => function (Block $block) { + 'archived_items' => static function (Block $block) { return eZFlowPool::archivedItems($block->id); }, - 'waiting_items' => function (Block $block) { + 'waiting_items' => static function (Block $block) { return eZFlowPool::waitingItems($block->id); }, - 'last_valid_items' => function (Block $block) { + 'last_valid_items' => static function (Block $block) { $validItems = eZFlowPool::validItems($block->id); if (empty($validItems)) { return; @@ -60,9 +60,9 @@ protected function definition() return $result; }, // The following is only for block_view_gui template function in legacy. - 'view_template' => function (Block $block) { + 'view_template' => static function (Block $block) { return 'view'; }, - ); + ]; } } diff --git a/mvc/Templating/Adapter/ZoneAdapter.php b/mvc/Templating/Adapter/ZoneAdapter.php index c408e516..f7c93d7a 100644 --- a/mvc/Templating/Adapter/ZoneAdapter.php +++ b/mvc/Templating/Adapter/ZoneAdapter.php @@ -25,18 +25,18 @@ class ZoneAdapter extends DefinitionBasedAdapter */ protected function definition() { - return array( + return [ 'id' => 'id', 'action' => 'action', 'zone_identifier' => 'identifier', - 'blocks' => function (Zone $zone) { - $legacyBlocks = array(); + 'blocks' => static function (Zone $zone) { + $legacyBlocks = []; foreach ($zone->blocks as $block) { $legacyBlocks[] = new BlockAdapter($block); } return $legacyBlocks; }, - ); + ]; } } diff --git a/mvc/Templating/Converter/ApiContentConverter.php b/mvc/Templating/Converter/ApiContentConverter.php index b4de95e5..00bcacf7 100644 --- a/mvc/Templating/Converter/ApiContentConverter.php +++ b/mvc/Templating/Converter/ApiContentConverter.php @@ -32,7 +32,7 @@ class ApiContentConverter implements MultipleObjectConverter public function __construct(\Closure $legacyKernelClosure) { $this->legacyKernelClosure = $legacyKernelClosure; - $this->apiObjects = array(); + $this->apiObjects = []; } /** @@ -56,12 +56,12 @@ final protected function getLegacyKernel() */ public function convert($object) { - if (!is_object($object)) { - throw new \InvalidArgumentException('Transferred object must be a real object. Got ' . gettype($object)); + if (!\is_object($object)) { + throw new \InvalidArgumentException('Transferred object must be a real object. Got ' . \gettype($object)); } return $this->getLegacyKernel()->runCallback( - function () use ($object) { + static function () use ($object) { if ($object instanceof Content) { return eZContentObject::fetch($object->getVersionInfo()->getContentInfo()->id); } elseif ($object instanceof Location) { @@ -86,8 +86,8 @@ function () use ($object) { */ public function register($object, $alias) { - if (!is_object($object)) { - throw new \InvalidArgumentException('Transferred object must be a real object. Got ' . gettype($object)); + if (!\is_object($object)) { + throw new \InvalidArgumentException('Transferred object must be a real object. Got ' . \gettype($object)); } $this->apiObjects[$alias] = $object; @@ -102,12 +102,12 @@ public function convertAll() { $apiObjects = $this->apiObjects; if (empty($apiObjects)) { - return array(); + return []; } return $this->getLegacyKernel()->runCallback( - function () use ($apiObjects) { - $convertedObjects = array(); + static function () use ($apiObjects) { + $convertedObjects = []; foreach ($apiObjects as $alias => $apiObject) { if ($apiObject instanceof Content) { $convertedObjects[$alias] = eZContentObject::fetch($apiObject->getVersionInfo()->getContentInfo()->id); diff --git a/mvc/Templating/Converter/DelegatingConverter.php b/mvc/Templating/Converter/DelegatingConverter.php index ac60fd1c..ed644c4b 100644 --- a/mvc/Templating/Converter/DelegatingConverter.php +++ b/mvc/Templating/Converter/DelegatingConverter.php @@ -32,8 +32,8 @@ class DelegatingConverter implements MultipleObjectConverter public function __construct(ObjectConverter $genericConverter) { - $this->convertersMap = array(); - $this->objectsToConvert = array(); + $this->convertersMap = []; + $this->objectsToConvert = []; $this->genericConverter = $genericConverter; } @@ -69,11 +69,11 @@ public function register($object, $alias) */ public function convertAll() { - $convertedObjects = array(); - $delegatingConverters = array(); + $convertedObjects = []; + $delegatingConverters = []; foreach ($this->objectsToConvert as $alias => $obj) { - $className = get_class($obj); + $className = \get_class($obj); if (isset($this->convertersMap[$className])) { $converter = $this->convertersMap[$className]; // MultipleObjectConverter => Register it for later conversion @@ -109,7 +109,7 @@ public function convertAll() */ public function convert($object) { - $className = get_class($object); + $className = \get_class($object); if (isset($this->convertersMap[$className])) { $converter = $this->convertersMap[$className]; } else { diff --git a/mvc/Templating/Converter/GenericConverter.php b/mvc/Templating/Converter/GenericConverter.php index cf6cbb9b..74573191 100644 --- a/mvc/Templating/Converter/GenericConverter.php +++ b/mvc/Templating/Converter/GenericConverter.php @@ -26,8 +26,8 @@ class GenericConverter implements ObjectConverter */ public function convert($object) { - if (!is_object($object)) { - throw new \InvalidArgumentException('Transferred object must be a real object. Got ' . gettype($object)); + if (!\is_object($object)) { + throw new \InvalidArgumentException('Transferred object must be a real object. Got ' . \gettype($object)); } return new LegacyAdapter($object); diff --git a/mvc/Templating/Converter/PagePartsConverter.php b/mvc/Templating/Converter/PagePartsConverter.php index ae10f7e8..9222ef1c 100644 --- a/mvc/Templating/Converter/PagePartsConverter.php +++ b/mvc/Templating/Converter/PagePartsConverter.php @@ -18,8 +18,8 @@ class PagePartsConverter implements ObjectConverter { public function convert($object) { - if (!is_object($object)) { - throw new InvalidArgumentException('Transferred object must be a Page\\Parts\\Block object. Got ' . gettype($object)); + if (!\is_object($object)) { + throw new InvalidArgumentException('Transferred object must be a Page\\Parts\\Block object. Got ' . \gettype($object)); } if ($object instanceof Block) { @@ -28,6 +28,6 @@ public function convert($object) return new ZoneAdapter($object); } - throw new InvalidArgumentException('Transferred object must be a Page\\Parts\\Block object. Got ' . get_class($object)); + throw new InvalidArgumentException('Transferred object must be a Page\\Parts\\Block object. Got ' . \get_class($object)); } } diff --git a/mvc/Templating/LegacyAdapter.php b/mvc/Templating/LegacyAdapter.php index c413120c..2394042b 100644 --- a/mvc/Templating/LegacyAdapter.php +++ b/mvc/Templating/LegacyAdapter.php @@ -44,7 +44,7 @@ public function __construct($transferredObject) // Registering available public properties $this->properties = array_map( - function () { + static function () { return true; }, get_object_vars($transferredObject) @@ -54,7 +54,7 @@ function () { $this->getters = array_fill_keys( array_filter( get_class_methods($transferredObject), - function ($method) { + static function ($method) { return strpos($method, 'get') === 0; } ), @@ -94,7 +94,7 @@ public function attribute($name) return $this->object->$getterName(); } - throw new \InvalidArgumentException("Unsupported attribute '$name' for " . get_class($this->object)); + throw new \InvalidArgumentException("Unsupported attribute '$name' for " . \get_class($this->object)); } /** @@ -107,7 +107,7 @@ public function attributes() $getters = $this->getters; array_walk( $getters, - function ($methodName) { + static function ($methodName) { return lcfirst(substr($methodName, 3)); } ); diff --git a/mvc/Templating/LegacyEngine.php b/mvc/Templating/LegacyEngine.php index d79341fc..7c9ecdfa 100644 --- a/mvc/Templating/LegacyEngine.php +++ b/mvc/Templating/LegacyEngine.php @@ -33,7 +33,7 @@ public function __construct(\Closure $legacyKernelClosure, MultipleObjectConvert { $this->legacyKernelClosure = $legacyKernelClosure; $this->objectConverter = $objectConverter; - $this->supportedTemplates = array(); + $this->supportedTemplates = []; } /** @@ -58,24 +58,24 @@ protected function getLegacyKernel() * * @api */ - public function render($name, array $parameters = array()) + public function render($name, array $parameters = []) { $objectConverter = $this->objectConverter; - $legacyVars = array(); + $legacyVars = []; foreach ($parameters as $varName => $param) { // If $param is an array, we recursively convert all objects contained in it (if any). // Scalar parameters are passed as is - if (is_array($param)) { + if (\is_array($param)) { array_walk_recursive( $param, - function (&$element) use ($objectConverter) { - if (is_object($element) && !($element instanceof LegacyCompatible)) { + static function (&$element) use ($objectConverter) { + if (\is_object($element) && !($element instanceof LegacyCompatible)) { $element = $objectConverter->convert($element); } } ); $legacyVars[$varName] = $param; - } elseif (!is_object($param) || $param instanceof LegacyCompatible) { + } elseif (!\is_object($param) || $param instanceof LegacyCompatible) { $legacyVars[$varName] = $param; } else { $objectConverter->register($param, $varName); @@ -84,7 +84,7 @@ function (&$element) use ($objectConverter) { $legacyVars += $objectConverter->convertAll(); return $this->getLegacyKernel()->runCallback( - function () use ($name, $legacyVars) { + static function () use ($name, $legacyVars) { $tpl = eZTemplate::factory(); foreach ($legacyVars as $varName => $value) { @@ -107,7 +107,7 @@ function () use ($name, $legacyVars) { public function exists($name) { return $this->getLegacyKernel()->runCallback( - function () use ($name) { + static function () use ($name) { $legacyTemplate = eZTemplate::factory()->loadURIRoot($name, false, $extraParameters); return !empty($legacyTemplate); @@ -136,7 +136,7 @@ public function supports($name) strpos($name, 'design:') === 0 || strpos($name, 'file:') === 0 ) && - (substr($name, -strlen(self::SUPPORTED_SUFFIX)) === self::SUPPORTED_SUFFIX); + (substr($name, -\strlen(self::SUPPORTED_SUFFIX)) === self::SUPPORTED_SUFFIX); return $this->supportedTemplates[$name]; } diff --git a/mvc/Templating/LegacyFormulaLoader.php b/mvc/Templating/LegacyFormulaLoader.php index 2e8506d0..910a6282 100644 --- a/mvc/Templating/LegacyFormulaLoader.php +++ b/mvc/Templating/LegacyFormulaLoader.php @@ -29,6 +29,6 @@ class LegacyFormulaLoader implements FormulaLoaderInterface */ public function load(ResourceInterface $resource) { - return array(); + return []; } } diff --git a/mvc/Templating/LegacyHelper.php b/mvc/Templating/LegacyHelper.php index c148c263..d856a31e 100644 --- a/mvc/Templating/LegacyHelper.php +++ b/mvc/Templating/LegacyHelper.php @@ -37,7 +37,7 @@ public function loadDataFromModuleResult(array $moduleResult) $that = $this; $kernelClosure()->runCallback( - function () use ($moduleResult, $that) { + static function () use ($moduleResult, $that) { // Injecting all $moduleResult entries in the legacy helper foreach ($moduleResult as $key => $val) { if ($key === 'content') { diff --git a/mvc/Templating/Tests/Adapter/ValueObjectAdapterTest.php b/mvc/Templating/Tests/Adapter/ValueObjectAdapterTest.php index 748c24bd..9670106f 100644 --- a/mvc/Templating/Tests/Adapter/ValueObjectAdapterTest.php +++ b/mvc/Templating/Tests/Adapter/ValueObjectAdapterTest.php @@ -40,26 +40,26 @@ protected function setUp() parent::setUp(); $block = new \stdClass(); $block->id = 123456; - $this->validProperties = array( + $this->validProperties = [ 'id' => 123, 'identifier' => 'some_identifier', 'action' => 'some_action', - 'blocks' => array($block), - ); - $this->map = array( + 'blocks' => [$block], + ]; + $this->map = [ 'id' => 'id', 'zone_identifier' => 'identifier', 'all_blocks' => 'blocks', - 'dynamic_prop' => function (ValueObject $valueObject) { + 'dynamic_prop' => static function (ValueObject $valueObject) { return $valueObject; }, - ); + ]; $this->valueObject = $this ->getMockBuilder(Zone::class) ->setConstructorArgs( - array( + [ $this->validProperties, - ) + ] ) ->getMockForAbstractClass(); $this->adapter = $this->getAdapter($this->valueObject, $this->map); @@ -92,14 +92,14 @@ public function testHasAttribute($attributeName, $isset) public function hasAttributeProvider() { - return array( - array('id', true), - array('action', false), - array('zone_identifier', true), - array('all_blocks', true), - array('dynamic_prop', true), - array('non_existent', false), - ); + return [ + ['id', true], + ['action', false], + ['zone_identifier', true], + ['all_blocks', true], + ['dynamic_prop', true], + ['non_existent', false], + ]; } /** @@ -128,14 +128,14 @@ public function testGetAttribute() public function getAttributeProvider() { - return array( - array('id', $this->validProperties['id']), - array('action', null), - array('zone_identifier', $this->validProperties['identifier']), - array('all_blocks', $this->validProperties['blocks']), - array('dynamic_prop', $this->valueObject), - array('non_existent', null), - ); + return [ + ['id', $this->validProperties['id']], + ['action', null], + ['zone_identifier', $this->validProperties['identifier']], + ['all_blocks', $this->validProperties['blocks']], + ['dynamic_prop', $this->valueObject], + ['non_existent', null], + ]; } /** diff --git a/mvc/Templating/Tests/Converter/PagePartsConverterTest.php b/mvc/Templating/Tests/Converter/PagePartsConverterTest.php index 4a6b4de0..c5e5fcda 100644 --- a/mvc/Templating/Tests/Converter/PagePartsConverterTest.php +++ b/mvc/Templating/Tests/Converter/PagePartsConverterTest.php @@ -33,46 +33,48 @@ public function testConvert(ValueObject $valueObject, $expectedAdapterClass) public function convertProvider() { - return array( - array( + return [ + [ $this->createMock(Block::class), BlockAdapter::class, - ), - array( + ], + [ $this->createMock(Zone::class), ZoneAdapter::class, - ), - ); + ], + ]; } /** - * @expectedException \InvalidArgumentException * @dataProvider convertFailNotObjectProvider * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Converter\PagePartsConverter::convert */ public function testConvertFailNotObject($value) { + $this->expectException(\InvalidArgumentException::class); + $converter = new PagePartsConverter(); $converter->convert($value); } public function convertFailNotObjectProvider() { - return array( - array('foo'), - array('bar'), - array(123), - array(true), - array(array()), - ); + return [ + ['foo'], + ['bar'], + [123], + [true], + [[]], + ]; } /** * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Converter\PagePartsConverter::convert - * @expectedException \InvalidArgumentException */ public function testConvertFailWrongType() { + $this->expectException(\InvalidArgumentException::class); + $converter = new PagePartsConverter(); $converter->convert($this->createMock(ValueObject::class)); } diff --git a/mvc/Templating/Tests/GlobalHelperTest.php b/mvc/Templating/Tests/GlobalHelperTest.php index 6846f993..91796109 100644 --- a/mvc/Templating/Tests/GlobalHelperTest.php +++ b/mvc/Templating/Tests/GlobalHelperTest.php @@ -24,7 +24,7 @@ protected function setUp() parent::setUp(); $this->legacyHelper = $this->getMockBuilder(LegacyHelper::class) ->setConstructorArgs([ - function () { + static function () { }, ]) ->setMethods([]) diff --git a/mvc/Templating/Tests/LegacyEngineTest.php b/mvc/Templating/Tests/LegacyEngineTest.php index 8e153d9d..88d05107 100644 --- a/mvc/Templating/Tests/LegacyEngineTest.php +++ b/mvc/Templating/Tests/LegacyEngineTest.php @@ -23,7 +23,7 @@ protected function setUp() { parent::setUp(); $this->engine = new LegacyEngine( - function () { + static function () { }, $this->createMock(MultipleObjectConverter::class) ); @@ -44,14 +44,14 @@ public function testSupports($tplName, $expected) public function supportTestProvider() { - return array( - array('design:foo/bar.tpl', true), - array('file:some/path.tpl', true), - array('unsupported.php', false), - array('unsupported.tpl', false), - array('design:unsupported.php', false), - array('design:foo/bar.php', false), - array('file:some/path.php', false), - ); + return [ + ['design:foo/bar.tpl', true], + ['file:some/path.tpl', true], + ['unsupported.php', false], + ['unsupported.tpl', false], + ['design:unsupported.php', false], + ['design:foo/bar.php', false], + ['file:some/path.php', false], + ]; } } diff --git a/mvc/Templating/Tests/Twig/EnvironmentTest.php b/mvc/Templating/Tests/Twig/EnvironmentTest.php index 4d2b9512..1943ae5f 100644 --- a/mvc/Templating/Tests/Twig/EnvironmentTest.php +++ b/mvc/Templating/Tests/Twig/EnvironmentTest.php @@ -48,11 +48,11 @@ public function testLoadTemplateLegacy() /** * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Environment::loadTemplate * @covers \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Template::getTemplateName - * - * @expectedException \Twig_Error_Loader */ public function testLoadNonExistingTemplateLegacy() { + $this->expectException(\Twig_Error_Loader::class); + $legacyEngine = $this->createMock(LegacyEngine::class); $templateName = 'design:test/helloworld.tpl'; diff --git a/mvc/Templating/Tests/Twig/LoaderStringTest.php b/mvc/Templating/Tests/Twig/LoaderStringTest.php index 971c2bc0..0c948f5a 100644 --- a/mvc/Templating/Tests/Twig/LoaderStringTest.php +++ b/mvc/Templating/Tests/Twig/LoaderStringTest.php @@ -35,7 +35,7 @@ public function testGetCacheKey() public function testIsFresh() { $loaderString = new LoaderString(); - $this->assertSame(true, $loaderString->isFresh('foo', time())); + $this->assertTrue($loaderString->isFresh('foo', time())); } /** @@ -49,13 +49,13 @@ public function testExists($name, $expectedResult) public function existsProvider() { - return array( - array('foo.html.twig', false), - array('foo/bar/baz.txt.twig', false), - array('SOMETHING.HTML.tWiG', false), - array('foo', true), - array('Hey, I love twig', true), - array('Hey, I love Twig', true), - ); + return [ + ['foo.html.twig', false], + ['foo/bar/baz.txt.twig', false], + ['SOMETHING.HTML.tWiG', false], + ['foo', true], + ['Hey, I love twig', true], + ['Hey, I love Twig', true], + ]; } } diff --git a/mvc/Templating/Tests/Twig/TemplateTest.php b/mvc/Templating/Tests/Twig/TemplateTest.php index 30affd64..31e7479a 100644 --- a/mvc/Templating/Tests/Twig/TemplateTest.php +++ b/mvc/Templating/Tests/Twig/TemplateTest.php @@ -53,7 +53,7 @@ public function testGetName() */ public function testRender() { - $tplParams = array('foo' => 'bar', 'truc' => 'muche'); + $tplParams = ['foo' => 'bar', 'truc' => 'muche']; $this->legacyEngine ->expects($this->once()) ->method('render') diff --git a/mvc/Templating/Twig/Environment.php b/mvc/Templating/Twig/Environment.php index aa7694b0..18c33a29 100644 --- a/mvc/Templating/Twig/Environment.php +++ b/mvc/Templating/Twig/Environment.php @@ -24,7 +24,7 @@ class Environment extends Twig_Environment * * @var \eZ\Publish\Core\MVC\Legacy\Templating\Twig\Template[] */ - protected $legacyTemplatesCache = array(); + protected $legacyTemplatesCache = []; public function setEzLegacyEngine(LegacyEngine $legacyEngine) { @@ -34,11 +34,11 @@ public function setEzLegacyEngine(LegacyEngine $legacyEngine) public function loadTemplate($name, $index = null) { // If legacy engine supports given template, delegate it. - if (is_string($name) && isset($this->legacyTemplatesCache[$name])) { + if (\is_string($name) && isset($this->legacyTemplatesCache[$name])) { return $this->legacyTemplatesCache[$name]; } - if (is_string($name) && $this->legacyEngine->supports($name)) { + if (\is_string($name) && $this->legacyEngine->supports($name)) { if (!$this->legacyEngine->exists($name)) { throw new Twig_Error_Loader("Unable to find the template \"$name\""); } diff --git a/mvc/Templating/Twig/Extension/LegacyExtension.php b/mvc/Templating/Twig/Extension/LegacyExtension.php index 014aff6a..61f0295f 100644 --- a/mvc/Templating/Twig/Extension/LegacyExtension.php +++ b/mvc/Templating/Twig/Extension/LegacyExtension.php @@ -65,16 +65,16 @@ public function __construct( * * @deprecated since 5.1 */ - public function renderTemplate($tplPath, array $params = array()) + public function renderTemplate($tplPath, array $params = []) { return $this->legacyEngine->render($tplPath, $params); } public function getTokenParsers() { - return array( + return [ new LegacyIncludeParser(), - ); + ]; } /** @@ -84,7 +84,7 @@ public function getTokenParsers() */ public function getName() { - return get_class($this); + return \get_class($this); } /** @@ -104,18 +104,18 @@ public function initRuntime(Twig_Environment $environment) */ public function getFunctions() { - return array( + return [ new Twig_SimpleFunction( 'ez_legacy_render_js', - array($this, 'renderLegacyJs'), - array('is_safe' => array('html')) + [$this, 'renderLegacyJs'], + ['is_safe' => ['html']] ), new Twig_SimpleFunction( 'ez_legacy_render_css', - array($this, 'renderLegacyCss'), - array('is_safe' => array('html')) + [$this, 'renderLegacyCss'], + ['is_safe' => ['html']] ), - ); + ]; } /** @@ -125,10 +125,10 @@ public function getFunctions() */ public function renderLegacyJs() { - $jsFiles = array(); - $jsCodeLines = array(); + $jsFiles = []; + $jsCodeLines = []; - foreach ($this->legacyHelper->get('js_files', array()) as $jsItem) { + foreach ($this->legacyHelper->get('js_files', []) as $jsItem) { // List of items can contain empty elements, path to files or code if (!empty($jsItem)) { if (isset($jsItem[4]) && $this->isFile($jsItem, '.js')) { @@ -141,10 +141,10 @@ public function renderLegacyJs() return $this->environment->render( $this->jsTemplate, - array( + [ 'js_files' => $jsFiles, 'js_code_lines' => $jsCodeLines, - ) + ] ); } @@ -155,10 +155,10 @@ public function renderLegacyJs() */ public function renderLegacyCss() { - $cssFiles = array(); - $cssCodeLines = array(); + $cssFiles = []; + $cssCodeLines = []; - foreach ($this->legacyHelper->get('css_files', array()) as $cssItem) { + foreach ($this->legacyHelper->get('css_files', []) as $cssItem) { // List of items can contain empty elements, path to files or code if (!empty($cssItem)) { if (isset($cssItem[5]) && $this->isFile($cssItem, '.css')) { @@ -171,10 +171,10 @@ public function renderLegacyCss() return $this->environment->render( $this->cssTemplate, - array( + [ 'css_files' => $cssFiles, 'css_code_lines' => $cssCodeLines, - ) + ] ); } @@ -191,6 +191,6 @@ private function isFile($item, $extension) return strpos($item, 'http://') === 0 || strpos($item, 'https://') === 0 - || strripos($item, $extension) === (strlen($item) - strlen($extension)); + || strripos($item, $extension) === (\strlen($item) - \strlen($extension)); } } diff --git a/mvc/Templating/Twig/LoaderString.php b/mvc/Templating/Twig/LoaderString.php index 8e249d8c..dbe7e70a 100644 --- a/mvc/Templating/Twig/LoaderString.php +++ b/mvc/Templating/Twig/LoaderString.php @@ -61,7 +61,7 @@ public function isFresh($name, $time) public function exists($name) { $suffix = '.twig'; - $endsWithSuffix = strtolower(substr($name, -strlen($suffix))) === $suffix; + $endsWithSuffix = strtolower(substr($name, -\strlen($suffix))) === $suffix; return !$endsWithSuffix; } diff --git a/mvc/Templating/Twig/Node/LegacyIncludeNode.php b/mvc/Templating/Twig/Node/LegacyIncludeNode.php index de61286f..aa074c3c 100644 --- a/mvc/Templating/Twig/Node/LegacyIncludeNode.php +++ b/mvc/Templating/Twig/Node/LegacyIncludeNode.php @@ -22,11 +22,11 @@ class LegacyIncludeNode extends Twig_Node public function __construct(Twig_Node_Expression $tplPath, Twig_Node_Expression $params, $lineno, $tag = null) { return parent::__construct( - array( + [ 'tplPath' => $tplPath, 'params' => $params, - ), - array(), + ], + [], $lineno, $tag ); diff --git a/mvc/Templating/Twig/Template.php b/mvc/Templating/Twig/Template.php index 8df36efe..23ef50b0 100644 --- a/mvc/Templating/Twig/Template.php +++ b/mvc/Templating/Twig/Template.php @@ -50,7 +50,7 @@ public function render(array $context) * @param array $context An array of parameters to pass to the template * @param array $blocks An array of blocks to pass to the template */ - public function display(array $context, array $blocks = array()) + public function display(array $context, array $blocks = []) { echo $this->render($context); } @@ -68,7 +68,7 @@ public function getTemplateName() */ public function getDebugInfo() { - return array(); + return []; } /** @@ -82,7 +82,7 @@ public function getSource() /** * {@inheritdoc} */ - protected function doDisplay(array $context, array $blocks = array()) + protected function doDisplay(array $context, array $blocks = []) { } } diff --git a/mvc/Templating/Twig/TokenParser/LegacyIncludeParser.php b/mvc/Templating/Twig/TokenParser/LegacyIncludeParser.php index 3dd86c56..edc42cfb 100644 --- a/mvc/Templating/Twig/TokenParser/LegacyIncludeParser.php +++ b/mvc/Templating/Twig/TokenParser/LegacyIncludeParser.php @@ -40,7 +40,7 @@ public function parse(Twig_Token $token) $stream->next(); $params = $exprParser->parseExpression(); } else { - $params = new Twig_Node_Expression_Array(array(), $token->getLine()); + $params = new Twig_Node_Expression_Array([], $token->getLine()); } $stream->expect(Twig_Token::BLOCK_END_TYPE); diff --git a/mvc/Tests/Event/PostBuildKernelEventTest.php b/mvc/Tests/Event/PostBuildKernelEventTest.php index 180e8798..bfb1a18c 100644 --- a/mvc/Tests/Event/PostBuildKernelEventTest.php +++ b/mvc/Tests/Event/PostBuildKernelEventTest.php @@ -20,7 +20,7 @@ public function testConstruct() $kernelHandler = $this->createMock(ezpKernelHandler::class); $legacyKernel = $this ->getMockBuilder(Kernel::class) - ->setConstructorArgs(array($kernelHandler, 'foo', 'bar')) + ->setConstructorArgs([$kernelHandler, 'foo', 'bar']) ->getMock(); $event = new PostBuildKernelEvent($legacyKernel, $kernelHandler); $this->assertSame($legacyKernel, $event->getLegacyKernel()); diff --git a/mvc/Tests/KernelTest.php b/mvc/Tests/KernelTest.php index ac47d711..e07df664 100644 --- a/mvc/Tests/KernelTest.php +++ b/mvc/Tests/KernelTest.php @@ -33,7 +33,7 @@ public function testRunCallbackWithException() $iterations = 1; do { try { - $this->getLegacyKernel()->runCallback(function () {}); + $this->getLegacyKernel()->runCallback(static function () {}); } // this will occur on the 2nd iteration if the kernel state hasn't been correctly reset catch (RuntimeException $e) { diff --git a/mvc/Tests/Security/SSOListenerTest.php b/mvc/Tests/Security/SSOListenerTest.php index efac2bd0..fc9460c0 100644 --- a/mvc/Tests/Security/SSOListenerTest.php +++ b/mvc/Tests/Security/SSOListenerTest.php @@ -57,7 +57,7 @@ protected function setUp() ); $legacyKernel = $this->legacyKernel = $this->createMock(ezpKernelHandler::class); - $this->legacyKernelClosure = function () use ($legacyKernel) { + $this->legacyKernelClosure = static function () use ($legacyKernel) { return $legacyKernel; }; @@ -82,7 +82,7 @@ public function testGetPreAuthenticatedDataNoUser() $refListener = new ReflectionObject($this->ssoListener); $refMethod = $refListener->getMethod('getPreAuthenticatedData'); $refMethod->setAccessible(true); - $this->assertSame(array('', ''), $refMethod->invoke($this->ssoListener, new Request())); + $this->assertSame(['', ''], $refMethod->invoke($this->ssoListener, new Request())); } public function testGetPreAuthenticatedData() @@ -93,23 +93,23 @@ public function testGetPreAuthenticatedData() $userId = 123; $passwordHash = md5('password'); // Specifically silence E_DEPRECATED on constructor name for php7 - $legacyUser = @new eZUser(array('contentobject_id' => $userId)); + $legacyUser = @new eZUser(['contentobject_id' => $userId]); $apiUser = new CoreUser( - array( + [ 'passwordHash' => $passwordHash, 'content' => new Content( - array( + [ 'versionInfo' => new VersionInfo( - array( + [ 'contentInfo' => new ContentInfo(), - ) + ] ), - ) + ] ), - ) + ] ); - $finalUser = new User($apiUser, array('ROLE_USER')); + $finalUser = new User($apiUser, ['ROLE_USER']); $this->userService ->expects($this->once()) @@ -126,6 +126,6 @@ public function testGetPreAuthenticatedData() $refListener = new ReflectionObject($this->ssoListener); $refMethod = $refListener->getMethod('getPreAuthenticatedData'); $refMethod->setAccessible(true); - $this->assertEquals(array($finalUser, $passwordHash), $refMethod->invoke($this->ssoListener, new Request())); + $this->assertEquals([$finalUser, $passwordHash], $refMethod->invoke($this->ssoListener, new Request())); } } diff --git a/mvc/Tests/SignalSlot/LegacySlotsTest.php b/mvc/Tests/SignalSlot/LegacySlotsTest.php index 3524308e..868dacb5 100644 --- a/mvc/Tests/SignalSlot/LegacySlotsTest.php +++ b/mvc/Tests/SignalSlot/LegacySlotsTest.php @@ -67,28 +67,28 @@ public function testAbstractLegacySlot() public function providerForTestLegacySlots() { - return array( - array('LegacyAssignSectionSlot', 'SectionService\\AssignSectionSignal', array()), - array('LegacyCopyContentSlot', 'ContentService\\CopyContentSignal', array()), - array('LegacyCreateLocationSlot', 'LocationService\\CreateLocationSignal', array()), - array('LegacyDeleteContentSlot', 'ContentService\\DeleteContentSignal', array()), - array('LegacyDeleteLocationSlot', 'LocationService\\DeleteLocationSignal', array()), - array('LegacyDeleteVersionSlot', 'ContentService\\DeleteVersionSignal', array()), - array('LegacyHideLocationSlot', 'LocationService\\HideLocationSignal', array()), - array('LegacyMoveSubtreeSlot', 'LocationService\\MoveSubtreeSignal', array()), - array('LegacyPublishVersionSlot', 'ContentService\\PublishVersionSignal', array()), - array('LegacySetContentStateSlot', 'ObjectStateService\\SetContentStateSignal', array()), - array('LegacySwapLocationSlot', 'LocationService\\SwapLocationSignal', array()), - array('LegacyUnhideLocationSlot', 'LocationService\\UnhideLocationSignal', array()), - array('LegacyUpdateLocationSlot', 'LocationService\\UpdateLocationSignal', array()), - array('LegacyPublishContentTypeDraftSlot', 'ContentTypeService\\PublishContentTypeDraftSignal', array()), - ); + return [ + ['LegacyAssignSectionSlot', 'SectionService\\AssignSectionSignal', []], + ['LegacyCopyContentSlot', 'ContentService\\CopyContentSignal', []], + ['LegacyCreateLocationSlot', 'LocationService\\CreateLocationSignal', []], + ['LegacyDeleteContentSlot', 'ContentService\\DeleteContentSignal', []], + ['LegacyDeleteLocationSlot', 'LocationService\\DeleteLocationSignal', []], + ['LegacyDeleteVersionSlot', 'ContentService\\DeleteVersionSignal', []], + ['LegacyHideLocationSlot', 'LocationService\\HideLocationSignal', []], + ['LegacyMoveSubtreeSlot', 'LocationService\\MoveSubtreeSignal', []], + ['LegacyPublishVersionSlot', 'ContentService\\PublishVersionSignal', []], + ['LegacySetContentStateSlot', 'ObjectStateService\\SetContentStateSignal', []], + ['LegacySwapLocationSlot', 'LocationService\\SwapLocationSignal', []], + ['LegacyUnhideLocationSlot', 'LocationService\\UnhideLocationSignal', []], + ['LegacyUpdateLocationSlot', 'LocationService\\UpdateLocationSignal', []], + ['LegacyPublishContentTypeDraftSlot', 'ContentTypeService\\PublishContentTypeDraftSignal', []], + ]; } /** * @dataProvider providerForTestLegacySlots */ - public function testLegacySlotsValidSignal($slotName, $signalName, array $signalProperties = array()) + public function testLegacySlotsValidSignal($slotName, $signalName, array $signalProperties = []) { $ezpKernelHandlerMock = $this->ezpKernelHandlerMock; $signalClassName = self::SIGNAL_SLOT_NS . '\\Signal\\' . $signalName; @@ -98,7 +98,7 @@ public function testLegacySlotsValidSignal($slotName, $signalName, array $signal * @var \eZ\Publish\Core\SignalSlot\Slot */ $slot = new $slotClassName( - function () use ($ezpKernelHandlerMock) { + static function () use ($ezpKernelHandlerMock) { return $ezpKernelHandlerMock; }, $this->persistenceCachePurgerMock, @@ -129,7 +129,7 @@ public function testLegacySlotsInValidSignal($slotName) * @var \eZ\Publish\Core\SignalSlot\Slot */ $slot = new $slotClassName( - function () use ($ezpKernelHandlerMock) { + static function () use ($ezpKernelHandlerMock) { return $ezpKernelHandlerMock; }, $this->persistenceCachePurgerMock, diff --git a/mvc/View/Provider/Block.php b/mvc/View/Provider/Block.php index 8691e2b8..245b03f5 100644 --- a/mvc/View/Provider/Block.php +++ b/mvc/View/Provider/Block.php @@ -49,9 +49,9 @@ public function getView(View $view) $block = $view->getBlock(); $legacyKernel = $this->getLegacyKernel(); - $legacyBlockClosure = function (array $params) use ($block, $legacyKernel) { + $legacyBlockClosure = static function (array $params) use ($block, $legacyKernel) { return $legacyKernel->runCallback( - function () use ($block, $params) { + static function () use ($block, $params) { $tpl = eZTemplate::factory(); /** * @var \eZObjectForwarder @@ -61,12 +61,12 @@ function () use ($block, $params) { return ''; } - $children = array(); + $children = []; $funcObject->process( $tpl, $children, 'block_view_gui', false, - array( - 'block' => array( - array( + [ + 'block' => [ + [ eZTemplate::TYPE_ARRAY, // eZTemplate::TYPE_OBJECT does not exist because // it's not possible to create "inline" objects in @@ -77,12 +77,12 @@ function () use ($block, $params) { // (TYPE_STRING, TYPE_BOOLEAN, ... have the same // behaviour, see eZTemplate::elementValue()) new BlockAdapter($block), - ), - ), - ), - array(), '', '' + ], + ], + ], + [], '', '' ); - if (is_array($children) && isset($children[0])) { + if (\is_array($children) && isset($children[0])) { return ezpEvent::getInstance()->filter('response/output', $children[0]); } diff --git a/mvc/View/Provider/Content.php b/mvc/View/Provider/Content.php index 848e33b1..8a957346 100644 --- a/mvc/View/Provider/Content.php +++ b/mvc/View/Provider/Content.php @@ -76,12 +76,12 @@ function () use ($contentInfo, $viewType, $params) { ); } - $children = array(); + $children = []; $funcObject->process( $tpl, $children, 'content_view_gui', false, - array( - 'content_object' => array( - array( + [ + 'content_object' => [ + [ eZTemplate::TYPE_ARRAY, // eZTemplate::TYPE_OBJECT does not exist because // it's not possible to create "inline" objects in @@ -92,18 +92,18 @@ function () use ($contentInfo, $viewType, $params) { // (TYPE_STRING, TYPE_BOOLEAN, ... have the same // behaviour, see eZTemplate::elementValue()) eZContentObject::fetch($contentInfo->id), - ), - ), - 'view' => array( - array( + ], + ], + 'view' => [ + [ eZTemplate::TYPE_STRING, $viewType, - ), - ), - ), - array(), '', '' + ], + ], + ], + [], '', '' ); - if (is_array($children) && isset($children[0])) { + if (\is_array($children) && isset($children[0])) { return ezpEvent::getInstance()->filter('response/output', $children[0]); } @@ -129,7 +129,7 @@ function () use ($contentInfo, $viewType, $params) { */ protected function legalizeLinkParameters(array $linkParameters) { - $parameters = array(); + $parameters = []; if (isset($linkParameters['href'])) { $parameters['href'] = $linkParameters['href']; diff --git a/mvc/View/Provider/Location.php b/mvc/View/Provider/Location.php index b195b92c..2ff30436 100644 --- a/mvc/View/Provider/Location.php +++ b/mvc/View/Provider/Location.php @@ -41,16 +41,16 @@ public function getView(View $view) $logger = $this->logger; $legacyHelper = $this->legacyHelper; $currentViewProvider = $this; - $viewParameters = array(); + $viewParameters = []; $request = $this->getCurrentRequest(); if (isset($request)) { - $viewParameters = $request->attributes->get('viewParameters', array()); + $viewParameters = $request->attributes->get('viewParameters', []); } $viewType = $view->getViewType(); $location = $view->getLocation(); - $legacyContentClosure = function (array $params) use ($location, $viewType, $logger, $legacyHelper, $viewParameters, $currentViewProvider) { + $legacyContentClosure = static function (array $params) use ($location, $viewType, $logger, $legacyHelper, $viewParameters, $currentViewProvider) { $content = isset($params['content']) ? $params['content'] : null; // Additional parameters (aka user parameters in legacy) are expected to be scalar foreach ($params as $paramName => $param) { @@ -59,7 +59,7 @@ public function getView(View $view) if (isset($logger)) { $logger->notice( "'$paramName' is not scalar, cannot pass it to legacy content module. Skipping.", - array(__METHOD__) + [__METHOD__] ); } } @@ -96,15 +96,15 @@ public function getView(View $view) */ public function renderPublishedView(APILocation $location, $viewType, array $params, LegacyHelper $legacyHelper) { - $moduleResult = array(); + $moduleResult = []; // Filling up moduleResult $result = $this->getLegacyKernel()->runCallback( - function () use ($location, $viewType, $params, &$moduleResult) { + static function () use ($location, $viewType, $params, &$moduleResult) { $contentViewModule = eZModule::findModule('content'); $moduleResult = $contentViewModule->run( 'view', - array($viewType, $location->id), + [$viewType, $location->id], false, $params ); @@ -132,17 +132,17 @@ public function renderPreview(APIContent $content, array $params, LegacyHelper $ { /** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess $siteAccess */ $siteAccess = $this->getCurrentRequest()->attributes->get('siteaccess'); - $moduleResult = array(); + $moduleResult = []; // Filling up moduleResult $result = $this->getLegacyKernel()->runCallback( - function () use ($content, $params, $siteAccess, &$moduleResult) { + static function () use ($content, $params, $siteAccess, &$moduleResult) { $contentViewModule = eZModule::findModule('content'); $moduleResult = $contentViewModule->run( 'versionview', - array($content->contentInfo->id, $content->getVersionInfo()->versionNo, $content->getVersionInfo()->languageCodes[0]), + [$content->contentInfo->id, $content->getVersionInfo()->versionNo, $content->getVersionInfo()->languageCodes[0]], false, - array('site_access' => $siteAccess->name) + $params + ['site_access' => $siteAccess->name] + $params ); return ezpEvent::getInstance()->filter('response/output', $moduleResult['content']); diff --git a/mvc/View/TwigContentViewLayoutDecorator.php b/mvc/View/TwigContentViewLayoutDecorator.php index 00b260b5..300d1946 100644 --- a/mvc/View/TwigContentViewLayoutDecorator.php +++ b/mvc/View/TwigContentViewLayoutDecorator.php @@ -36,7 +36,7 @@ class TwigContentViewLayoutDecorator implements View /** * @var array */ - protected $configHash = array(); + protected $configHash = []; /** * @var \eZ\Publish\Core\MVC\ConfigResolverInterface @@ -61,7 +61,7 @@ class TwigContentViewLayoutDecorator implements View public function __construct(Twig_Environment $twig, array $options, ConfigResolverInterface $configResolver) { $this->twig = $twig; - $this->options = $options + array('contentBlockName' => 'content'); + $this->options = $options + ['contentBlockName' => 'content']; $this->configResolver = $configResolver; } @@ -108,7 +108,7 @@ public function getTemplateIdentifier() $twig = $this->twig; $layout = $this->configResolver->getParameter('view_default_layout', 'ezpublish_legacy'); - return function (array $params) use ($options, $contentView, $twig, $layout) { + return static function (array $params) use ($options, $contentView, $twig, $layout) { $contentViewClosure = $contentView->getTemplateIdentifier(); if (isset($params['noLayout']) && $params['noLayout']) { $layout = $options['viewbaseLayout']; @@ -123,9 +123,9 @@ public function getTemplateIdentifier() return $twig->render( $twigContentTemplate, - $params + array( + $params + [ 'viewResult' => $contentViewClosure($params), - ) + ] ); }; }