Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Updating php-cs-fixer and php_codesniffer to latest versions #42603

Merged
merged 21 commits into from Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
60ae34e
Updating php-cs-fixer and php_codesniffer to latest versions
Hackwar Jan 4, 2024
0e082d5
Fixing codestyle for newer php-cs-fixer version
Hackwar Jan 4, 2024
8240e27
Merge branch '5.1-phpcs2' of github.com:Hackwar/joomla-cms into 5.1-p…
Hackwar Jan 5, 2024
8d19ede
Merge branch '5.1-dev' of https://github.com/joomla/joomla-cms into 5…
Hackwar Jan 5, 2024
620d3e0
fix php-cs comments ident and position
Razzo1987 Jan 11, 2024
45ab38e
Merge pull request #60 from Razzo1987/5.1-phpcs-fix
Hackwar Jan 11, 2024
e526e83
fix phpcs - Blank line at end of control structure
LadySolveig Jan 13, 2024
e9de999
configuration update - php-cs-fixer
LadySolveig Jan 13, 2024
560db28
CS fixes after phs-cs-fixer configuration update
LadySolveig Jan 13, 2024
ec106fd
Merge pull request #62 from LadySolveig/5.1/php-cs-fixer-deprecatedRule
Hackwar Jan 13, 2024
4de2eab
Merge pull request #61 from LadySolveig/5.1/phpcs-fix
Hackwar Jan 13, 2024
71a7be7
Apply suggestions from code review - fix comments ident position
LadySolveig Jan 15, 2024
cb9ef0f
Apply suggestions from code review - fix comments ident position
LadySolveig Jan 15, 2024
9760312
Merge branch '5.1-dev' into 5.1-phpcs
LadySolveig Jan 15, 2024
baf50cb
Merge branch '5.1-dev' into 5.1-phpcs
LadySolveig Jan 17, 2024
2a61720
update php-cs-fixer to version 3.47.1
LadySolveig Jan 18, 2024
2c667a1
Merge remote-tracking branch 'joomla/5.1-dev' into 5.1-phpcs
LadySolveig Jan 18, 2024
7f8543e
Merge branch '5.1-dev' into 5.1-phpcs
LadySolveig Feb 22, 2024
4bb8eb7
php-cs-fixer und phpcs update
LadySolveig Feb 22, 2024
4ce2c90
Merge pull request #63 from LadySolveig/5.1-phpcs
Hackwar Feb 23, 2024
a19af44
Merge branch '5.1-dev' into 5.1-phpcs
LadySolveig Feb 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .php-cs-fixer.dist.php
Expand Up @@ -70,8 +70,8 @@
'@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,
// List of values separated by a comma is contained on a single line should not have a trailing comma like [$foo, $bar,] = ...
'no_trailing_comma_in_singleline' => 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
Expand Down
30 changes: 15 additions & 15 deletions administrator/components/com_admin/src/Model/SysinfoModel.php
Expand Up @@ -244,17 +244,17 @@ public function &getPhpSettings(): array
}

$this->php_settings = [
'memory_limit' => ini_get('memory_limit'),
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
'display_errors' => ini_get('display_errors') == '1',
'short_open_tag' => ini_get('short_open_tag') == '1',
'file_uploads' => ini_get('file_uploads') == '1',
'output_buffering' => (int) ini_get('output_buffering') !== 0,
'open_basedir' => ini_get('open_basedir'),
'session.save_path' => ini_get('session.save_path'),
'session.auto_start' => ini_get('session.auto_start'),
'disable_functions' => ini_get('disable_functions'),
'memory_limit' => \ini_get('memory_limit'),
'upload_max_filesize' => \ini_get('upload_max_filesize'),
'post_max_size' => \ini_get('post_max_size'),
'display_errors' => \ini_get('display_errors') == '1',
'short_open_tag' => \ini_get('short_open_tag') == '1',
'file_uploads' => \ini_get('file_uploads') == '1',
'output_buffering' => (int) \ini_get('output_buffering') !== 0,
'open_basedir' => \ini_get('open_basedir'),
'session.save_path' => \ini_get('session.save_path'),
'session.auto_start' => \ini_get('session.auto_start'),
'disable_functions' => \ini_get('disable_functions'),
'xml' => \extension_loaded('xml'),
'zlib' => \extension_loaded('zlib'),
'zip' => \function_exists('zip_open') && \function_exists('zip_read'),
Expand All @@ -263,7 +263,7 @@ public function &getPhpSettings(): array
'gd' => \extension_loaded('gd'),
'iconv' => \function_exists('iconv'),
'intl' => \function_exists('transliterator_transliterate'),
'max_input_vars' => ini_get('max_input_vars'),
'max_input_vars' => \ini_get('max_input_vars'),
];

