diff --git a/.drone.yml b/.drone.yml index a75913ff3bab..e7afa44165c8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,6 +27,7 @@ steps: depends_on: [ composer ] commands: - echo $(date) + - ./libraries/vendor/bin/php-cs-fixer fix -vvv --dry-run - ./libraries/vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml . - echo $(date) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 67e4aee1f962..69c9a61acd05 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -29,18 +29,8 @@ * ./libraries/vendor/bin/php-cs-fixer fix administrator/index.php */ -// Only index the files in /libraries and no deeper, to prevent /libraries/vendor being indexed -$topFilesFinder = PhpCsFixer\Finder::create() - ->in( - [ - __DIR__ . '/libraries' - ] - ) - ->files() - ->depth(0); - -// Add all the core Joomla folders and append to this list the files indexed above from /libraries -$mainFinder = PhpCsFixer\Finder::create() +// Add all the core Joomla folders +$finder = PhpCsFixer\Finder::create() ->in( [ __DIR__ . '/administrator', @@ -57,20 +47,39 @@ __DIR__ . '/plugins', __DIR__ . '/templates', __DIR__ . '/tests', - __DIR__ . '/layouts', ] ) - ->append($topFilesFinder); + // Ignore template files as PHP CS fixer can't handle them properly + // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/3702#issuecomment-396717120 + ->notPath('/tmpl/') + ->notPath('/layouts/') + ->notPath('/cassiopeia/') + ->notPath('/atum/') + // Ignore psr12 scripts because they contain invalid syntax + ->notPath('/psr12/') + ->notName('github_rebase.php'); $config = new PhpCsFixer\Config(); $config ->setRiskyAllowed(true) + ->setHideProgress(false) + ->setUsingCache(false) ->setRules( [ - '@PSR12' => true, - 'array_syntax' => ['syntax' => 'short'], + // Basic ruleset is PSR 12 + '@PSR12' => true, + // Short array syntax + 'array_syntax' => ['syntax' => 'short'], + // Lists should not have a trailing comma like list($foo, $bar,) = ... + 'no_trailing_comma_in_list_call' => true, + // Arrays on multiline should have a trailing comma + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + // Align elements in multiline array and variable declarations on new lines below each other + 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align']], + // The "No break" comment in switch statements + 'no_break_comment' => ['comment_text' => 'No break'], ] ) - ->setFinder($mainFinder); + ->setFinder($finder); return $config; diff --git a/administrator/components/com_actionlogs/services/provider.php b/administrator/components/com_actionlogs/services/provider.php index 3d81708bd9fe..6f6c54d9c4bc 100644 --- a/administrator/components/com_actionlogs/services/provider.php +++ b/administrator/components/com_actionlogs/services/provider.php @@ -24,8 +24,7 @@ * * @since 4.0.0 */ -return new class implements ServiceProviderInterface -{ +return new class () implements ServiceProviderInterface { /** * Registers the service provider with a DI container. * diff --git a/administrator/components/com_actionlogs/src/Field/LogtypeField.php b/administrator/components/com_actionlogs/src/Field/LogtypeField.php index b3ae4c96ef18..d55071386192 100644 --- a/administrator/components/com_actionlogs/src/Field/LogtypeField.php +++ b/administrator/components/com_actionlogs/src/Field/LogtypeField.php @@ -55,7 +55,7 @@ public function getOptions() foreach ($extensions as $extension) { ActionlogsHelper::loadTranslationFiles($extension); - $extensionName = Text::_($extension); + $extensionName = Text::_($extension); $options[ApplicationHelper::stringURLSafe($extensionName) . '_' . $extension] = HTMLHelper::_('select.option', $extension, $extensionName); } diff --git a/administrator/components/com_actionlogs/src/Helper/ActionlogsHelper.php b/administrator/components/com_actionlogs/src/Helper/ActionlogsHelper.php index af6254ef0bab..0fc9ca67b0eb 100644 --- a/administrator/components/com_actionlogs/src/Helper/ActionlogsHelper.php +++ b/administrator/components/com_actionlogs/src/Helper/ActionlogsHelper.php @@ -78,7 +78,7 @@ public static function getCsvData($data): Generator 'extension' => self::escapeCsvFormula(Text::_($extension)), 'date' => (new Date($log->log_date, new \DateTimeZone('UTC')))->format('Y-m-d H:i:s T'), 'name' => self::escapeCsvFormula($log->name), - 'ip_address' => self::escapeCsvFormula($log->ip_address === 'COM_ACTIONLOGS_DISABLED' ? $disabledText : $log->ip_address) + 'ip_address' => self::escapeCsvFormula($log->ip_address === 'COM_ACTIONLOGS_DISABLED' ? $disabledText : $log->ip_address), ]; } } @@ -95,7 +95,7 @@ public static function getCsvData($data): Generator public static function loadTranslationFiles($extension) { static $cache = []; - $extension = strtolower($extension); + $extension = strtolower($extension); if (isset($cache[$extension])) { return; @@ -277,13 +277,13 @@ public static function loadActionLogPluginsLanguage() 'folder', 'element', 'params', - 'extension_id' + 'extension_id', ], [ 'type', 'name', 'params', - 'id' + 'id', ] ) ) diff --git a/administrator/components/com_actionlogs/src/Model/ActionlogModel.php b/administrator/components/com_actionlogs/src/Model/ActionlogModel.php index b0edc5b45d83..fbf7acd1f4ac 100644 --- a/administrator/components/com_actionlogs/src/Model/ActionlogModel.php +++ b/administrator/components/com_actionlogs/src/Model/ActionlogModel.php @@ -145,16 +145,16 @@ protected function sendNotificationEmails($messages, $username, $context) $temp = []; foreach ($messages as $message) { - $m = []; + $m = []; $m['extension'] = Text::_($extension); $m['message'] = ActionlogsHelper::getHumanReadableLogMessage($message); $m['date'] = HTMLHelper::_('date', $message->log_date, 'Y-m-d H:i:s T', 'UTC'); $m['username'] = $username; - $temp[] = $m; + $temp[] = $m; } $templateData = [ - 'messages' => $temp + 'messages' => $temp, ]; $mailer = new MailTemplate('com_actionlogs.notification', $app->getLanguage()->getTag()); diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 0c574e3d90ed..bd51061c51e1 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -307,10 +307,10 @@ protected function uninstallRepeatableFieldsPlugin() * for each of the sub fields of the `repeatable` instance. */ $data = [ - 'context' => $row->context, - 'group_id' => $row->group_id, - 'title' => $oldField->fieldname, - 'name' => ( + 'context' => $row->context, + 'group_id' => $row->group_id, + 'title' => $oldField->fieldname, + 'name' => ( $fieldname_prefix . $oldField->fieldname . ($fieldname_suffix > 0 ? ('_' . $fieldname_suffix) : '') @@ -7886,7 +7886,7 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false) '/libraries/vendor/paragonie/sodium_compat/dist', ]; - $status['files_checked'] = $files; + $status['files_checked'] = $files; $status['folders_checked'] = $folders; foreach ($files as $file) { @@ -8351,7 +8351,7 @@ private function contactItems(Table $tableItem): array 'client_id' => 1, 'publish_up' => null, 'publish_down' => null, - ] + ], ]; return $menuItems; @@ -8510,7 +8510,7 @@ private function finderItems(Table $tableItem): array 'client_id' => 1, 'publish_up' => null, 'publish_down' => null, - ] + ], ]; return $menuItems; @@ -8543,7 +8543,7 @@ private function updateContentTypes(): void ]; // Get table definitions. - $db = Factory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( [ @@ -8612,7 +8612,7 @@ protected function fixFilenameCasing() $files = [ // 3.10 changes '/libraries/src/Filesystem/Support/Stringcontroller.php' => '/libraries/src/Filesystem/Support/StringController.php', - '/libraries/src/Form/Rule/SubFormRule.php' => '/libraries/src/Form/Rule/SubformRule.php', + '/libraries/src/Form/Rule/SubFormRule.php' => '/libraries/src/Form/Rule/SubformRule.php', // 4.0.0 '/media/vendor/skipto/js/skipTo.js' => '/media/vendor/skipto/js/skipto.js', ]; @@ -8668,14 +8668,14 @@ protected function fixFilenameCasing() protected function moveRemainingTemplateFiles() { $folders = [ - '/administrator/templates/atum/css' => '/media/templates/administrator/atum/css', + '/administrator/templates/atum/css' => '/media/templates/administrator/atum/css', '/administrator/templates/atum/images' => '/media/templates/administrator/atum/images', - '/administrator/templates/atum/js' => '/media/templates/administrator/atum/js', - '/administrator/templates/atum/scss' => '/media/templates/administrator/atum/scss', - '/templates/cassiopeia/css' => '/media/templates/site/cassiopeia/css', - '/templates/cassiopeia/images' => '/media/templates/site/cassiopeia/images', - '/templates/cassiopeia/js' => '/media/templates/site/cassiopeia/js', - '/templates/cassiopeia/scss' => '/media/templates/site/cassiopeia/scss', + '/administrator/templates/atum/js' => '/media/templates/administrator/atum/js', + '/administrator/templates/atum/scss' => '/media/templates/administrator/atum/scss', + '/templates/cassiopeia/css' => '/media/templates/site/cassiopeia/css', + '/templates/cassiopeia/images' => '/media/templates/site/cassiopeia/images', + '/templates/cassiopeia/js' => '/media/templates/site/cassiopeia/js', + '/templates/cassiopeia/scss' => '/media/templates/site/cassiopeia/scss', ]; foreach ($folders as $oldFolder => $newFolder) { diff --git a/administrator/components/com_admin/services/provider.php b/administrator/components/com_admin/services/provider.php index d17a3d0cc5fa..33f2e9783890 100644 --- a/administrator/components/com_admin/services/provider.php +++ b/administrator/components/com_admin/services/provider.php @@ -25,8 +25,7 @@ * * @since 4.0.0 */ -return new class implements ServiceProviderInterface -{ +return new class () implements ServiceProviderInterface { /** * Registers the service provider with a DI container. * diff --git a/administrator/components/com_admin/src/Model/HelpModel.php b/administrator/components/com_admin/src/Model/HelpModel.php index 7572d9b7aadf..e93a2384f475 100644 --- a/administrator/components/com_admin/src/Model/HelpModel.php +++ b/administrator/components/com_admin/src/Model/HelpModel.php @@ -152,7 +152,7 @@ public function &getToc() } // Get Help files - $files = Folder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$'); + $files = Folder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$'); $this->toc = []; foreach ($files as $file) { diff --git a/administrator/components/com_admin/src/Model/SysinfoModel.php b/administrator/components/com_admin/src/Model/SysinfoModel.php index 80425291ed74..0fa96f5ede7d 100644 --- a/administrator/components/com_admin/src/Model/SysinfoModel.php +++ b/administrator/components/com_admin/src/Model/SysinfoModel.php @@ -140,7 +140,7 @@ class SysinfoModel extends BaseDatabaseModel 'smtphost', 'tmp_path', 'open_basedir', - ] + ], ]; /** @@ -279,12 +279,12 @@ public function &getConfig(): array return $this->config; } - $registry = new Registry(new \JConfig()); + $registry = new Registry(new \JConfig()); $this->config = $registry->toArray(); - $hidden = [ + $hidden = [ 'host', 'user', 'password', 'ftp_user', 'ftp_pass', 'smtpuser', 'smtppass', 'redis_server_auth', 'session_redis_server_auth', - 'proxy_user', 'proxy_pass', 'secret' + 'proxy_user', 'proxy_pass', 'secret', ]; foreach ($hidden as $key) { @@ -393,13 +393,13 @@ public function &getPHPInfo(): string $phpInfo = ob_get_contents(); ob_end_clean(); preg_match_all('#
]*>(.*)#siU', $phpInfo, $output); - $output = preg_replace('#