Skip to content

Commit

Permalink
Update CS standard and fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Mar 14, 2019
1 parent 12670a8 commit 13c75de
Show file tree
Hide file tree
Showing 125 changed files with 1,177 additions and 1,175 deletions.
6 changes: 5 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions bundle/Cache/LegacyCachePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
Expand Down
2 changes: 1 addition & 1 deletion bundle/Cache/LegacySwitchableHttpCachePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions bundle/Cache/PersistenceCachePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion bundle/Cache/SwitchableHttpCachePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions bundle/Collector/TemplateDebugInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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;
}

try {
$templateStats = $legacyKernel()->runCallback(
function () {
static function () {
if (eZTemplate::isTemplatesUsageStatisticsEnabled()) {
return eZTemplate::templatesUsageStatistics();
} else {
Expand All @@ -53,18 +53,18 @@ 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) {
$requestedTpl = $tplInfo['requested-template-name'];
$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 {
Expand Down
8 changes: 4 additions & 4 deletions bundle/Command/LegacyBundleInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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'), '/');

Expand Down
4 changes: 2 additions & 2 deletions bundle/Command/LegacyConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion bundle/Command/LegacyEmbedScriptCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
8 changes: 4 additions & 4 deletions bundle/Command/LegacyInitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions bundle/Command/LegacySrcSymlinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions bundle/Command/LegacyWrapperInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions bundle/Controller/LegacyRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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') : []
);
}
}
18 changes: 9 additions & 9 deletions bundle/Controller/LegacySetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
),
)
],
],
]
);
}
);
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/Controller/LegacyTreeMenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions bundle/Controller/WebsiteToolbarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion bundle/DependencyInjection/Compiler/LegacyBundlesPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions bundle/DependencyInjection/Compiler/LegacyPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function process(ContainerBuilder $container)

$definition->addMethodCall(
'addConverter',
array(
[
new Reference($id),
$attribute['for'],
)
]
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')]);
}
}
2 changes: 1 addition & 1 deletion bundle/DependencyInjection/Compiler/TwigPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]);
}
}
2 changes: 1 addition & 1 deletion bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getConfigTreeBuilder()
->scalarNode('root_dir')
->validate()
->ifTrue(
function ($v) {
static function ($v) {
return !file_exists($v);
}
)
Expand Down
Loading

0 comments on commit 13c75de

Please sign in to comment.