return $this->php_settings;
Expand Down Expand Up @@ -355,7 +355,7 @@ private function getCompatPluginParameters()
public function phpinfoEnabled(): bool
{
// remove any spaces from the ini value before exploding it
$disabledFunctions = str_replace(' ', '', ini_get('disable_functions'));
$disabledFunctions = str_replace(' ', '', \ini_get('disable_functions'));
Hackwar marked this conversation as resolved.
Show resolved Hide resolved
return !\in_array('phpinfo', explode(',', $disabledFunctions));
}

Expand Down Expand Up @@ -666,7 +666,7 @@ public function getDirectory(bool $public = false): array
*/
private function addDirectory(string $name, string $path, string $message = ''): void
{
$this->directories[$name] = ['writable' => is_writable($path), 'message' => $message,];
$this->directories[$name] = ['writable' => is_writable($path), 'message' => $message];
}

/**
Expand Down Expand Up @@ -718,7 +718,7 @@ protected function parsePhpInfo(string $html): array
foreach ($vals as $val) {
// 3cols
if (preg_match($p2, $val, $matches)) {
$r[$name][trim($matches[1])] = [trim($matches[2]), trim($matches[3]),];
$r[$name][trim($matches[1])] = [trim($matches[2]), trim($matches[3])];
} elseif (preg_match($p3, $val, $matches)) {
// 2cols
$r[$name][trim($matches[1])] = trim($matches[2]);
Expand Down
Expand Up @@ -249,8 +249,8 @@ protected function getListQuery()
$categoryId = $categoryId ? [$categoryId] : [];
}

// Case: Using both categories filter and by level filter
if (\count($categoryId)) {
// Case: Using both categories filter and by level filter
$categoryTable = Table::getInstance('Category', 'JTable');
$subCatItemsWhere = [];

Expand All @@ -263,9 +263,8 @@ protected function getListQuery()
}

$query->where('(' . implode(' OR ', $subCatItemsWhere) . ')');

// Case: Using only the by level filter
} elseif ($level) {
// Case: Using only the by level filter
$query->where($db->quoteName('a.level') . ' <= :level')
->bind(':level', $level, ParameterType::INTEGER);
}
Expand Down
6 changes: 3 additions & 3 deletions administrator/components/com_finder/src/Indexer/Adapter.php
Expand Up @@ -922,20 +922,20 @@ protected function translateState($item, $category = null)

// Translate the state
switch ($item) {
// Published items should always show up in search results
case 1:
// Published items should always show up in search results
return 1;

// Archived items should only show up when option is enabled
case 2:
// Archived items should only show up when option is enabled
if ($this->params->get('search_archived', 1) == 0) {
return 0;
}

return 1;

// All other states should return an unpublished state
default:
// All other states should return an unpublished state
return 0;
}
}
Expand Down
Expand Up @@ -920,13 +920,13 @@ protected function translateState($item, $category = null)

// Translate the state
switch ($item) {
// Published and archived items only should return a published state
case 1:
case 2:
// Published and archived items only should return a published state
return 1;

// All other states should return an unpublished state
default:
// All other states should return an unpublished state
return 0;
}
}
Expand Down
Expand Up @@ -38,7 +38,7 @@ class Html extends Parser
public function parse($input)
{
// Strip invalid UTF-8 characters.
$oldSetting = ini_get('mbstring.substitute_character');
$oldSetting = \ini_get('mbstring.substitute_character');
ini_set('mbstring.substitute_character', 'none');
Hackwar marked this conversation as resolved.
Show resolved Hide resolved
$input = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
ini_set('mbstring.substitute_character', $oldSetting);
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_finder/src/Indexer/Query.php
Expand Up @@ -794,9 +794,9 @@ protected function processString($input, $lang, $mode)

// Now we have to handle the filter string.
switch ($modifier) {
// Handle a before and after date filters.
case 'before':
case 'after':
// Handle a before and after date filters.
// Get the time offset.
$offset = Factory::getApplication()->get('offset');

Expand All @@ -820,8 +820,8 @@ protected function processString($input, $lang, $mode)

break;

// Handle a taxonomy branch filter.
default:
// Handle a taxonomy branch filter.
// Try to find the node id.
$return = Taxonomy::getNodeByTitle($modifier, $value);

Expand Down
Expand Up @@ -274,7 +274,7 @@ protected function _getPackageFromUpload()
$userfile = $input->files->get('install_package', null, 'raw');

// Make sure that file uploads are enabled in php.
if (!(bool) ini_get('file_uploads')) {
if (!(bool) \ini_get('file_uploads')) {
Factory::getApplication()->enqueueMessage(Text::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLFILE'), 'error');

return false;
Expand Down
Expand Up @@ -176,7 +176,7 @@ protected function translate(&$items)
break;
case 'file':
$extension = 'files_' . $item->element;
$lang->load("$extension.sys", JPATH_SITE);
$lang->load("$extension.sys", JPATH_SITE);
break;
case 'library':
$parts = explode('/', $item->element);
Expand Down
Expand Up @@ -552,8 +552,8 @@ protected function loadFormData()
protected function preparePreUpdate($update, $table)
{
switch ($table->type) {
// Components could have a helper which adds additional data
case 'component':
// Components could have a helper which adds additional data
$ename = str_replace('com_', '', $table->element);
$fname = $ename . '.php';
$cname = ucfirst($ename) . 'Helper';
Expand All @@ -570,8 +570,8 @@ protected function preparePreUpdate($update, $table)

break;

// Modules could have a helper which adds additional data
case 'module':
// Modules could have a helper which adds additional data
$cname = str_replace('_', '', $table->element) . 'Helper';
$path = ($table->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $table->element . '/helper.php';

Expand All @@ -585,9 +585,9 @@ protected function preparePreUpdate($update, $table)

break;

// If we have a plugin, we can use the plugin trigger "onInstallerBeforePackageDownload"
// But we should make sure, that our plugin is loaded, so we don't need a second "installer" plugin
case 'plugin':
// If we have a plugin, we can use the plugin trigger "onInstallerBeforePackageDownload"
// But we should make sure, that our plugin is loaded, so we don't need a second "installer" plugin
$cname = str_replace('plg_', '', $table->element);
PluginHelper::importPlugin($table->folder, $cname);
break;
Expand Down
Expand Up @@ -626,18 +626,18 @@ protected function getListQuery()

if (is_numeric($supported)) {
switch ($supported) {
// Show Update Sites which support Download Keys
case 1:
// Show Update Sites which support Download Keys
$supportedIDs = InstallerHelper::getDownloadKeySupportedSites($enabled);
LadySolveig marked this conversation as resolved.
Show resolved Hide resolved
break;

// Show Update Sites which are missing Download Keys
case -1:
// Show Update Sites which are missing Download Keys
$supportedIDs = InstallerHelper::getDownloadKeyExistsSites(false, $enabled);
break;

// Show Update Sites which have valid Download Keys
case 2:
// Show Update Sites which have valid Download Keys
$supportedIDs = InstallerHelper::getDownloadKeyExistsSites(true, $enabled);
break;
}
Expand Down
Expand Up @@ -98,7 +98,7 @@ public function getItems()
// 16MB
$minLimit = 16 * 1024 * 1024;

$file_uploads = ini_get('file_uploads');
$file_uploads = \ini_get('file_uploads');

if (!$file_uploads) {
$messages[] = [
Expand All @@ -107,7 +107,7 @@ public function getItems()
];
}

$upload_dir = ini_get('upload_tmp_dir');
$upload_dir = \ini_get('upload_tmp_dir');

if (!$upload_dir) {
$messages[] = [
Expand Down Expand Up @@ -135,7 +135,7 @@ public function getItems()
];
}

$memory_limit = $this->return_bytes(ini_get('memory_limit'));
$memory_limit = $this->return_bytes(\ini_get('memory_limit'));

if ($memory_limit > -1) {
if ($memory_limit < $minLimit) {
Expand All @@ -153,8 +153,8 @@ public function getItems()
}
}

$post_max_size = $this->return_bytes(ini_get('post_max_size'));
$upload_max_filesize = $this->return_bytes(ini_get('upload_max_filesize'));
$post_max_size = $this->return_bytes(\ini_get('post_max_size'));
$upload_max_filesize = $this->return_bytes(\ini_get('upload_max_filesize'));

if ($post_max_size > 0 && $post_max_size < $upload_max_filesize) {
$messages[] = [
Expand Down
6 changes: 3 additions & 3 deletions administrator/components/com_joomlaupdate/extract.php
Expand Up @@ -1603,7 +1603,7 @@ private function getPhpMaxExecTime(): int
return 10;
}

$phpMaxTime = @ini_get("maximum_execution_time");
$phpMaxTime = @\ini_get("maximum_execution_time");
$phpMaxTime = (!is_numeric($phpMaxTime) ? 10 : @\intval($phpMaxTime)) ?: 10;

return max(1, $phpMaxTime);
Expand Down Expand Up @@ -1694,9 +1694,9 @@ function clearFileInOPCache(string $file): bool
static $hasOpCache = null;

if (\is_null($hasOpCache)) {
$hasOpCache = ini_get('opcache.enable')
$hasOpCache = \ini_get('opcache.enable')
&& \function_exists('opcache_invalidate')
&& (!ini_get('opcache.restrict_api') || stripos(realpath($_SERVER['SCRIPT_FILENAME']), ini_get('opcache.restrict_api')) === 0);
&& (!\ini_get('opcache.restrict_api') || stripos(realpath($_SERVER['SCRIPT_FILENAME']), \ini_get('opcache.restrict_api')) === 0);
}

if ($hasOpCache && (strtolower(substr($file, -4)) === '.php')) {
Expand Down
22 changes: 11 additions & 11 deletions administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
Expand Up @@ -88,19 +88,19 @@ public function applyUpdateSite()
$params = ComponentHelper::getParams('com_joomlaupdate');

switch ($params->get('updatesource', 'nochange')) {
// "Minor & Patch Release for Current version AND Next Major Release".
case 'next':
// "Minor & Patch Release for Current version AND Next Major Release".
$updateURL = 'https://update.joomla.org/core/sts/list_sts.xml';
break;

// "Testing"
case 'testing':
// "Testing"
$updateURL = 'https://update.joomla.org/core/test/list_test.xml';
break;

case 'custom':
// "Custom"
// @todo: check if the customurl is valid and not just "not empty".
case 'custom':
if (trim($params->get('customurl', '')) != '') {
$updateURL = trim($params->get('customurl', ''));
} else {
Expand All @@ -110,6 +110,7 @@ public function applyUpdateSite()
}
break;

default:
/**
* "Minor & Patch Release for Current version (recommended and default)".
* The commented "case" below are for documenting where 'default' and legacy options falls
Expand All @@ -118,7 +119,6 @@ public function applyUpdateSite()
* case 'sts': (It's shown as "Default" because that option does not exist any more)
* case 'nochange':
*/
default:
$updateURL = 'https://update.joomla.org/core/list.xml';
}

Expand Down Expand Up @@ -930,7 +930,7 @@ public function upload()
$userfile = $input->files->get('install_package', null, 'raw');

// Make sure that file uploads are enabled in php.
if (!(bool) ini_get('file_uploads')) {
if (!(bool) \ini_get('file_uploads')) {
throw new \RuntimeException(Text::_('COM_INSTALLER_MSG_INSTALL_WARNINSTALLFILE'), 500);
}

Expand Down Expand Up @@ -1103,7 +1103,7 @@ public function getPhpOptions()
// Check for default MB language.
$option = new \stdClass();
$option->label = Text::_('INSTL_MB_LANGUAGE_IS_DEFAULT');
$option->state = strtolower(ini_get('mbstring.language')) === 'neutral';
$option->state = strtolower(\ini_get('mbstring.language')) === 'neutral';
$option->notice = $option->state ? null : Text::_('INSTL_NOTICEMBLANGNOTDEFAULT');
$options[] = $option;
}
Expand Down Expand Up @@ -1159,28 +1159,28 @@ public function getPhpSettings()
// Check for display errors.
$setting = new \stdClass();
$setting->label = Text::_('INSTL_DISPLAY_ERRORS');
$setting->state = (bool) ini_get('display_errors');
$setting->state = (bool) \ini_get('display_errors');
$setting->recommended = false;
$settings[] = $setting;

// Check for file uploads.
$setting = new \stdClass();
$setting->label = Text::_('INSTL_FILE_UPLOADS');
$setting->state = (bool) ini_get('file_uploads');
$setting->state = (bool) \ini_get('file_uploads');
$setting->recommended = true;
$settings[] = $setting;

// Check for output buffering.
$setting = new \stdClass();
$setting->label = Text::_('INSTL_OUTPUT_BUFFERING');
$setting->state = (int) ini_get('output_buffering') !== 0;
$setting->state = (int) \ini_get('output_buffering') !== 0;
$setting->recommended = false;
$settings[] = $setting;

// Check for session auto-start.
$setting = new \stdClass();
$setting->label = Text::_('INSTL_SESSION_AUTO_START');
$setting->state = (bool) ini_get('session.auto_start');
$setting->state = (bool) \ini_get('session.auto_start');
$setting->recommended = false;
$settings[] = $setting;

Expand Down Expand Up @@ -1291,7 +1291,7 @@ private function getTargetMinimumPHPVersion()
*/
public function getIniParserAvailability()
{
$disabledFunctions = ini_get('disable_functions');
$disabledFunctions = \ini_get('disable_functions');

if (!empty($disabledFunctions)) {
// Attempt to detect them in the PHP INI disable_functions variable.
Expand Down