diff --git a/administrator/components/com_actionlogs/src/Plugin/ActionLogPlugin.php b/administrator/components/com_actionlogs/src/Plugin/ActionLogPlugin.php index 4db8752a80d1f..662c90a14bad2 100644 --- a/administrator/components/com_actionlogs/src/Plugin/ActionLogPlugin.php +++ b/administrator/components/com_actionlogs/src/Plugin/ActionLogPlugin.php @@ -10,6 +10,7 @@ namespace Joomla\Component\Actionlogs\Administrator\Plugin; +use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Application\CMSApplication; use Joomla\Database\DatabaseDriver; use Joomla\Component\Actionlogs\Administrator\Model\ActionlogModel; @@ -70,7 +71,7 @@ abstract class ActionLogPlugin extends CMSPlugin */ protected function addLog($messages, $messageLanguageKey, $context, $userId = null) { - $app = $this->getApplication() ?: $this->app; + $app = $this->getApplication() instanceof CMSApplicationInterface ? $this->getApplication() : $this->app; $user = $app->getIdentity(); foreach ($messages as $index => $message) { diff --git a/administrator/components/com_actionlogs/src/View/Actionlogs/HtmlView.php b/administrator/components/com_actionlogs/src/View/Actionlogs/HtmlView.php index 6e20d3a76dac2..fbad86b85a23b 100644 --- a/administrator/components/com_actionlogs/src/View/Actionlogs/HtmlView.php +++ b/administrator/components/com_actionlogs/src/View/Actionlogs/HtmlView.php @@ -111,7 +111,7 @@ public function display($tpl = null) $this->showIpColumn = (bool) $params->get('ip_logging', 0); $this->dateRelative = (bool) $params->get('date_relative', 1); - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_admin/src/Model/HelpModel.php b/administrator/components/com_admin/src/Model/HelpModel.php index 200bbd922472a..bb7e8a24ebf1e 100644 --- a/administrator/components/com_admin/src/Model/HelpModel.php +++ b/administrator/components/com_admin/src/Model/HelpModel.php @@ -128,7 +128,7 @@ public function getLangTag() */ public function &getToc() { - if (\count($this->toc)) { + if (\count($this->toc) !== 0) { return $this->toc; } @@ -157,7 +157,7 @@ public function &getToc() foreach ($files as $file) { $buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file); - if (!preg_match('#
'; $orphans = $lang->getOrphans(); - if (\count($orphans)) { + if (\count($orphans) !== 0) { ksort($orphans, SORT_STRING); $guesses = []; @@ -247,7 +247,7 @@ public function execute() } // If gzip compression is enabled in configuration and the server is compliant, compress the output. - if ($this->get('gzip') && !\ini_get('zlib.output_compression') && (\ini_get('output_handler') != 'ob_gzhandler')) { + if ($this->get('gzip') && (in_array(\ini_get('zlib.output_compression'), ['', '0'], true) || \ini_get('zlib.output_compression') === false) && (\ini_get('output_handler') != 'ob_gzhandler')) { $this->compress(); } } catch (\Throwable $throwable) { diff --git a/installation/src/Controller/LanguageController.php b/installation/src/Controller/LanguageController.php index 58f31c96e2f58..a76615f3be83d 100644 --- a/installation/src/Controller/LanguageController.php +++ b/installation/src/Controller/LanguageController.php @@ -96,7 +96,7 @@ public function setdefault() $admin_lang = $this->input->getString('administratorlang', false); // Check that the string is an ISO Language Code avoiding any injection. - if (!preg_match('/^[a-z]{2}(\-[A-Z]{2})?$/', $admin_lang)) { + if (in_array(preg_match('/^[a-z]{2}(\-[A-Z]{2})?$/', $admin_lang), [0, false], true)) { $admin_lang = 'en-GB'; } @@ -113,7 +113,7 @@ public function setdefault() $frontend_lang = $this->input->getString('frontendlang', false); // Check that the string is an ISO Language Code avoiding any injection. - if (!preg_match('/^[a-z]{2}(\-[A-Z]{2})?$/', $frontend_lang)) { + if (in_array(preg_match('/^[a-z]{2}(\-[A-Z]{2})?$/', $frontend_lang), [0, false], true)) { $frontend_lang = 'en-GB'; } diff --git a/installation/src/Helper/DatabaseHelper.php b/installation/src/Helper/DatabaseHelper.php index 6fa15b8b10f93..f9daf177c949e 100644 --- a/installation/src/Helper/DatabaseHelper.php +++ b/installation/src/Helper/DatabaseHelper.php @@ -203,7 +203,7 @@ public static function validateConnectionParameters($options) } // Validate database table prefix. - if (empty($options->db_prefix) || !preg_match('#^[a-zA-Z]+\w*$#', $options->db_prefix)) { + if (empty($options->db_prefix) || in_array(preg_match('#^[a-zA-Z]+\w*$#', $options->db_prefix), [0, false], true)) { return Text::_('INSTL_DATABASE_PREFIX_MSG'); } @@ -213,7 +213,7 @@ public static function validateConnectionParameters($options) } // Validate database name. - if (\in_array($options->db_type, ['pgsql', 'postgresql']) && !preg_match('#^[a-zA-Z_][0-9a-zA-Z_$]*$#', $options->db_name)) { + if (\in_array($options->db_type, ['pgsql', 'postgresql']) && in_array(preg_match('#^[a-zA-Z_][0-9a-zA-Z_$]*$#', $options->db_name), [0, false], true)) { return Text::_('INSTL_DATABASE_NAME_MSG_POSTGRES'); } diff --git a/installation/src/Model/DatabaseModel.php b/installation/src/Model/DatabaseModel.php index a2a70bf628037..2450c0f969e81 100644 --- a/installation/src/Model/DatabaseModel.php +++ b/installation/src/Model/DatabaseModel.php @@ -398,7 +398,7 @@ public function populateDatabase($db, $schema) $return = true; // Get the contents of the schema file. - if (!($buffer = file_get_contents($schema))) { + if ($buffer = file_get_contents($schema) === '' || $buffer = file_get_contents($schema) === '0' || $buffer = file_get_contents($schema) === false) { Factory::getApplication()->enqueueMessage(Text::_('INSTL_SAMPLE_DATA_NOT_FOUND'), 'error'); return false; @@ -461,7 +461,7 @@ protected function splitQueries($query) // Parse the schema file to break up queries. for ($i = 0; $i < \strlen($query) - 1; $i++) { - if ($query[$i] === ';' && !$in_string) { + if ($query[$i] === ';' && ($in_string === false || ($in_string === '' || $in_string === '0'))) { $queries[] = substr($query, 0, $i); $query = substr($query, $i + 1); $i = 0; @@ -469,7 +469,7 @@ protected function splitQueries($query) if ($in_string && ($query[$i] === $in_string) && $buffer[1] !== "\\") { $in_string = false; - } elseif (!$in_string && ($query[$i] === '"' || $query[$i] === "'") && (!isset($buffer[0]) || $buffer[0] !== "\\")) { + } elseif (($in_string === false || ($in_string === '' || $in_string === '0')) && ($query[$i] === '"' || $query[$i] === "'") && (!isset($buffer[0]) || $buffer[0] !== "\\")) { $in_string = $query[$i]; } diff --git a/layouts/joomla/form/field/radiobasic.php b/layouts/joomla/form/field/radiobasic.php index 5ad5bf522fa3c..4d52fa85f0cbe 100644 --- a/layouts/joomla/form/field/radiobasic.php +++ b/layouts/joomla/form/field/radiobasic.php @@ -70,7 +70,7 @@ // Initialize some option attributes. $checked = ((string) $option->value === $value) ? 'checked="checked"' : ''; $optionClass = empty($option->class) ? '' : 'class="' . $option->class . '"'; - $disabled = !empty($option->disable) || ($disabled && !$checked) ? 'disabled' : ''; + $disabled = !empty($option->disable) || ($disabled && ($checked === '' || $checked === '0')) ? 'disabled' : ''; // Initialize some JavaScript option attributes. $onclick = empty($option->onclick) ? '' : 'onclick="' . $option->onclick . '"'; diff --git a/libraries/src/Application/AdministratorApplication.php b/libraries/src/Application/AdministratorApplication.php index fc477824cbaad..eac5c198d8330 100644 --- a/libraries/src/Application/AdministratorApplication.php +++ b/libraries/src/Application/AdministratorApplication.php @@ -352,7 +352,7 @@ public function login($credentials, $options = []) $lang = $this->input->getCmd('lang', ''); $lang = preg_replace('/[^A-Z-]/i', '', $lang); - if ($lang) { + if ($lang !== '' && $lang !== '0' && $lang !== []) { $this->setUserState('application.lang', $lang); } diff --git a/libraries/src/Application/ApiApplication.php b/libraries/src/Application/ApiApplication.php index 06ec58c71a4c6..f2f3ac25e4728 100644 --- a/libraries/src/Application/ApiApplication.php +++ b/libraries/src/Application/ApiApplication.php @@ -338,7 +338,7 @@ private function handlePreflight($method, $router) * If not an OPTIONS request or CORS is not enabled, * there's nothing useful to do here. */ - if ($method !== 'OPTIONS' || !(int) $this->get('cors')) { + if ($method !== 'OPTIONS' || (int) $this->get('cors') === 0) { return; } diff --git a/libraries/src/Application/CLI/CliOutput.php b/libraries/src/Application/CLI/CliOutput.php index 1810ec97ce84f..14a66f06eaa45 100644 --- a/libraries/src/Application/CLI/CliOutput.php +++ b/libraries/src/Application/CLI/CliOutput.php @@ -43,7 +43,7 @@ abstract class CliOutput */ public function __construct(?ProcessorInterface $processor = null) { - $this->setProcessor($processor ?: new ColorProcessor()); + $this->setProcessor($processor instanceof ProcessorInterface ? $processor : new ColorProcessor()); } /** diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index cbaaf960284a8..175b497268b1e 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -183,7 +183,7 @@ abstract class CMSApplication extends WebApplication implements ContainerAwareIn */ public function __construct(?Input $input = null, ?Registry $config = null, ?WebClient $client = null, ?Container $container = null) { - $container = $container ?: new Container(); + $container = $container instanceof Container ? $container : new Container(); $this->setContainer($container); parent::__construct($input, $config, $client); @@ -311,7 +311,7 @@ public function execute() } // If gzip compression is enabled in configuration and the server is compliant, compress the output. - if ($this->get('gzip') && !\ini_get('zlib.output_compression') && \ini_get('output_handler') !== 'ob_gzhandler') { + if ($this->get('gzip') && (in_array(\ini_get('zlib.output_compression'), ['', '0'], true) || \ini_get('zlib.output_compression') === false) && \ini_get('output_handler') !== 'ob_gzhandler') { $this->compress(); // Trigger the onAfterCompress event. @@ -552,7 +552,7 @@ public function getMenu($name = null, $options = []) public function getMessageQueue($clear = false) { // For empty queue, if messages exists in the session, enqueue them. - if (!\count($this->messageQueue)) { + if (\count($this->messageQueue) === 0) { $sessionQueue = $this->getSession()->get('application.queue', []); if ($sessionQueue) { @@ -1007,7 +1007,7 @@ public function logout($userid = null, $options = []) public function redirect($url, $status = 303) { // Persist messages if they exist. - if (\count($this->messageQueue)) { + if (\count($this->messageQueue) !== 0) { $this->getSession()->set('application.queue', $this->messageQueue); } @@ -1178,7 +1178,7 @@ public function setUserState($key, $value) public function toString($compress = false) { // Don't compress something if the server is going to do it anyway. Waste of time. - if ($compress && !\ini_get('zlib.output_compression') && \ini_get('output_handler') !== 'ob_gzhandler') { + if ($compress && (in_array(\ini_get('zlib.output_compression'), ['', '0'], true) || \ini_get('zlib.output_compression') === false) && \ini_get('output_handler') !== 'ob_gzhandler') { $this->compress(); } @@ -1326,7 +1326,7 @@ private function setupLogging(): void $categories = preg_split('/[^\w.-]+/', (string) $this->get('log_categories', ''), -1, PREG_SPLIT_NO_EMPTY); $mode = (bool) $this->get('log_category_mode', false); - if (!$categories) { + if ($categories === [] || $categories === false) { return; } diff --git a/libraries/src/Application/CliApplication.php b/libraries/src/Application/CliApplication.php index b85abf837c9d3..917b634ed961c 100644 --- a/libraries/src/Application/CliApplication.php +++ b/libraries/src/Application/CliApplication.php @@ -127,9 +127,9 @@ public function __construct( $this->close(); } - $container = $container ?: Factory::getContainer(); + $container = $container instanceof Container ? $container : Factory::getContainer(); $this->setContainer($container); - $this->setDispatcher($dispatcher ?: $container->get(DispatcherInterface::class)); + $this->setDispatcher($dispatcher instanceof DispatcherInterface ? $dispatcher : $container->get(DispatcherInterface::class)); if (!$container->has('session')) { $container->alias('session', 'session.cli') @@ -141,8 +141,8 @@ public function __construct( $this->input = new Cli(); $this->language = Factory::getLanguage(); - $this->output = $output ?: new Stdout(); - $this->cliInput = $cliInput ?: new CliInput(); + $this->output = $output instanceof CliOutput ? $output : new Stdout(); + $this->cliInput = $cliInput instanceof CliInput ? $cliInput : new CliInput(); parent::__construct($config); diff --git a/libraries/src/Application/DaemonApplication.php b/libraries/src/Application/DaemonApplication.php index 4d69571d0249a..fd2258c9b2abe 100644 --- a/libraries/src/Application/DaemonApplication.php +++ b/libraries/src/Application/DaemonApplication.php @@ -762,7 +762,7 @@ protected function writeProcessIdFile() } // Write the process id file out to disk. - if (!file_put_contents($file, $this->processId)) { + if (in_array(file_put_contents($file, $this->processId), [0, false], true)) { Log::add('Unable to write process id file: ' . $file, Log::ERROR); return false; diff --git a/libraries/src/Application/IdentityAware.php b/libraries/src/Application/IdentityAware.php index 2be4ac9c99297..0a760aeb6918f 100644 --- a/libraries/src/Application/IdentityAware.php +++ b/libraries/src/Application/IdentityAware.php @@ -56,7 +56,7 @@ public function getIdentity() */ public function loadIdentity(?User $identity = null) { - $this->identity = $identity ?: $this->getUserFactory()->loadUserById(0); + $this->identity = $identity instanceof User ? $identity : $this->getUserFactory()->loadUserById(0); return $this; } diff --git a/libraries/src/Application/WebApplication.php b/libraries/src/Application/WebApplication.php index 4472447882bca..9ddff4ecaa78a 100644 --- a/libraries/src/Application/WebApplication.php +++ b/libraries/src/Application/WebApplication.php @@ -112,7 +112,7 @@ abstract class WebApplication extends AbstractWebApplication public function __construct(?Input $input = null, ?Registry $config = null, ?WebClient $client = null, ?ResponseInterface $response = null) { // Ensure we have a CMS Input object otherwise the DI for \Joomla\CMS\Session\Storage\JoomlaStorage fails - $input = $input ?: new Input(); + $input = $input instanceof Input ? $input : new Input(); parent::__construct($input, $config, $client, $response); @@ -197,7 +197,7 @@ public function execute() } // If gzip compression is enabled in configuration and the server is compliant, compress the output. - if ($this->get('gzip') && !\ini_get('zlib.output_compression') && (\ini_get('output_handler') !== 'ob_gzhandler')) { + if ($this->get('gzip') && (in_array(\ini_get('zlib.output_compression'), ['', '0'], true) || \ini_get('zlib.output_compression') === false) && (\ini_get('output_handler') !== 'ob_gzhandler')) { $this->compress(); } @@ -408,7 +408,7 @@ protected function loadSystemUris($requestUri = null) $uri = Uri::getInstance($this->get('uri.request')); // If we are working from a CGI SAPI with the 'cgi.fix_pathinfo' directive disabled we use PHP_SELF. - if (str_contains(PHP_SAPI, 'cgi') && !\ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) { + if (str_contains(PHP_SAPI, 'cgi') && (in_array(\ini_get('cgi.fix_pathinfo'), ['', '0'], true) || \ini_get('cgi.fix_pathinfo') === false) && !empty($_SERVER['REQUEST_URI'])) { // We aren't expecting PATH_INFO within PHP_SELF so this should work. $path = \dirname((string) $_SERVER['PHP_SELF']); } else { diff --git a/libraries/src/Cache/Storage/FileStorage.php b/libraries/src/Cache/Storage/FileStorage.php index a760b58c28e78..aa57a72eacf44 100644 --- a/libraries/src/Cache/Storage/FileStorage.php +++ b/libraries/src/Cache/Storage/FileStorage.php @@ -586,10 +586,10 @@ protected function _filesInFolder( return $arr; } - $excludefilter = \count($excludefilter) ? '/(' . implode('|', $excludefilter) . ')/' : ''; + $excludefilter = \count($excludefilter) !== 0 ? '/(' . implode('|', $excludefilter) . ')/' : ''; while (($file = readdir($handle)) !== false) { - if (($file !== '.') && ($file !== '..') && (!\in_array($file, $exclude)) && (!$excludefilter || !preg_match($excludefilter, $file))) { + if (($file !== '.') && ($file !== '..') && (!\in_array($file, $exclude)) && ($excludefilter === '' || $excludefilter === '0' || in_array(preg_match($excludefilter, $file), [0, false], true))) { $dir = $path . '/' . $file; $isDir = is_dir($dir); @@ -653,13 +653,13 @@ protected function _folders( return $arr; } - $excludefilter_string = \count($excludefilter) ? '/(' . implode('|', $excludefilter) . ')/' : ''; + $excludefilter_string = \count($excludefilter) !== 0 ? '/(' . implode('|', $excludefilter) . ')/' : ''; while (($file = readdir($handle)) !== false) { if ( ($file !== '.') && ($file !== '..') && (!\in_array($file, $exclude)) - && ($excludefilter_string === '' || $excludefilter_string === '0' || !preg_match($excludefilter_string, $file)) + && ($excludefilter_string === '' || $excludefilter_string === '0' || in_array(preg_match($excludefilter_string, $file), [0, false], true)) ) { $dir = $path . '/' . $file; $isDir = is_dir($dir); diff --git a/libraries/src/Captcha/Google/HttpBridgePostRequestMethod.php b/libraries/src/Captcha/Google/HttpBridgePostRequestMethod.php index acee2c848c368..88d5994914798 100644 --- a/libraries/src/Captcha/Google/HttpBridgePostRequestMethod.php +++ b/libraries/src/Captcha/Google/HttpBridgePostRequestMethod.php @@ -51,7 +51,7 @@ final class HttpBridgePostRequestMethod implements RequestMethod */ public function __construct(?Http $http = null) { - $this->http = $http ?: HttpFactory::getHttp(); + $this->http = $http instanceof Http ? $http : HttpFactory::getHttp(); } /** diff --git a/libraries/src/Client/FtpClient.php b/libraries/src/Client/FtpClient.php index 275fa248a0241..d6196076461ae 100644 --- a/libraries/src/Client/FtpClient.php +++ b/libraries/src/Client/FtpClient.php @@ -1299,7 +1299,7 @@ public function listNames($path = null) $list = preg_replace('#^' . preg_quote((string) $path, '#') . '[/\\\\]?#', '', $list); - if ($keys = array_merge(array_keys($list, '.'), array_keys($list, '..'))) { + if ($keys = array_merge(array_keys($list, '.'), array_keys($list, '..')) !== []) { foreach ($keys as $key) { unset($list[$key]); } @@ -1350,7 +1350,7 @@ public function listNames($path = null) $data = preg_split('/[' . CRLF . ']+/', (string) $data, -1, PREG_SPLIT_NO_EMPTY); $data = preg_replace('#^' . preg_quote(substr((string) $path, 1), '#') . '[/\\\\]?#', '', $data); - if ($keys = array_merge(array_keys($data, '.'), array_keys($data, '..'))) { + if ($keys = array_merge(array_keys($data, '.'), array_keys($data, '..')) !== []) { foreach ($keys as $key) { unset($data[$key]); } @@ -1472,7 +1472,7 @@ public function listDetails($path = null, $type = 'all') } } - if (!$osType) { + if ($osType === null) { Log::add(Text::sprintf('JLIB_CLIENT_ERROR_FTP_UNRECOGNISED_FOLDER_LISTING_FORMATJLIB_CLIENT_ERROR_JFTP_LISTDETAILS_UNRECOGNISED', __METHOD__), Log::WARNING, 'jerror'); return false; @@ -1573,7 +1573,7 @@ protected function _putCmd($cmd, $expectedResponse) } // Send the command to the server - if (!fwrite($this->_conn, $cmd . "\r\n")) { + if (in_array(fwrite($this->_conn, $cmd . "\r\n"), [0, false], true)) { Log::add(Text::sprintf('DDD', Text::sprintf('JLIB_CLIENT_ERROR_FTP_PUTCMD_SEND', __METHOD__, $cmd)), Log::WARNING, 'jerror'); } @@ -1599,7 +1599,7 @@ protected function _verifyResponse($expected) do { $this->_response .= fgets($this->_conn, 4096); - } while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts) && time() < $endTime); + } while (in_array(preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts), [0, false], true) && time() < $endTime); // Catch a timeout or bad response if (!isset($parts[1])) { @@ -1654,7 +1654,7 @@ protected function _passive() do { $this->_response .= fgets($this->_conn, 4096); - } while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts) && time() < $endTime); + } while (in_array(preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts), [0, false], true) && time() < $endTime); // Catch a timeout or bad response if (!isset($parts[1])) { diff --git a/libraries/src/Component/Router/RouterView.php b/libraries/src/Component/Router/RouterView.php index 5d7a26dd92296..75d94f4bb31aa 100644 --- a/libraries/src/Component/Router/RouterView.php +++ b/libraries/src/Component/Router/RouterView.php @@ -265,7 +265,7 @@ public function getName() if (empty($this->name)) { $r = null; - if (!preg_match('/(.*)Router/i', static::class, $r)) { + if (in_array(preg_match('/(.*)Router/i', static::class, $r), [0, false], true)) { throw new \Exception('JLIB_APPLICATION_ERROR_ROUTER_GET_NAME', 500); } diff --git a/libraries/src/Component/Router/Rules/PreprocessRules.php b/libraries/src/Component/Router/Rules/PreprocessRules.php index 9f3e4bd65a566..d7f211fbe8768 100644 --- a/libraries/src/Component/Router/Rules/PreprocessRules.php +++ b/libraries/src/Component/Router/Rules/PreprocessRules.php @@ -116,7 +116,7 @@ public function preprocess(&$query) } // Lets fix the slug (id:alias) - if (!strpos((string) $query[$key], ':')) { + if (in_array(strpos((string) $query[$key], ':'), [0, false], true)) { $query[$key] .= ':' . $obj->alias; } diff --git a/libraries/src/Console/AddUserCommand.php b/libraries/src/Console/AddUserCommand.php index be355b785930d..94acb9cda1042 100644 --- a/libraries/src/Console/AddUserCommand.php +++ b/libraries/src/Console/AddUserCommand.php @@ -208,7 +208,7 @@ public function getStringFromOption($option, $question): string { $answer = (string) $this->cliInput->getOption($option); - while (!$answer) { + while ($answer === '' || $answer === '0') { if ($option === 'password') { $answer = (string) $this->ioStyle->askHidden($question); } else { diff --git a/libraries/src/Console/AddUserToGroupCommand.php b/libraries/src/Console/AddUserToGroupCommand.php index 90493c005afb8..ec3de019d61ab 100644 --- a/libraries/src/Console/AddUserToGroupCommand.php +++ b/libraries/src/Console/AddUserToGroupCommand.php @@ -265,7 +265,7 @@ protected function getStringFromOption($option, $question): string { $answer = (string) $this->getApplication()->getConsoleInput()->getOption($option); - while (!$answer) { + while ($answer === '' || $answer === '0') { $answer = (string) $this->ioStyle->ask($question); } diff --git a/libraries/src/Console/ChangeUserPasswordCommand.php b/libraries/src/Console/ChangeUserPasswordCommand.php index ee696777f6aa6..e90b0a6bca7e4 100644 --- a/libraries/src/Console/ChangeUserPasswordCommand.php +++ b/libraries/src/Console/ChangeUserPasswordCommand.php @@ -124,7 +124,7 @@ protected function getStringFromOption($option, $question): string { $answer = (string) $this->cliInput->getOption($option); - while (!$answer) { + while ($answer === '' || $answer === '0') { if ($option === 'password') { $answer = (string) $this->ioStyle->askHidden($question); } else { diff --git a/libraries/src/Console/DeleteUserCommand.php b/libraries/src/Console/DeleteUserCommand.php index 6dc7f5c8f9dd9..cd231c30fd429 100644 --- a/libraries/src/Console/DeleteUserCommand.php +++ b/libraries/src/Console/DeleteUserCommand.php @@ -171,7 +171,7 @@ protected function getStringFromOption($option, $question): string { $answer = (string) $this->getApplication()->getConsoleInput()->getOption($option); - while (!$answer) { + while ($answer === '' || $answer === '0') { $answer = (string) $this->ioStyle->ask($question); } diff --git a/libraries/src/Console/RemoveUserFromGroupCommand.php b/libraries/src/Console/RemoveUserFromGroupCommand.php index e94e17ce1a716..ee128fa111e2c 100644 --- a/libraries/src/Console/RemoveUserFromGroupCommand.php +++ b/libraries/src/Console/RemoveUserFromGroupCommand.php @@ -267,7 +267,7 @@ protected function getStringFromOption($option, $question): string { $answer = (string) $this->getApplication()->getConsoleInput()->getOption($option); - while (!$answer) { + while ($answer === '' || $answer === '0') { $answer = (string) $this->ioStyle->ask($question); } diff --git a/libraries/src/Console/SetConfigurationCommand.php b/libraries/src/Console/SetConfigurationCommand.php index 2de16e82dee45..8eec388550a47 100644 --- a/libraries/src/Console/SetConfigurationCommand.php +++ b/libraries/src/Console/SetConfigurationCommand.php @@ -286,7 +286,7 @@ public function checkDb($options): bool } // Validate database table prefix. - if (isset($options['dbprefix']) && !preg_match('#^[a-zA-Z]+\w*$#', (string) $options['dbprefix'])) { + if (isset($options['dbprefix']) && in_array(preg_match('#^[a-zA-Z]+\w*$#', (string) $options['dbprefix']), [0, false], true)) { $this->ioStyle->error(Text::_('INSTL_DATABASE_PREFIX_MSG')); return false; @@ -307,7 +307,7 @@ public function checkDb($options): bool } // Validate database name. - if (\in_array($options['dbtype'], ['pgsql', 'postgresql'], true) && !preg_match('#^[a-zA-Z_][0-9a-zA-Z_$]*$#', (string) $options['db'])) { + if (\in_array($options['dbtype'], ['pgsql', 'postgresql'], true) && in_array(preg_match('#^[a-zA-Z_][0-9a-zA-Z_$]*$#', (string) $options['db']), [0, false], true)) { $this->ioStyle->error(Text::_('INSTL_DATABASE_NAME_MSG_POSTGRES')); return false; diff --git a/libraries/src/Console/SiteCreatePublicFolderCommand.php b/libraries/src/Console/SiteCreatePublicFolderCommand.php index 7db04c5e134dd..abe7e6b78a1f3 100644 --- a/libraries/src/Console/SiteCreatePublicFolderCommand.php +++ b/libraries/src/Console/SiteCreatePublicFolderCommand.php @@ -111,7 +111,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in */ public function getStringFromOption($option, $question, $required = true): string { - while (!$answer && $required) { + while (($answer === '' || $answer === '0') && $required) { $answer = (string) $this->ioStyle->ask($question); } diff --git a/libraries/src/Console/TasksStateCommand.php b/libraries/src/Console/TasksStateCommand.php index f051c9207a2e3..e37c240212173 100644 --- a/libraries/src/Console/TasksStateCommand.php +++ b/libraries/src/Console/TasksStateCommand.php @@ -96,7 +96,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $state = (string) ArrayHelper::arraySearch($state, Task::STATE_MAP); } - if (!\strlen($state) || !Task::isValidState($state)) { + if ($state === '' || !Task::isValidState($state)) { $this->ioStyle->error('Invalid state passed!'); return 2; diff --git a/libraries/src/Dispatcher/ComponentDispatcher.php b/libraries/src/Dispatcher/ComponentDispatcher.php index b223f82d9e5d6..9789dec1083d7 100644 --- a/libraries/src/Dispatcher/ComponentDispatcher.php +++ b/libraries/src/Dispatcher/ComponentDispatcher.php @@ -159,7 +159,7 @@ public function dispatch() public function getController(string $name, string $client = '', array $config = []): BaseController { // Set up the client - $client = $client ?: ucfirst($this->app->getName()); + $client = $client !== '' && $client !== '0' ? $client : ucfirst($this->app->getName()); // Get the controller instance $controller = $this->mvcFactory->createController( diff --git a/libraries/src/Dispatcher/ComponentDispatcherFactory.php b/libraries/src/Dispatcher/ComponentDispatcherFactory.php index 60a9fee30bab3..60249f0ae18c0 100644 --- a/libraries/src/Dispatcher/ComponentDispatcherFactory.php +++ b/libraries/src/Dispatcher/ComponentDispatcherFactory.php @@ -76,6 +76,6 @@ public function createDispatcher(CMSApplicationInterface $application, ?Input $i } } - return new $className($application, $input ?: $application->getInput(), $this->mvcFactory); + return new $className($application, $input instanceof Input ? $input : $application->getInput(), $this->mvcFactory); } } diff --git a/libraries/src/Dispatcher/ModuleDispatcherFactory.php b/libraries/src/Dispatcher/ModuleDispatcherFactory.php index 9c15739800fd2..741b78ca694b0 100644 --- a/libraries/src/Dispatcher/ModuleDispatcherFactory.php +++ b/libraries/src/Dispatcher/ModuleDispatcherFactory.php @@ -67,6 +67,6 @@ public function createDispatcher(\stdClass $module, CMSApplicationInterface $app $className = ModuleDispatcher::class; } - return new $className($module, $application, $input ?: $application->getInput()); + return new $className($module, $application, $input instanceof Input ? $input : $application->getInput()); } } diff --git a/libraries/src/Document/HtmlDocument.php b/libraries/src/Document/HtmlDocument.php index 26ce90492c1de..11cb0cda7720b 100644 --- a/libraries/src/Document/HtmlDocument.php +++ b/libraries/src/Document/HtmlDocument.php @@ -338,10 +338,10 @@ public function mergeHeadData($data) return $this; } - $this->title = (isset($data['title']) && !empty($data['title']) && !stristr($this->title, (string) $data['title'])) + $this->title = (isset($data['title']) && !empty($data['title']) && (in_array(stristr($this->title, (string) $data['title']), ['', '0'], true) || stristr($this->title, (string) $data['title']) === false)) ? $this->title . $data['title'] : $this->title; - $this->description = (isset($data['description']) && !empty($data['description']) && !stristr($this->description, (string) $data['description'])) + $this->description = (isset($data['description']) && !empty($data['description']) && (in_array(stristr($this->description, (string) $data['description']), ['', '0'], true) || stristr($this->description, (string) $data['description']) === false)) ? $this->description . $data['description'] : $this->description; $this->link = $data['link'] ?? $this->link; diff --git a/libraries/src/Document/PreloadManager.php b/libraries/src/Document/PreloadManager.php index 8ef2ca57f64fa..7728ef02a2c77 100644 --- a/libraries/src/Document/PreloadManager.php +++ b/libraries/src/Document/PreloadManager.php @@ -41,7 +41,7 @@ class PreloadManager implements PreloadManagerInterface */ public function __construct(?EvolvableLinkProviderInterface $linkProvider = null) { - $this->linkProvider = $linkProvider ?: new GenericLinkProvider(); + $this->linkProvider = $linkProvider instanceof EvolvableLinkProviderInterface ? $linkProvider : new GenericLinkProvider(); } /** diff --git a/libraries/src/Document/Renderer/Html/ScriptsRenderer.php b/libraries/src/Document/Renderer/Html/ScriptsRenderer.php index 5b176c017b5fc..8b00e1eca7ad7 100644 --- a/libraries/src/Document/Renderer/Html/ScriptsRenderer.php +++ b/libraries/src/Document/Renderer/Html/ScriptsRenderer.php @@ -159,7 +159,7 @@ private function renderElement($item): string if (JDEBUG) { $attribs['data-asset-name'] = $asset->getName(); - if ($asset->getDependencies()) { + if ($asset->getDependencies() !== []) { $attribs['data-asset-dependencies'] = implode(',', $asset->getDependencies()); } diff --git a/libraries/src/Document/Renderer/Html/StylesRenderer.php b/libraries/src/Document/Renderer/Html/StylesRenderer.php index 325091221dd99..5abbc0e88fdf7 100644 --- a/libraries/src/Document/Renderer/Html/StylesRenderer.php +++ b/libraries/src/Document/Renderer/Html/StylesRenderer.php @@ -148,7 +148,7 @@ private function renderElement($item): string if (JDEBUG) { $attribs['data-asset-name'] = $asset->getName(); - if ($asset->getDependencies()) { + if ($asset->getDependencies() !== []) { $attribs['data-asset-dependencies'] = implode(',', $asset->getDependencies()); } diff --git a/libraries/src/Encrypt/Base32.php b/libraries/src/Encrypt/Base32.php index 5c72a4830aba8..7fbea69525ddb 100644 --- a/libraries/src/Encrypt/Base32.php +++ b/libraries/src/Encrypt/Base32.php @@ -61,7 +61,7 @@ private function bin2str($str) throw new \Exception('Length must be divisible by 8'); } - if (!preg_match('/^[01]+$/', $str)) { + if (in_array(preg_match('/^[01]+$/', $str), [0, false], true)) { throw new \Exception("Only 0's and 1's are permitted"); } @@ -91,7 +91,7 @@ private function fromBin($str) throw new \Exception('Length must be divisible by 8'); } - if (!preg_match('/^[01]+$/', $str)) { + if (in_array(preg_match('/^[01]+$/', $str), [0, false], true)) { throw new \Exception("Only 0's and 1's are permitted"); } @@ -128,7 +128,7 @@ private function fromBin($str) */ private function toBin($str) { - if (!preg_match('/^[' . self::CSRFC3548 . ']+$/', $str)) { + if (in_array(preg_match('/^[' . self::CSRFC3548 . ']+$/', $str), [0, false], true)) { throw new \Exception('Must match character set'); } diff --git a/libraries/src/Event/Menu/PreprocessMenuItemsEvent.php b/libraries/src/Event/Menu/PreprocessMenuItemsEvent.php index f9f4c8f38ae06..5d7d507095eac 100644 --- a/libraries/src/Event/Menu/PreprocessMenuItemsEvent.php +++ b/libraries/src/Event/Menu/PreprocessMenuItemsEvent.php @@ -100,7 +100,7 @@ protected function onSetContext(string $value): string protected function onSetSubject(array $value): array { // Filter out MenuItem elements. Non empty result means invalid data - $valid = !array_filter($value, fn($item) => !$item instanceof MenuItem); + $valid = array_filter($value, fn($item) => !$item instanceof MenuItem) === []; if (!$valid) { throw new \UnexpectedValueException(sprintf("Argument 'subject' of event %s is not of the expected type", $this->name)); diff --git a/libraries/src/Event/Module/ModuleListEvent.php b/libraries/src/Event/Module/ModuleListEvent.php index 0c68782b530fd..f10aa38b99e4a 100644 --- a/libraries/src/Event/Module/ModuleListEvent.php +++ b/libraries/src/Event/Module/ModuleListEvent.php @@ -73,7 +73,7 @@ public function __construct($name, array $arguments = []) protected function onSetModules(array $value): array { // Filter out Module elements. Non empty result means invalid data - $valid = !array_filter($value, fn($item) => !\is_object($item)); + $valid = array_filter($value, fn($item) => !\is_object($item)) === []; if (!$valid) { throw new \UnexpectedValueException(sprintf("Argument 'modules' of event %s is not of the expected type", $this->name)); diff --git a/libraries/src/Feed/FeedFactory.php b/libraries/src/Feed/FeedFactory.php index 522a21e5d6ac2..0f24ce3f2ef61 100644 --- a/libraries/src/Feed/FeedFactory.php +++ b/libraries/src/Feed/FeedFactory.php @@ -108,7 +108,7 @@ public function registerParser($tagName, $className, $overwrite = false) } // Validate that the tag name is valid. - if (!preg_match('/\A(?!XML)[a-z][\w0-9-]*/i', $tagName)) { + if (in_array(preg_match('/\A(?!XML)[a-z][\w0-9-]*/i', $tagName), [0, false], true)) { throw new \InvalidArgumentException('The tag name ' . $tagName . ' is not valid.'); } diff --git a/libraries/src/Feed/FeedParser.php b/libraries/src/Feed/FeedParser.php index 5e5c81a5852e2..0fedbdb0fbb73 100644 --- a/libraries/src/Feed/FeedParser.php +++ b/libraries/src/Feed/FeedParser.php @@ -66,7 +66,7 @@ abstract class FeedParser public function __construct(\XMLReader $stream, ?InputFilter $inputFilter = null) { $this->stream = $stream; - $this->inputFilter = $inputFilter ?: InputFilter::getInstance([], [], 1, 1); + $this->inputFilter = $inputFilter instanceof InputFilter ? $inputFilter : InputFilter::getInstance([], [], 1, 1); } /** diff --git a/libraries/src/Filesystem/File.php b/libraries/src/Filesystem/File.php index 54f8c5ea3eb17..53736aa70b454 100644 --- a/libraries/src/Filesystem/File.php +++ b/libraries/src/Filesystem/File.php @@ -224,7 +224,7 @@ public static function canFlushFileCache() if ( \ini_get('opcache.enable') && \function_exists('opcache_invalidate') - && (!\ini_get('opcache.restrict_api') || stripos(realpath($_SERVER['SCRIPT_FILENAME']), \ini_get('opcache.restrict_api')) === 0) + && (in_array(\ini_get('opcache.restrict_api'), ['', '0'], true) || \ini_get('opcache.restrict_api') === false || stripos(realpath($_SERVER['SCRIPT_FILENAME']), \ini_get('opcache.restrict_api')) === 0) ) { static::$canFlushFileCache = true; } else { diff --git a/libraries/src/Filesystem/FilesystemHelper.php b/libraries/src/Filesystem/FilesystemHelper.php index 6223d34dba465..1bdb337f1e9e8 100644 --- a/libraries/src/Filesystem/FilesystemHelper.php +++ b/libraries/src/Filesystem/FilesystemHelper.php @@ -58,16 +58,16 @@ public static function remotefsize($url) $path = parse_url($url, PHP_URL_PATH); $user = parse_url($url, PHP_URL_USER); $pass = parse_url($url, PHP_URL_PASS); - if ((!$server) || (!$path)) { + if (($server === 0 || ($server === '' || $server === '0') || $server === [] || $server === false || $server === null) || ($path === 0 || ($path === '' || $path === '0') || $path === [] || $path === false || $path === null)) { return false; } - if (!$port) { + if ($port === 0 || ($port === '' || $port === '0') || $port === [] || $port === false || $port === null) { $port = 21; } - if (!$user) { + if ($user === 0 || ($user === '' || $user === '0') || $user === [] || $user === false || $user === null) { $user = 'anonymous'; } - if (!$pass) { + if ($pass === 0 || ($pass === '' || $pass === '0') || $pass === [] || $pass === false || $pass === null) { $pass = ''; } switch ($sch) { @@ -121,19 +121,19 @@ public static function ftpChmod($url, $mode) $user = parse_url($url, PHP_URL_USER); $pass = parse_url($url, PHP_URL_PASS); - if ((!$server) || (!$path)) { + if (($server === 0 || ($server === '' || $server === '0') || $server === [] || $server === false || $server === null) || ($path === 0 || ($path === '' || $path === '0') || $path === [] || $path === false || $path === null)) { return false; } - if (!$port) { + if ($port === 0 || ($port === '' || $port === '0') || $port === [] || $port === false || $port === null) { $port = 21; } - if (!$user) { + if ($user === 0 || ($user === '' || $user === '0') || $user === [] || $user === false || $user === null) { $user = 'anonymous'; } - if (!$pass) { + if ($pass === 0 || ($pass === '' || $pass === '0') || $pass === [] || $pass === false || $pass === null) { $pass = ''; } @@ -325,7 +325,7 @@ private static function parseSize($size) { $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); $size = preg_replace('/[^0-9\.]/', '', $size); - if ($unit) { + if ($unit !== '' && $unit !== '0' && $unit !== []) { return round($size * 1024 ** stripos('bkmgtpezy', $unit[0])); } diff --git a/libraries/src/Filesystem/Folder.php b/libraries/src/Filesystem/Folder.php index 1793519ff0f06..c2b929d4caa5e 100644 --- a/libraries/src/Filesystem/Folder.php +++ b/libraries/src/Filesystem/Folder.php @@ -462,7 +462,7 @@ public static function files( } // Compute the excludefilter string - $excludeFilterString = \count($excludeFilter) ? '/(' . implode('|', $excludeFilter) . ')/' : ''; + $excludeFilterString = \count($excludeFilter) !== 0 ? '/(' . implode('|', $excludeFilter) . ')/' : ''; // Get the files $arr = self::_items($path, $filter, $recurse, $full, $exclude, $excludeFilterString, true); @@ -513,7 +513,7 @@ public static function folders( } // Compute the excludefilter string - $excludeFilterString = \count($excludeFilter) ? '/(' . implode('|', $excludeFilter) . ')/' : ''; + $excludeFilterString = \count($excludeFilter) !== 0 ? '/(' . implode('|', $excludeFilter) . ')/' : ''; // Get the folders $arr = self::_items($path, $filter, $recurse, $full, $exclude, $excludeFilterString, false); @@ -557,7 +557,7 @@ protected static function _items($path, $filter, $recurse, $full, $exclude, $exc while (($file = readdir($handle)) !== false) { if ( $file !== '.' && $file !== '..' && !\in_array($file, $exclude) - && (empty($excludeFilterString) || !preg_match($excludeFilterString, $file)) + && (empty($excludeFilterString) || in_array(preg_match($excludeFilterString, $file), [0, false], true)) ) { // Compute the fullpath $fullpath = $path . '/' . $file; diff --git a/libraries/src/Filesystem/Patcher.php b/libraries/src/Filesystem/Patcher.php index 2f2839dd3891f..659c553c947ef 100644 --- a/libraries/src/Filesystem/Patcher.php +++ b/libraries/src/Filesystem/Patcher.php @@ -288,7 +288,7 @@ protected static function findHeader(&$lines, &$src, &$dst) $line = current($lines); // Search for the header - while ($line !== false && !preg_match(self::SRC_FILE, (string) $line, $m)) { + while ($line !== false && in_array(preg_match(self::SRC_FILE, (string) $line, $m), [0, false], true)) { $line = next($lines); } @@ -308,7 +308,7 @@ protected static function findHeader(&$lines, &$src, &$dst) } // Search the destination file - if (!preg_match(self::DST_FILE, (string) $line, $m)) { + if (in_array(preg_match(self::DST_FILE, (string) $line, $m), [0, false], true)) { throw new \RuntimeException('Invalid Diff file'); } diff --git a/libraries/src/Form/Field/CalendarField.php b/libraries/src/Form/Field/CalendarField.php index 7444618ee07d3..ee5c2f2305e08 100644 --- a/libraries/src/Form/Field/CalendarField.php +++ b/libraries/src/Form/Field/CalendarField.php @@ -220,16 +220,16 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) $return = parent::setup($element, $value, $group); if ($return) { - $this->maxlength = (int) $this->element['maxlength'] ?: 45; - $this->format = (string) $this->element['format'] ?: '%Y-%m-%d'; - $this->filterFormat = (string) $this->element['filterformat'] ?: ''; - $this->filter = (string) $this->element['filter'] ?: 'USER_UTC'; - $this->todaybutton = (string) $this->element['todaybutton'] ?: 'true'; - $this->weeknumbers = (string) $this->element['weeknumbers'] ?: 'true'; - $this->showtime = (string) $this->element['showtime'] ?: 'false'; - $this->filltable = (string) $this->element['filltable'] ?: 'true'; - $this->timeformat = (int) $this->element['timeformat'] ?: 24; - $this->singleheader = (string) $this->element['singleheader'] ?: 'false'; + $this->maxlength = (int) $this->element['maxlength'] !== 0 ? (int) $this->element['maxlength'] : 45; + $this->format = (string) $this->element['format'] !== '' && (string) $this->element['format'] !== '0' ? (string) $this->element['format'] : '%Y-%m-%d'; + $this->filterFormat = (string) $this->element['filterformat'] !== '' && (string) $this->element['filterformat'] !== '0' ? (string) $this->element['filterformat'] : ''; + $this->filter = (string) $this->element['filter'] !== '' && (string) $this->element['filter'] !== '0' ? (string) $this->element['filter'] : 'USER_UTC'; + $this->todaybutton = (string) $this->element['todaybutton'] !== '' && (string) $this->element['todaybutton'] !== '0' ? (string) $this->element['todaybutton'] : 'true'; + $this->weeknumbers = (string) $this->element['weeknumbers'] !== '' && (string) $this->element['weeknumbers'] !== '0' ? (string) $this->element['weeknumbers'] : 'true'; + $this->showtime = (string) $this->element['showtime'] !== '' && (string) $this->element['showtime'] !== '0' ? (string) $this->element['showtime'] : 'false'; + $this->filltable = (string) $this->element['filltable'] !== '' && (string) $this->element['filltable'] !== '0' ? (string) $this->element['filltable'] : 'true'; + $this->timeformat = (int) $this->element['timeformat'] !== 0 ? (int) $this->element['timeformat'] : 24; + $this->singleheader = (string) $this->element['singleheader'] !== '' && (string) $this->element['singleheader'] !== '0' ? (string) $this->element['singleheader'] : 'false'; $this->minyear = \strlen((string) $this->element['minyear']) !== 0 ? (int) $this->element['minyear'] : null; $this->maxyear = \strlen((string) $this->element['maxyear']) !== 0 ? (int) $this->element['maxyear'] : null; diff --git a/libraries/src/Form/Field/ColorField.php b/libraries/src/Form/Field/ColorField.php index 4f706eaa6daae..723c47b6229e7 100644 --- a/libraries/src/Form/Field/ColorField.php +++ b/libraries/src/Form/Field/ColorField.php @@ -237,7 +237,7 @@ protected function getLayoutData() $lang = Factory::getApplication()->getLanguage(); $data = parent::getLayoutData(); $color = strtolower((string) $this->value); - $color = !$color && $color !== '0' ? '' : $color; + $color = ($color === '' || $color === '0') && $color !== '0' ? '' : $color; // Position of the panel can be: right (default), left, top or bottom (default RTL is left) $position = ' data-position="' . (($lang->isRtl() && $this->position === 'default') ? 'left' : $this->position) . '"'; diff --git a/libraries/src/Form/Field/ComponentlayoutField.php b/libraries/src/Form/Field/ComponentlayoutField.php index 3d1ae7a70208d..c264a9fcb1158 100644 --- a/libraries/src/Form/Field/ComponentlayoutField.php +++ b/libraries/src/Form/Field/ComponentlayoutField.php @@ -110,7 +110,7 @@ protected function getInput() ) ->bind(':clientId', $clientId, ParameterType::INTEGER); - if ($template) { + if ($template !== '' && $template !== '0' && $template !== []) { $query->where($db->quoteName('e.element') . ' = :template') ->bind(':template', $template); } @@ -204,7 +204,7 @@ protected function getInput() } } - if (\count($files)) { + if (\count($files) !== 0) { // Create the group for the template $groups[$template->name] = []; $groups[$template->name]['id'] = $this->id . '_' . $template->element; diff --git a/libraries/src/Form/Field/ListField.php b/libraries/src/Form/Field/ListField.php index ca3b0c75dda39..b6acf5e8da040 100644 --- a/libraries/src/Form/Field/ListField.php +++ b/libraries/src/Form/Field/ListField.php @@ -274,7 +274,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) if ($return) { // Check if it's using the old way - $this->header = (string) $this->element['header'] ?: false; + $this->header = (string) $this->element['header'] !== '' && (string) $this->element['header'] !== '0' ? (string) $this->element['header'] : false; } return $return; diff --git a/libraries/src/Form/Field/ModulelayoutField.php b/libraries/src/Form/Field/ModulelayoutField.php index 1c4e4f73bc7bd..9783e327e1da9 100644 --- a/libraries/src/Form/Field/ModulelayoutField.php +++ b/libraries/src/Form/Field/ModulelayoutField.php @@ -108,7 +108,7 @@ protected function getInput() ) ->bind(':clientId', $clientId, ParameterType::INTEGER); - if ($template) { + if ($template !== '' && $template !== '0' && $template !== []) { $query->where($db->quoteName('e.element') . ' = :template') ->bind(':template', $template); } @@ -167,7 +167,7 @@ protected function getInput() } } - if (\count($files)) { + if (\count($files) !== 0) { // Create the group for the template $groups[$template->element] = []; $groups[$template->element]['id'] = $this->id . '_' . $template->element; diff --git a/libraries/src/Form/Field/SqlField.php b/libraries/src/Form/Field/SqlField.php index 4cd85b40ff5c6..aeaf83ac47387 100644 --- a/libraries/src/Form/Field/SqlField.php +++ b/libraries/src/Form/Field/SqlField.php @@ -176,10 +176,10 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) } } - $this->keyField = (string) $this->element['key_field'] ?: 'value'; - $this->valueField = (string) $this->element['value_field'] ?: (string) $this->element['name']; - $this->translate = (string) $this->element['translate'] ?: false; - $this->header = (string) $this->element['header'] ?: false; + $this->keyField = (string) $this->element['key_field'] !== '' && (string) $this->element['key_field'] !== '0' ? (string) $this->element['key_field'] : 'value'; + $this->valueField = (string) $this->element['value_field'] !== '' && (string) $this->element['value_field'] !== '0' ? (string) $this->element['value_field'] : (string) $this->element['name']; + $this->translate = (string) $this->element['translate'] !== '' && (string) $this->element['translate'] !== '0' ? (string) $this->element['translate'] : false; + $this->header = (string) $this->element['header'] !== '' && (string) $this->element['header'] !== '0' ? (string) $this->element['header'] : false; } return $return; diff --git a/libraries/src/Form/Field/TagField.php b/libraries/src/Form/Field/TagField.php index ad6e105adfba0..d41d9136f6099 100644 --- a/libraries/src/Form/Field/TagField.php +++ b/libraries/src/Form/Field/TagField.php @@ -120,7 +120,7 @@ protected function getInput() */ protected function getOptions() { - $published = (string) $this->element['published'] ?: [0, 1]; + $published = (string) $this->element['published'] !== '' && (string) $this->element['published'] !== '0' ? (string) $this->element['published'] : [0, 1]; $app = Factory::getApplication(); $language = null; $options = []; @@ -157,7 +157,7 @@ protected function getOptions() } } - if ($language) { + if ($language !== null && $language !== []) { $query->whereIn($db->quoteName('a.language'), $language, ParameterType::STRING); } diff --git a/libraries/src/Form/Field/TransitionField.php b/libraries/src/Form/Field/TransitionField.php index 77c7e93eed2e0..b8a875832358d 100644 --- a/libraries/src/Form/Field/TransitionField.php +++ b/libraries/src/Form/Field/TransitionField.php @@ -156,7 +156,7 @@ protected function getGroups() $groups[Text::_('COM_CONTENT_RUN_TRANSITION')] = $items; } - if (\count($groups)) { + if (\count($groups) !== 0) { $default[][] = HTMLHelper::_('select.option', '-1', '--------', ['disable' => true]); } diff --git a/libraries/src/Form/Filter/UrlFilter.php b/libraries/src/Form/Filter/UrlFilter.php index 8e630b7ca1d44..0597484a54cd1 100644 --- a/libraries/src/Form/Filter/UrlFilter.php +++ b/libraries/src/Form/Filter/UrlFilter.php @@ -61,14 +61,14 @@ public function filter(\SimpleXMLElement $element, $value, $group = null, ?Regis // If there is no protocol and the relative option is not specified, // we assume that it is an external URL and prepend http:// if ( - ((string) $element['type'] === 'url' && !$protocol && !$element['relative']) - || ((string) $element['type'] !== 'url' && !$protocol) + ((string) $element['type'] === 'url' && ($protocol === 0 || ($protocol === '' || $protocol === '0') || $protocol === [] || $protocol === false || $protocol === null) && !$element['relative']) + || ((string) $element['type'] !== 'url' && ($protocol === 0 || ($protocol === '' || $protocol === '0') || $protocol === [] || $protocol === false || $protocol === null)) ) { $protocol = 'http'; // If it looks like an internal link, then add the root. $value = str_starts_with($value, 'index.php') ? Uri::root() . $value : $protocol . '://' . $value; - } elseif (!$protocol && $element['relative'] instanceof \SimpleXMLElement) { + } elseif (($protocol === 0 || ($protocol === '' || $protocol === '0') || $protocol === [] || $protocol === false || $protocol === null) && $element['relative'] instanceof \SimpleXMLElement) { // If relative URLS are allowed we assume that URLs without protocols are internal. $host = Uri::getInstance('SERVER')->getHost(); diff --git a/libraries/src/Form/Rule/TelRule.php b/libraries/src/Form/Rule/TelRule.php index da96f815698fe..a27508d071858 100644 --- a/libraries/src/Form/Rule/TelRule.php +++ b/libraries/src/Form/Rule/TelRule.php @@ -68,7 +68,7 @@ public function test(\SimpleXMLElement $element, $value, $group = null, ?Registr if ($plan === 'northamerica' || $plan === 'us') { $plan = 'NANP'; - } elseif ($plan === 'International' || $plan === 'int' || $plan === 'missdn' || !$plan) { + } elseif ($plan === 'International' || $plan === 'int' || $plan === 'missdn' || ($plan === '' || $plan === '0')) { $plan = 'ITU-T'; } elseif ($plan === 'IETF') { $plan = 'EPP'; diff --git a/libraries/src/Form/Rule/TimeRule.php b/libraries/src/Form/Rule/TimeRule.php index 1b09510de6bfe..dd84f6a79c367 100644 --- a/libraries/src/Form/Rule/TimeRule.php +++ b/libraries/src/Form/Rule/TimeRule.php @@ -76,7 +76,7 @@ public function test(\SimpleXMLElement $element, $value, $group = null, ?Registr } // If the are other symbols except of numbers and ':' return error message - if (!preg_match('#^[0-9:]+$#', $stringValue)) { + if (in_array(preg_match('#^[0-9:]+$#', $stringValue), [0, false], true)) { Factory::getApplication()->enqueueMessage( Text::_('JLIB_FORM_FIELD_INVALID_TIME_INPUT'), 'warning' diff --git a/libraries/src/HTML/HTMLHelper.php b/libraries/src/HTML/HTMLHelper.php index f718f0c2f6fa2..9e6b788d459ee 100644 --- a/libraries/src/HTML/HTMLHelper.php +++ b/libraries/src/HTML/HTMLHelper.php @@ -609,7 +609,7 @@ public static function cleanImageURL($url) $url = ''; } - if (!strpos($url, '?')) { + if (in_array(strpos($url, '?'), [0, false], true)) { $obj->url = $url; return $obj; @@ -691,7 +691,7 @@ public static function image($file, $alt, $attribs = null, $relative = false, $r $includes = static::includeRelativeFiles('images', $path, $relative, false, false); // Grab the first found path and if none exists default to null - $path = \count($includes) ? $includes[0] : null; + $path = \count($includes) !== 0 ? $includes[0] : null; } // Compile the file name diff --git a/libraries/src/HTML/Helpers/JGrid.php b/libraries/src/HTML/Helpers/JGrid.php index eb5266d3bc058..1a986d4d62663 100644 --- a/libraries/src/HTML/Helpers/JGrid.php +++ b/libraries/src/HTML/Helpers/JGrid.php @@ -252,7 +252,7 @@ public static function published( } } - return static::state($states, $value, $i, ['prefix' => $prefix, 'translate' => !$tip], $enabled, true, $checkbox, $formId); + return static::state($states, $value, $i, ['prefix' => $prefix, 'translate' => $tip === '' || $tip === '0' || $tip === false], $enabled, true, $checkbox, $formId); } return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox, $formId); diff --git a/libraries/src/HTML/Helpers/Menu.php b/libraries/src/HTML/Helpers/Menu.php index 77dc5b32ae674..242a497835d96 100644 --- a/libraries/src/HTML/Helpers/Menu.php +++ b/libraries/src/HTML/Helpers/Menu.php @@ -331,7 +331,7 @@ public static function linkOptions($all = false, $unassigned = false, $clientId // First pass - collect children foreach ($mitems as $v) { $pt = $v->parent_id; - $list = @$children[$pt] ? $children[$pt] : []; + $list = @$children[$pt] !== [] ? $children[$pt] : []; $list[] = $v; $children[$pt] = $list; } diff --git a/libraries/src/HTML/Helpers/Select.php b/libraries/src/HTML/Helpers/Select.php index ef363eb3bdcb4..77355f7165435 100644 --- a/libraries/src/HTML/Helpers/Select.php +++ b/libraries/src/HTML/Helpers/Select.php @@ -554,7 +554,7 @@ public static function options($arr, $optKey = 'value', $optText = 'text', $sele $splitText = explode(' - ', (string) $text, 2); $text = $splitText[0]; - if (isset($splitText[1]) && $splitText[1] !== '' && !preg_match('/^[\s]+$/', $splitText[1])) { + if (isset($splitText[1]) && $splitText[1] !== '' && in_array(preg_match('/^[\s]+$/', $splitText[1]), [0, false], true)) { $text .= ' - ' . $splitText[1]; } diff --git a/libraries/src/Help/Help.php b/libraries/src/Help/Help.php index 362c64307256d..0866255bda9a3 100644 --- a/libraries/src/Help/Help.php +++ b/libraries/src/Help/Help.php @@ -76,7 +76,7 @@ public static function createUrl($ref, $useComponent = false, $override = null, } // If the URL is local then make sure we have a valid file extension on the URL. - if ($local && !preg_match('#\.html$|\.xml$#i', $ref)) { + if ($local && in_array(preg_match('#\.html$|\.xml$#i', $ref), [0, false], true)) { $url .= '.html'; } diff --git a/libraries/src/Helper/MediaHelper.php b/libraries/src/Helper/MediaHelper.php index 35a82c45835e3..d303e5bde44a8 100644 --- a/libraries/src/Helper/MediaHelper.php +++ b/libraries/src/Helper/MediaHelper.php @@ -231,7 +231,7 @@ public function canUpload($file, $component = 'com_media', $allowedExecutables = $executables = array_merge(self::EXECUTABLES, InputFilter::FORBIDDEN_FILE_EXTENSIONS); // Remove allowed executables from array - if (\count($allowedExecutables)) { + if (\count($allowedExecutables) !== 0) { $executables = array_diff($executables, $allowedExecutables); } diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index bfbe27fe57af6..60b925c579161 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -327,7 +327,7 @@ public static function getLayoutPath($module, $layout = 'default') $temp = explode(':', $layout); $template = $temp[0] === '_' ? $template : $temp[0]; $layout = $temp[1]; - $defaultLayout = $temp[1] ?: 'default'; + $defaultLayout = $temp[1] !== '' && $temp[1] !== '0' ? $temp[1] : 'default'; } $dPath = JPATH_BASE . '/modules/' . $module . '/tmpl/default.php'; diff --git a/libraries/src/Helper/PublicFolderGeneratorHelper.php b/libraries/src/Helper/PublicFolderGeneratorHelper.php index a8a506a3ad382..f4df7ad7e6fa8 100644 --- a/libraries/src/Helper/PublicFolderGeneratorHelper.php +++ b/libraries/src/Helper/PublicFolderGeneratorHelper.php @@ -212,7 +212,7 @@ private function createSymlink(string $source, string $dest, string $base): void */ private function createFile(string $path, string $content): void { - if (!file_put_contents($path, $content)) { + if (in_array(file_put_contents($path, $content), [0, false], true)) { throw new \Exception('Unable to create the file: ' . $path); } } diff --git a/libraries/src/Http/HttpFactory.php b/libraries/src/Http/HttpFactory.php index 92ceb9977acc7..466f274e3f6ba 100644 --- a/libraries/src/Http/HttpFactory.php +++ b/libraries/src/Http/HttpFactory.php @@ -75,7 +75,7 @@ public static function getAvailableDriver($options = [], $default = null) } // Check if there is at least one available http transport adapter - if (!\count($availableAdapters)) { + if (\count($availableAdapters) === 0) { return false; } diff --git a/libraries/src/Http/Transport/CurlTransport.php b/libraries/src/Http/Transport/CurlTransport.php index 029153446b1ea..403bb81c92762 100644 --- a/libraries/src/Http/Transport/CurlTransport.php +++ b/libraries/src/Http/Transport/CurlTransport.php @@ -244,7 +244,7 @@ protected function getResponse($content, $info) // Get the response code from the first offset of the response headers. preg_match('/\d{3}/', array_shift($headers), $matches); - $code = \count($matches) ? $matches[0] : null; + $code = $matches !== [] ? $matches[0] : null; if (!is_numeric($code)) { // No valid response code was detected. @@ -283,6 +283,6 @@ private function redirectsAllowed() { $curlVersion = curl_version(); // If open_basedir is enabled we also need to check if libcurl version is 7.19.4 or higher - return !\ini_get('open_basedir') || version_compare($curlVersion['version'], '7.19.4', '>='); + return in_array(\ini_get('open_basedir'), ['', '0'], true) || \ini_get('open_basedir') === false || version_compare($curlVersion['version'], '7.19.4', '>='); } } diff --git a/libraries/src/Image/Image.php b/libraries/src/Image/Image.php index c19f6d4a1c6f7..3d34568f5d552 100644 --- a/libraries/src/Image/Image.php +++ b/libraries/src/Image/Image.php @@ -178,7 +178,7 @@ public static function getImageFileProperties($path) // Get the image file information. $info = getimagesize($path); - if (!$info) { + if ($info === false) { throw new UnparsableImageException('Unable to get properties for the image.'); } diff --git a/libraries/src/Installer/Adapter/ComponentAdapter.php b/libraries/src/Installer/Adapter/ComponentAdapter.php index 527f6ede738dc..591f07b4975df 100644 --- a/libraries/src/Installer/Adapter/ComponentAdapter.php +++ b/libraries/src/Installer/Adapter/ComponentAdapter.php @@ -994,7 +994,7 @@ protected function _buildAdminMenus($componentId = null) $data['published'] = 1; $data['parent_id'] = 1; $data['component_id'] = $componentId; - $data['img'] = ((string) $menuElement->attributes()->img) ?: 'class:component'; + $data['img'] = ((string) $menuElement->attributes()->img !== '' && (string) $menuElement->attributes()->img !== '0') ? (string) $menuElement->attributes()->img : 'class:component'; $data['home'] = 0; $data['path'] = ''; $data['params'] = ''; @@ -1016,7 +1016,7 @@ protected function _buildAdminMenus($componentId = null) $request[] = 'view=' . $menuElement->attributes()->view; } - $qstring = \count($request) ? '&' . implode('&', $request) : ''; + $qstring = $request !== [] ? '&' . implode('&', $request) : ''; $data['link'] = 'index.php?option=' . $option . $qstring; // Try to create the menu item in the database @@ -1040,12 +1040,12 @@ protected function _buildAdminMenus($componentId = null) $data['menutype'] = 'main'; $data['client_id'] = 1; $data['title'] = trim($child); - $data['alias'] = ((string) $child->attributes()->alias) ?: (string) $child; - $data['type'] = ((string) $child->attributes()->type) ?: 'component'; + $data['alias'] = ((string) $child->attributes()->alias !== '' && (string) $child->attributes()->alias !== '0') ? (string) $child->attributes()->alias : (string) $child; + $data['type'] = ((string) $child->attributes()->type !== '' && (string) $child->attributes()->type !== '0') ? (string) $child->attributes()->type : 'component'; $data['published'] = 1; $data['parent_id'] = $parent_id; $data['component_id'] = $componentId; - $data['img'] = ((string) $child->attributes()->img) ?: 'class:component'; + $data['img'] = ((string) $child->attributes()->img !== '' && (string) $child->attributes()->img !== '0') ? (string) $child->attributes()->img : 'class:component'; $data['home'] = 0; $data['params'] = ''; @@ -1085,7 +1085,7 @@ protected function _buildAdminMenus($componentId = null) $request[] = 'sub=' . $child->attributes()->sub; } - $qstring = \count($request) ? '&' . implode('&', $request) : ''; + $qstring = $request !== [] ? '&' . implode('&', $request) : ''; $data['link'] = 'index.php?option=' . $option . $qstring; } diff --git a/libraries/src/Installer/Adapter/FileAdapter.php b/libraries/src/Installer/Adapter/FileAdapter.php index b3f7cdfdd323c..c7b353e7fcf12 100644 --- a/libraries/src/Installer/Adapter/FileAdapter.php +++ b/libraries/src/Installer/Adapter/FileAdapter.php @@ -293,7 +293,7 @@ protected function removeExtensionFiles() foreach ($folderList as $folder) { $files = Folder::files($folder); - if ($files !== false && !\count($files)) { + if ($files !== false && \count($files) === 0) { Folder::delete($folder); } } diff --git a/libraries/src/Installer/Adapter/LibraryAdapter.php b/libraries/src/Installer/Adapter/LibraryAdapter.php index d8fbb4209ef00..1001e41ddda2b 100644 --- a/libraries/src/Installer/Adapter/LibraryAdapter.php +++ b/libraries/src/Installer/Adapter/LibraryAdapter.php @@ -283,7 +283,7 @@ protected function removeExtensionFiles() // If the folder is empty, let's delete it if (is_dir(Path::clean($this->parent->getPath('extension_root'))) && is_dir($this->parent->getPath('extension_root'))) { $files = Folder::files($this->parent->getPath('extension_root')); - if (!\count($files)) { + if (\count($files) === 0) { Folder::delete($this->parent->getPath('extension_root')); } } diff --git a/libraries/src/Installer/Adapter/ModuleAdapter.php b/libraries/src/Installer/Adapter/ModuleAdapter.php index 992505bbef720..fd4aded410edb 100644 --- a/libraries/src/Installer/Adapter/ModuleAdapter.php +++ b/libraries/src/Installer/Adapter/ModuleAdapter.php @@ -363,7 +363,7 @@ public function loadLanguage($path = null) $source = $path . '/' . $folder; } - $client = (string) $this->getManifest()->attributes()->client ?: 'site'; + $client = (string) $this->getManifest()->attributes()->client !== '' && (string) $this->getManifest()->attributes()->client !== '0' ? (string) $this->getManifest()->attributes()->client : 'site'; $this->doLoadLanguage($extension, $source, \constant('JPATH_' . strtoupper($client))); } } diff --git a/libraries/src/Installer/Adapter/TemplateAdapter.php b/libraries/src/Installer/Adapter/TemplateAdapter.php index 9854ee57790c8..2212ed3d0e362 100644 --- a/libraries/src/Installer/Adapter/TemplateAdapter.php +++ b/libraries/src/Installer/Adapter/TemplateAdapter.php @@ -333,7 +333,7 @@ protected function parseQueries() Text::sprintf('JLIB_INSTALLER_DEFAULT_STYLE', Text::_($this->extension->name)), $this->extension->params, (int) $this->manifest->inheritable, - (string) $this->manifest->parent ?: '', + (string) $this->manifest->parent !== '' && (string) $this->manifest->parent !== '0' ? (string) $this->manifest->parent : '', ], [ ParameterType::STRING, diff --git a/libraries/src/Installer/Installer.php b/libraries/src/Installer/Installer.php index 553568688f3be..485ea2383294f 100644 --- a/libraries/src/Installer/Installer.php +++ b/libraries/src/Installer/Installer.php @@ -1020,7 +1020,7 @@ public function parseQueries(\SimpleXMLElement $element) */ public function parseSQLFiles($element) { - if (!$element || !\count($element->children())) { + if (!$element || \count($element->children()) === 0) { // The tag does not exist. return 0; } @@ -1843,7 +1843,7 @@ public function copyFiles($files, $overwrite = null) */ public function removeFiles($element, $cid = 0) { - if (!$element || !\count($element->children())) { + if (!$element || \count($element->children()) === 0) { // Either the tag does not exist or has no children therefore we return zero files processed. return true; } @@ -1869,7 +1869,7 @@ public function removeFiles($element, $cid = 0) */ switch ($element->getName()) { case 'media': - $folder = (string) $element->attributes()->destination ?: ''; + $folder = (string) $element->attributes()->destination !== '' && (string) $element->attributes()->destination !== '0' ? (string) $element->attributes()->destination : ''; $source = $client->path . '/media/' . $folder; @@ -2272,8 +2272,8 @@ public static function parseXMLInstallFile($path) // Check if we're a language. If so use metafile. $data['type'] = $xml->getName() === 'metafile' ? 'language' : (string) $xml->attributes()->type; - $data['creationDate'] = ((string) $xml->creationDate) ?: Text::_('JLIB_UNKNOWN'); - $data['author'] = ((string) $xml->author) ?: Text::_('JLIB_UNKNOWN'); + $data['creationDate'] = ((string) $xml->creationDate !== '' && (string) $xml->creationDate !== '0') ? (string) $xml->creationDate : Text::_('JLIB_UNKNOWN'); + $data['author'] = ((string) $xml->author !== '' && (string) $xml->author !== '0') ? (string) $xml->author : Text::_('JLIB_UNKNOWN'); $data['copyright'] = (string) $xml->copyright; $data['authorEmail'] = (string) $xml->authorEmail; diff --git a/libraries/src/Installer/InstallerHelper.php b/libraries/src/Installer/InstallerHelper.php index 1f1c4d98e1116..e80f79a7af484 100644 --- a/libraries/src/Installer/InstallerHelper.php +++ b/libraries/src/Installer/InstallerHelper.php @@ -240,7 +240,7 @@ public static function detectType($packageDirectory) // Search the install dir for an XML file $files = Folder::files($packageDirectory, '\.xml$', 1, true); - if (!$files || !\count($files)) { + if (!$files || \count($files) === 0) { Log::add(Text::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE'), Log::WARNING, 'jerror'); return false; @@ -299,7 +299,7 @@ public static function getFilenameFromUrl($url) $filename = preg_replace('/__+/', '_', trim((string) $filename, '_')); // Return the cleaned filename or, if it is empty, a unique id. - return $filename ?: $default; + return $filename !== '' && $filename !== '0' && $filename !== [] ? $filename : $default; } /** diff --git a/libraries/src/Language/Language.php b/libraries/src/Language/Language.php index 12d3e64f69140..77a28e5f8a870 100644 --- a/libraries/src/Language/Language.php +++ b/libraries/src/Language/Language.php @@ -297,7 +297,7 @@ public function transliterate($string) $string = \call_user_func($this->transliterator, $string); // Check if all symbols were transliterated (contains only ASCII), otherwise continue - if (!preg_match('/[\\x80-\\xff]/', (string) $string)) { + if (in_array(preg_match('/[\\x80-\\xff]/', (string) $string), [0, false], true)) { return $string; } } @@ -705,7 +705,7 @@ protected function parse($fileName) $strings = []; // Debug the ini file if needed. - if ($this->debug && is_file($fileName) && !$this->debugFile($fileName)) { + if ($this->debug && is_file($fileName) && $this->debugFile($fileName) === 0) { // We didn't find any errors but there's a parser warning. $this->errorfiles[$fileName] = 'PHP parser errors :' . $runtimeException->getMessage(); } @@ -749,7 +749,7 @@ public function debugFile(string $filename): int $line = trim($line); // Ignore comment lines. - if (!\strlen($line) || $line['0'] == ';') { + if ($line === '' || $line['0'] == ';') { continue; } @@ -770,7 +770,7 @@ public function debugFile(string $filename): int } // Check that the line passes the necessary format. - if (!preg_match('#^[A-Z][A-Z0-9_:\*\-\.]*\s*=\s*".*"(\s*;.*)?$#', $line)) { + if (in_array(preg_match('#^[A-Z][A-Z0-9_:\*\-\.]*\s*=\s*".*"(\s*;.*)?$#', $line), [0, false], true)) { $errors[] = $realNumber; continue; } diff --git a/libraries/src/Language/Multilanguage.php b/libraries/src/Language/Multilanguage.php index 3b2465702bf5b..8ff50cdcd160c 100644 --- a/libraries/src/Language/Multilanguage.php +++ b/libraries/src/Language/Multilanguage.php @@ -54,7 +54,7 @@ public static function isEnabled(?CMSApplication $app = null, ?DatabaseInterface } // Get application object. - $app = $app ?: Factory::getApplication(); + $app = $app instanceof CMSApplication ? $app : Factory::getApplication(); // If being called from the frontend, we can avoid the database query. if ($app->isClient('site')) { @@ -66,7 +66,7 @@ public static function isEnabled(?CMSApplication $app = null, ?DatabaseInterface // If already tested, don't test again. if (!$tested) { // Determine status of language filter plugin. - $db = $db ?: Factory::getDbo(); + $db = $db instanceof DatabaseInterface ? $db : Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('enabled')) ->from($db->quoteName('#__extensions')) @@ -102,7 +102,7 @@ public static function getSiteHomePages(?DatabaseInterface $db = null) if (!isset($multilangSiteHomePages)) { // Check for Home pages languages. - $db = $db ?: Factory::getDbo(); + $db = $db instanceof DatabaseInterface ? $db : Factory::getDbo(); $query = $db->getQuery(true) ->select( [ diff --git a/libraries/src/Language/Text.php b/libraries/src/Language/Text.php index 3f3918171e3af..aede20ab9689c 100644 --- a/libraries/src/Language/Text.php +++ b/libraries/src/Language/Text.php @@ -110,7 +110,7 @@ private static function passSprintf(&$string, $jsSafe = false, $interpretBackSla $first_part = preg_replace('/\[\[%(\d+):[^\]]*\]\]/', '%\1$s', $first_part); // Check if string contains sprintf placeholders - if (!preg_match('/%(\d+\$)?s/', (string) $first_part)) { + if (in_array(preg_match('/%(\d+\$)?s/', (string) $first_part), [0, false], true)) { return false; } diff --git a/libraries/src/MVC/Controller/AdminController.php b/libraries/src/MVC/Controller/AdminController.php index 9ac5b1569f0d1..499540119885a 100644 --- a/libraries/src/MVC/Controller/AdminController.php +++ b/libraries/src/MVC/Controller/AdminController.php @@ -116,7 +116,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, if ($reflect->getNamespaceName() !== '' && $reflect->getNamespaceName() !== '0') { $r[2] = str_replace('Controller', '', $r[2]); - } elseif (!preg_match('/(.*)Controller(.*)/i', $reflect->getShortName(), $r)) { + } elseif (in_array(preg_match('/(.*)Controller(.*)/i', $reflect->getShortName(), $r), [0, false], true)) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500); } diff --git a/libraries/src/MVC/Controller/ApiController.php b/libraries/src/MVC/Controller/ApiController.php index 026521eb45f1d..94a171520e7bb 100644 --- a/libraries/src/MVC/Controller/ApiController.php +++ b/libraries/src/MVC/Controller/ApiController.php @@ -129,7 +129,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, if (empty($this->context)) { $r = null; - if (!preg_match('/(.*)Controller(.*)/i', static::class, $r)) { + if (in_array(preg_match('/(.*)Controller(.*)/i', static::class, $r), [0, false], true)) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500); } diff --git a/libraries/src/MVC/Controller/BaseController.php b/libraries/src/MVC/Controller/BaseController.php index 9c8896936efce..5ec71f0a5ab6d 100644 --- a/libraries/src/MVC/Controller/BaseController.php +++ b/libraries/src/MVC/Controller/BaseController.php @@ -360,8 +360,8 @@ public static function getInstance($prefix, $config = []) */ public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?CMSApplicationInterface $app = null, ?Input $input = null) { - $this->app = $app ?: Factory::getApplication(); - $this->input = $input ?: $this->app->getInput(); + $this->app = $app instanceof CMSApplicationInterface ? $app : Factory::getApplication(); + $this->input = $input instanceof Input ? $input : $this->app->getInput(); /** * @deprecated This is to maintain b/c with the J4.0 implementation of BaseController. In Joomla 6.0 this will be @@ -443,7 +443,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null, $this->default_view = $this->getName(); } - $this->factory = $factory ?: new LegacyFactory(); + $this->factory = $factory instanceof MVCFactoryInterface ? $factory : new LegacyFactory(); } /** @@ -777,7 +777,7 @@ public function getName() if (empty($this->name)) { $r = null; - if (!preg_match('/(.*)Controller/i', static::class, $r)) { + if (in_array(preg_match('/(.*)Controller/i', static::class, $r), [0, false], true)) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500); } diff --git a/libraries/src/MVC/Controller/FormController.php b/libraries/src/MVC/Controller/FormController.php index f79ecaf9c92d8..20276c8e9f6cc 100644 --- a/libraries/src/MVC/Controller/FormController.php +++ b/libraries/src/MVC/Controller/FormController.php @@ -131,7 +131,7 @@ public function __construct( $match .= '\\\\'; } - if (!preg_match('/(.*)' . $match . '(.*)/i', static::class, $r)) { + if (in_array(preg_match('/(.*)' . $match . '(.*)/i', static::class, $r), [0, false], true)) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500); } @@ -391,7 +391,7 @@ public function edit($key = null, $urlVar = null) } // Get the previous record id (if any) and the current record id. - $recordId = (int) (\count($cid) ? $cid[0] : $this->input->getInt($urlVar)); + $recordId = (int) ($cid !== [] ? $cid[0] : $this->input->getInt($urlVar)); $checkin = $table->hasField('checked_out'); // Access check. diff --git a/libraries/src/MVC/Factory/MVCFactory.php b/libraries/src/MVC/Factory/MVCFactory.php index 0647f43407962..82a98e10dddba 100644 --- a/libraries/src/MVC/Factory/MVCFactory.php +++ b/libraries/src/MVC/Factory/MVCFactory.php @@ -139,7 +139,7 @@ public function createModel($name, $prefix = '', array $config = []) $name = preg_replace('/[^A-Z0-9_]/i', '', $name); $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); - if (!$prefix) { + if ($prefix === '' || $prefix === '0' || $prefix === [] || $prefix === null) { @trigger_error( \sprintf( 'Calling %s() without a prefix is deprecated.', @@ -197,7 +197,7 @@ public function createView($name, $prefix = '', $type = '', array $config = []) $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); $type = preg_replace('/[^A-Z0-9_]/i', '', $type); - if (!$prefix) { + if ($prefix === '' || $prefix === '0' || $prefix === [] || $prefix === null) { @trigger_error( \sprintf( 'Calling %s() without a prefix is deprecated.', @@ -243,7 +243,7 @@ public function createTable($name, $prefix = '', array $config = []) $name = preg_replace('/[^A-Z0-9_]/i', '', $name); $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); - if (!$prefix) { + if ($prefix === '' || $prefix === '0' || $prefix === [] || $prefix === null) { @trigger_error( \sprintf( 'Calling %s() without a prefix is deprecated.', diff --git a/libraries/src/MVC/Model/BaseDatabaseModel.php b/libraries/src/MVC/Model/BaseDatabaseModel.php index 9773baea76368..fec0401ae5faf 100644 --- a/libraries/src/MVC/Model/BaseDatabaseModel.php +++ b/libraries/src/MVC/Model/BaseDatabaseModel.php @@ -90,7 +90,7 @@ public function __construct($config = [], ?MVCFactoryInterface $factory = null) if (empty($this->option)) { $r = null; - if (!preg_match('/(.*)Model/i', static::class, $r)) { + if (in_array(preg_match('/(.*)Model/i', static::class, $r), [0, false], true)) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500); } diff --git a/libraries/src/MVC/Model/BaseModel.php b/libraries/src/MVC/Model/BaseModel.php index 4778f1f181d4d..5b0bebb9b1930 100644 --- a/libraries/src/MVC/Model/BaseModel.php +++ b/libraries/src/MVC/Model/BaseModel.php @@ -135,7 +135,7 @@ public function getName() if (empty($this->name)) { $r = null; - if (!preg_match('/Model(.*)/i', static::class, $r)) { + if (in_array(preg_match('/Model(.*)/i', static::class, $r), [0, false], true)) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_GET_NAME', __METHOD__), 500); } diff --git a/libraries/src/MVC/View/FormView.php b/libraries/src/MVC/View/FormView.php index 2be9182f1ac02..60ea647c0e70f 100644 --- a/libraries/src/MVC/View/FormView.php +++ b/libraries/src/MVC/View/FormView.php @@ -240,7 +240,7 @@ protected function addToolbar() $formConfig = $this->form->getXml()->config->inlinehelp; if ($formConfig && (string) $formConfig['button'] === 'show') { - $targetClass = (string) $formConfig['targetclass'] ?: 'hide-aware-inline-help'; + $targetClass = (string) $formConfig['targetclass'] !== '' && (string) $formConfig['targetclass'] !== '0' ? (string) $formConfig['targetclass'] : 'hide-aware-inline-help'; ToolbarHelper::inlinehelp($targetClass); } } diff --git a/libraries/src/MVC/View/HtmlView.php b/libraries/src/MVC/View/HtmlView.php index 44be5092b173b..eaf6391523942 100644 --- a/libraries/src/MVC/View/HtmlView.php +++ b/libraries/src/MVC/View/HtmlView.php @@ -306,7 +306,7 @@ public function setLayoutExt($value) { $previous = $this->_layoutExt; - if ($value = preg_replace('#[^A-Za-z0-9]#', '', trim($value))) { + if ($value = preg_replace('#[^A-Za-z0-9]#', '', trim((string) $value)) !== '' && $value = preg_replace('#[^A-Za-z0-9]#', '', trim((string) $value)) !== '0' && $value = preg_replace('#[^A-Za-z0-9]#', '', trim((string) $value)) !== []) { $this->_layoutExt = $value; } diff --git a/libraries/src/Mail/MailHelper.php b/libraries/src/Mail/MailHelper.php index 2711a92f9f601..3e8438b1b77fa 100644 --- a/libraries/src/Mail/MailHelper.php +++ b/libraries/src/Mail/MailHelper.php @@ -136,7 +136,7 @@ public static function isEmailAddress($email) $allowed = "a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-"; $regex = sprintf('/^[%s][\.%s]{0,63}$/', $allowed, $allowed); - if (!preg_match($regex, $local) || str_ends_with($local, '.') || $local[0] === '.' || preg_match('/\.\./', $local)) { + if (in_array(preg_match($regex, $local), [0, false], true) || str_ends_with($local, '.') || $local[0] === '.' || preg_match('/\.\./', $local)) { return false; } @@ -168,7 +168,7 @@ public static function isEmailAddress($email) } // Check for invalid characters - if (!preg_match($regex, $domain)) { + if (in_array(preg_match($regex, $domain), [0, false], true)) { return false; } diff --git a/libraries/src/Mail/MailTemplate.php b/libraries/src/Mail/MailTemplate.php index afc4fb1065dbc..c7d75a1f8181f 100644 --- a/libraries/src/Mail/MailTemplate.php +++ b/libraries/src/Mail/MailTemplate.php @@ -112,7 +112,7 @@ public function __construct(/** */ protected $language, ?Mail $mailer = null) { - $this->mailer = $mailer ?: Factory::getMailer(); + $this->mailer = $mailer instanceof Mail ? $mailer : Factory::getMailer(); } /** diff --git a/libraries/src/Pagination/Pagination.php b/libraries/src/Pagination/Pagination.php index a2a56312c4658..af5232d8a4145 100644 --- a/libraries/src/Pagination/Pagination.php +++ b/libraries/src/Pagination/Pagination.php @@ -151,7 +151,7 @@ public function __construct($total, $limitstart, $limit, /** $this->total = (int) $total; $this->limitstart = max($limitstart, 0); $this->limit = max($limit, 0); - $this->app = $app ?: Factory::getApplication(); + $this->app = $app instanceof CMSApplication ? $app : Factory::getApplication(); if ($this->limit > $this->total) { $this->limitstart = 0; diff --git a/libraries/src/Pathway/SitePathway.php b/libraries/src/Pathway/SitePathway.php index 836ec5d046b74..223a5b9cae726 100644 --- a/libraries/src/Pathway/SitePathway.php +++ b/libraries/src/Pathway/SitePathway.php @@ -35,7 +35,7 @@ public function __construct(?SiteApplication $app = null) { $this->pathway = []; - $app = $app ?: Factory::getContainer()->get(SiteApplication::class); + $app = $app instanceof SiteApplication ? $app : Factory::getContainer()->get(SiteApplication::class); $menu = $app->getMenu(); $lang = Factory::getLanguage(); diff --git a/libraries/src/Plugin/PluginHelper.php b/libraries/src/Plugin/PluginHelper.php index 2782c79996f37..b714a14bf8177 100644 --- a/libraries/src/Plugin/PluginHelper.php +++ b/libraries/src/Plugin/PluginHelper.php @@ -67,7 +67,7 @@ public static function getLayoutPath($type, $name, $layout = 'default') $temp = explode(':', $layout); $template = $temp[0] === '_' ? $templateObj->template : $temp[0]; $layout = $temp[1]; - $defaultLayout = $temp[1] ?: 'default'; + $defaultLayout = $temp[1] !== '' && $temp[1] !== '0' ? $temp[1] : 'default'; } // Build the template and base path for the layout @@ -172,7 +172,7 @@ public static function importPlugin($type, $plugin = null, $autocreate = true, ? } // Ensure we have a dispatcher now so we can correctly track the loaded plugins - $dispatcher = $dispatcher ?: Factory::getApplication()->getDispatcher(); + $dispatcher = $dispatcher instanceof DispatcherInterface ? $dispatcher : Factory::getApplication()->getDispatcher(); // Get the dispatcher's hash to allow plugins to be registered to unique dispatchers $dispatcherHash = spl_object_hash($dispatcher); diff --git a/libraries/src/Router/SiteRouter.php b/libraries/src/Router/SiteRouter.php index 967716ec1c896..c1644045c52b8 100644 --- a/libraries/src/Router/SiteRouter.php +++ b/libraries/src/Router/SiteRouter.php @@ -64,8 +64,8 @@ class SiteRouter extends Router */ public function __construct(?CMSApplication $app = null, ?AbstractMenu $menu = null) { - $this->app = $app ?: Factory::getContainer()->get(SiteApplication::class); - $this->menu = $menu ?: $this->app->getMenu(); + $this->app = $app instanceof CMSApplication ? $app : Factory::getContainer()->get(SiteApplication::class); + $this->menu = $menu instanceof AbstractMenu ? $menu : $this->app->getMenu(); // Add core rules if ((int) $this->app->get('force_ssl') === 2) { diff --git a/libraries/src/Schema/ChangeItem/PostgresqlChangeItem.php b/libraries/src/Schema/ChangeItem/PostgresqlChangeItem.php index 2efd7f86a5752..5997700ae28e1 100644 --- a/libraries/src/Schema/ChangeItem/PostgresqlChangeItem.php +++ b/libraries/src/Schema/ChangeItem/PostgresqlChangeItem.php @@ -259,8 +259,8 @@ protected function buildCheckQuery() $this->msgElements = [$table]; } // Set fields based on results - $this->checkStatus = $result ? 0 : -1; - $this->checkQuery = $result ? 0 : -1; + $this->checkStatus = $result !== null && $result !== '' && $result !== '0' ? 0 : -1; + $this->checkQuery = $result !== null && $result !== '' && $result !== '0' ? 0 : -1; } /** diff --git a/libraries/src/Table/Category.php b/libraries/src/Table/Category.php index 7db7a3710cbaa..4536a4cbf9e22 100644 --- a/libraries/src/Table/Category.php +++ b/libraries/src/Table/Category.php @@ -140,7 +140,7 @@ protected function _getAssetParentId(?Table $table = null, $id = null) } // Return the asset id. - if ($assetId) { + if ($assetId !== null && $assetId !== 0) { return $assetId; } diff --git a/libraries/src/Table/Content.php b/libraries/src/Table/Content.php index 5e5e86201d0f7..b0fb96ca0052e 100644 --- a/libraries/src/Table/Content.php +++ b/libraries/src/Table/Content.php @@ -126,7 +126,7 @@ protected function _getAssetParentId(?Table $table = null, $id = null) } // Return the asset id. - if ($assetId) { + if ($assetId !== null && $assetId !== 0) { return $assetId; } diff --git a/libraries/src/Table/ContentType.php b/libraries/src/Table/ContentType.php index a86ab759a1be9..b2dd2a4d40e72 100644 --- a/libraries/src/Table/ContentType.php +++ b/libraries/src/Table/ContentType.php @@ -144,7 +144,7 @@ public function getContentTable() if (\is_object($tableInfo) && isset($tableInfo->special) && (\is_object($tableInfo->special) && isset($tableInfo->special->type) && isset($tableInfo->special->prefix))) { $class = $tableInfo->special->class ?? Table::class; - if (!class_implements($class, TableInterface::class)) { + if (in_array(class_implements($class, TableInterface::class), [[], false], true)) { // This isn't an instance of TableInterface. Stop. throw new \RuntimeException('Class must be an instance of Joomla\\CMS\\Table\\TableInterface'); } diff --git a/libraries/src/Table/Module.php b/libraries/src/Table/Module.php index 19a258dba4176..012c3bcb7c342 100644 --- a/libraries/src/Table/Module.php +++ b/libraries/src/Table/Module.php @@ -103,7 +103,7 @@ protected function _getAssetParentId(?Table $table = null, $id = null) } // Return the asset id. - if ($assetId) { + if ($assetId !== null && $assetId !== 0) { return $assetId; } diff --git a/libraries/src/Table/Table.php b/libraries/src/Table/Table.php index 48523327c182e..bb906ae0dd713 100644 --- a/libraries/src/Table/Table.php +++ b/libraries/src/Table/Table.php @@ -484,7 +484,7 @@ public function getTableName() public function getKeyName($multiple = false) { // Count the number of keys - if (\count($this->_tbl_keys)) { + if (\count($this->_tbl_keys) !== 0) { if ($multiple) { // If we want multiple keys, return the raw array. return $this->_tbl_keys; diff --git a/libraries/src/Table/User.php b/libraries/src/Table/User.php index 278a0589ba231..64b6583dc459c 100644 --- a/libraries/src/Table/User.php +++ b/libraries/src/Table/User.php @@ -300,7 +300,7 @@ public function check() $xid = (int) $this->_db->loadResult(); if ( - $rootUser == $this->username && (!$xid || $xid && $xid != (int) $this->id) + $rootUser == $this->username && ($xid === 0 || $xid && $xid != (int) $this->id) || $xid && $xid == (int) $this->id && $rootUser != $this->username ) { $this->setError(Text::_('JLIB_DATABASE_ERROR_USERNAME_CANNOT_CHANGE')); @@ -393,7 +393,7 @@ public function store($updateNulls = true) } // If there is anything left in this->groups it needs to be inserted - if (\count($groups)) { + if (\count($groups) !== 0) { // Set the new user group maps. $query->clear() ->insert($this->_db->quoteName('#__user_usergroup_map')) diff --git a/libraries/src/UCM/UCMBase.php b/libraries/src/UCM/UCMBase.php index ccc60cd92cd40..e6edb603a73d1 100644 --- a/libraries/src/UCM/UCMBase.php +++ b/libraries/src/UCM/UCMBase.php @@ -55,7 +55,7 @@ public function __construct($alias = null, ?UCMType $type = null) $input = Factory::getApplication()->getInput(); $this->alias = $alias ?: $input->get('option') . '.' . $input->get('view'); - $this->type = $type ?: $this->getType(); + $this->type = $type instanceof UCMType ? $type : $this->getType(); } /** @@ -126,7 +126,7 @@ public function getType() */ public function mapBase($original, ?UCMType $type = null) { - $type = $type ?: $this->type; + $type = $type instanceof UCMType ? $type : $this->type; return [ 'ucm_type_id' => $type->id, diff --git a/libraries/src/UCM/UCMContent.php b/libraries/src/UCM/UCMContent.php index 1304ed98c5903..8c5505e882a2f 100644 --- a/libraries/src/UCM/UCMContent.php +++ b/libraries/src/UCM/UCMContent.php @@ -75,7 +75,7 @@ public function __construct(?TableInterface $table = null, $alias = null, ?UCMTy */ public function save($original = null, ?UCMType $type = null) { - $type = $type ?: $this->type; + $type = $type instanceof UCMType ? $type : $this->type; $ucmData = $original ? $this->mapData($original, $type) : $this->ucmData; // Store the Common fields @@ -103,7 +103,7 @@ public function save($original = null, ?UCMType $type = null) public function delete($pk, ?UCMType $type = null) { $db = Factory::getDbo(); - $type = $type ?: $this->type; + $type = $type instanceof UCMType ? $type : $this->type; if (!\is_array($pk)) { $pk = explode(',', (string) $pk); @@ -133,7 +133,7 @@ public function delete($pk, ?UCMType $type = null) */ public function mapData($original, ?UCMType $type = null) { - $contentType = $type ?: $this->type; + $contentType = $type instanceof UCMType ? $type : $this->type; $fields = json_decode($contentType->type->field_mappings); @@ -182,7 +182,7 @@ public function mapData($original, ?UCMType $type = null) */ protected function store($data, ?TableInterface $table = null, $primaryKey = null) { - $table = $table ?: Table::getInstance('CoreContent'); + $table = $table instanceof TableInterface ? $table : Table::getInstance('CoreContent'); $typeId = $this->getType()->type->type_id; $primaryKey = $primaryKey ?: $this->getPrimaryKey($typeId, $data['core_content_item_id']); diff --git a/libraries/src/UCM/UCMType.php b/libraries/src/UCM/UCMType.php index 2aa078811e827..39e6c64a3f93c 100644 --- a/libraries/src/UCM/UCMType.php +++ b/libraries/src/UCM/UCMType.php @@ -93,8 +93,8 @@ class UCMType implements UCM */ public function __construct($alias = null, ?DatabaseDriver $database = null, ?AbstractApplication $application = null) { - $this->db = $database ?: Factory::getDbo(); - $app = $application ?: Factory::getApplication(); + $this->db = $database instanceof DatabaseDriver ? $database : Factory::getDbo(); + $app = $application instanceof AbstractApplication ? $application : Factory::getApplication(); // Make the best guess we can in the absence of information. $this->alias = $alias ?: $app->getInput()->get('option') . '.' . $app->getInput()->get('view'); diff --git a/libraries/src/Updater/Adapter/ExtensionAdapter.php b/libraries/src/Updater/Adapter/ExtensionAdapter.php index d90595c024409..6cab4f1aab0e1 100644 --- a/libraries/src/Updater/Adapter/ExtensionAdapter.php +++ b/libraries/src/Updater/Adapter/ExtensionAdapter.php @@ -155,7 +155,7 @@ protected function _endElement($parser, $name) $minimumVersion = $supportedDbs[$dbTypeUcase]; $dbMatch = version_compare($dbVersion, $minimumVersion, '>='); - if (!$dbMatch) { + if ($dbMatch === 0 || $dbMatch === false) { // Notify the user of the potential update $dbMsg = Text::sprintf( 'JLIB_INSTALLER_AVAILABLE_UPDATE_DB_MINIMUM', diff --git a/libraries/src/Updater/Adapter/TufAdapter.php b/libraries/src/Updater/Adapter/TufAdapter.php index 59fa42721a488..5b683bb90fddc 100644 --- a/libraries/src/Updater/Adapter/TufAdapter.php +++ b/libraries/src/Updater/Adapter/TufAdapter.php @@ -92,7 +92,7 @@ public function getUpdateTargets($options) foreach ($metaData['signed']['targets'] as $filename => $target) { $version = $this->processTufTarget($filename, $target); - if (!$version) { + if ($version === false || $version === []) { continue; } diff --git a/libraries/src/Updater/ConstraintChecker.php b/libraries/src/Updater/ConstraintChecker.php index e002b6a256bf9..a472e1f96045f 100644 --- a/libraries/src/Updater/ConstraintChecker.php +++ b/libraries/src/Updater/ConstraintChecker.php @@ -151,7 +151,7 @@ protected function checkPhpMinimum(string $phpMinimum) // Check if PHP version supported via tag $result = version_compare(PHP_VERSION, $phpMinimum, '>='); - if (!$result) { + if ($result === 0 || $result === false) { $this->failedEnvironmentConstraints->php = new \stdClass(); $this->failedEnvironmentConstraints->php->required = $phpMinimum; $this->failedEnvironmentConstraints->php->used = PHP_VERSION; @@ -191,7 +191,7 @@ protected function checkSupportedDatabases(array $supportedDatabases) $result = version_compare($dbVersion, $minimumVersion, '>='); - if (!$result) { + if ($result === 0 || $result === false) { $this->failedEnvironmentConstraints->db = new \stdClass(); $this->failedEnvironmentConstraints->db->type = $dbType; $this->failedEnvironmentConstraints->db->required = $minimumVersion; diff --git a/libraries/src/Updater/Update.php b/libraries/src/Updater/Update.php index 37761e178b959..549b6aef34e2d 100644 --- a/libraries/src/Updater/Update.php +++ b/libraries/src/Updater/Update.php @@ -437,7 +437,7 @@ public function _endElement($parser, $name) $minimumVersion = $supportedDbs->$dbType; $dbMatch = version_compare($dbVersion, $minimumVersion, '>='); - if (!$dbMatch) { + if ($dbMatch === 0 || $dbMatch === false) { $otherUpdateInfo->db = new \stdClass(); $otherUpdateInfo->db->type = $dbType; $otherUpdateInfo->db->required = $minimumVersion; diff --git a/libraries/src/Updater/Updater.php b/libraries/src/Updater/Updater.php index 0a76d383a9d30..a493075e5caf6 100644 --- a/libraries/src/Updater/Updater.php +++ b/libraries/src/Updater/Updater.php @@ -284,7 +284,7 @@ private function getUpdateObjectsForSite($updateSite, $minimumStability = self:: $extraUpdates = $this->getUpdateObjectsForSite($extraUpdateSite, $minimumStability); - if (\count($extraUpdates)) { + if (\count($extraUpdates) !== 0) { $retVal = array_merge($retVal, $extraUpdates); } } diff --git a/libraries/src/Uri/Uri.php b/libraries/src/Uri/Uri.php index 265579ff0f7ca..d2b44efff6ac0 100644 --- a/libraries/src/Uri/Uri.php +++ b/libraries/src/Uri/Uri.php @@ -148,7 +148,7 @@ public static function base($pathonly = false) } else { static::$base['prefix'] = $uri->toString(['scheme', 'host', 'port']); - if (str_contains(PHP_SAPI, 'cgi') && !\ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) { + if (str_contains(PHP_SAPI, 'cgi') && (in_array(\ini_get('cgi.fix_pathinfo'), ['', '0'], true) || \ini_get('cgi.fix_pathinfo') === false) && !empty($_SERVER['REQUEST_URI'])) { // PHP-CGI on Apache with "cgi.fix_pathinfo = 0" // We shouldn't have user-supplied PATH_INFO in PHP_SELF in this case diff --git a/libraries/src/WebAsset/WebAssetManager.php b/libraries/src/WebAsset/WebAssetManager.php index 4240b51ebc164..31c3b907d5f44 100644 --- a/libraries/src/WebAsset/WebAssetManager.php +++ b/libraries/src/WebAsset/WebAssetManager.php @@ -378,7 +378,7 @@ protected function usePresetItems($name): WebAssetManagerInterface $depName = substr((string) $dependency, 0, $pos); } - $depType = $depType ?: 'preset'; + $depType = $depType !== '' && $depType !== '0' ? $depType : 'preset'; // Make sure dependency exists if (!$this->registry->exists($depType, $depName)) { @@ -421,7 +421,7 @@ protected function disablePresetItems($name): WebAssetManagerInterface $depName = substr((string) $dependency, 0, $pos); } - $depType = $depType ?: 'preset'; + $depType = $depType !== '' && $depType !== '0' ? $depType : 'preset'; // Make sure dependency exists if (!$this->registry->exists($depType, $depName)) { diff --git a/modules/mod_feed/tmpl/default.php b/modules/mod_feed/tmpl/default.php index cf10646c8868d..d65a12b3a6946 100644 --- a/modules/mod_feed/tmpl/default.php +++ b/modules/mod_feed/tmpl/default.php @@ -83,7 +83,7 @@ get('rssitems', 3)); $i < $max; $i++) { ?> uri || !$feed[$i]->isPermaLink ? trim($feed[$i]->uri) : trim($feed[$i]->guid); - $uri = !$uri || stripos($uri, 'http') !== 0 ? $rssurl : $uri; + $uri = $uri === '' || $uri === '0' || stripos($uri, 'http') !== 0 ? $rssurl : $uri; $text = $feed[$i]->content !== '' ? trim($feed[$i]->content) : ''; ?> diff --git a/modules/mod_menu/src/Helper/MenuHelper.php b/modules/mod_menu/src/Helper/MenuHelper.php index f5b791b991027..0ed621091390f 100644 --- a/modules/mod_menu/src/Helper/MenuHelper.php +++ b/modules/mod_menu/src/Helper/MenuHelper.php @@ -168,9 +168,9 @@ public static function getList(&$params) } if (isset($items[$lastitem])) { - $items[$lastitem]->deeper = (($start ?: 1) > $items[$lastitem]->level); - $items[$lastitem]->shallower = (($start ?: 1) < $items[$lastitem]->level); - $items[$lastitem]->level_diff = ($items[$lastitem]->level - ($start ?: 1)); + $items[$lastitem]->deeper = (($start !== 0 ? $start : 1) > $items[$lastitem]->level); + $items[$lastitem]->shallower = (($start !== 0 ? $start : 1) < $items[$lastitem]->level); + $items[$lastitem]->level_diff = ($items[$lastitem]->level - ($start !== 0 ? $start : 1)); } } diff --git a/modules/mod_tags_popular/src/Dispatcher/Dispatcher.php b/modules/mod_tags_popular/src/Dispatcher/Dispatcher.php index 72420e5baf888..357177ccd7cfa 100644 --- a/modules/mod_tags_popular/src/Dispatcher/Dispatcher.php +++ b/modules/mod_tags_popular/src/Dispatcher/Dispatcher.php @@ -39,7 +39,7 @@ public function dispatch() { $displayData = $this->getLayoutData(); - if (!\count($displayData['list']) && !$displayData['params']->get('no_results_text')) { + if (\count($displayData['list']) === 0 && !$displayData['params']->get('no_results_text')) { return; } diff --git a/plugins/actionlog/joomla/src/Extension/Joomla.php b/plugins/actionlog/joomla/src/Extension/Joomla.php index 065c34104ea34..6aef9b25beeb6 100644 --- a/plugins/actionlog/joomla/src/Extension/Joomla.php +++ b/plugins/actionlog/joomla/src/Extension/Joomla.php @@ -1101,7 +1101,7 @@ public function onAfterLogExport(): void */ public function onAfterPurge(AfterPurgeEvent $event): void { - $group = $event->getGroup() ?: 'all'; + $group = in_array($event->getGroup(), ['', '0'], true) ? 'all' : $event->getGroup(); $context = $this->getApplication()->getInput()->get('option'); $user = $this->getApplication()->getIdentity(); diff --git a/plugins/content/contact/src/Extension/Contact.php b/plugins/content/contact/src/Extension/Contact.php index 7ad9a153bee47..3b806e421a309 100644 --- a/plugins/content/contact/src/Extension/Contact.php +++ b/plugins/content/contact/src/Extension/Contact.php @@ -60,7 +60,7 @@ public function onContentPrepare($context, &$row, $params, $page = 0) } // Return if we don't have a valid article id - if (!isset($row->id) || !(int) $row->id) { + if (!isset($row->id) || (int) $row->id === 0) { return; } diff --git a/plugins/editors/codemirror/src/Provider/CodeMirrorProvider.php b/plugins/editors/codemirror/src/Provider/CodeMirrorProvider.php index 3ed3901915c37..12ab9a7e3df3d 100644 --- a/plugins/editors/codemirror/src/Provider/CodeMirrorProvider.php +++ b/plugins/editors/codemirror/src/Provider/CodeMirrorProvider.php @@ -121,7 +121,7 @@ public function display(string $name, string $content = '', array $attributes = foreach ($customExtensions as $item) { $methods = array_filter(array_map('trim', explode(',', $item->methods ?? ''))); - if (empty($item->module) || !$methods) { + if (empty($item->module) || $methods === []) { continue; } diff --git a/plugins/editors/tinymce/src/Field/TinymcebuilderField.php b/plugins/editors/tinymce/src/Field/TinymcebuilderField.php index 94b76f9b51253..4f8769fa0d0f4 100644 --- a/plugins/editors/tinymce/src/Field/TinymcebuilderField.php +++ b/plugins/editors/tinymce/src/Field/TinymcebuilderField.php @@ -121,7 +121,7 @@ protected function getLayoutData() * Set 0: for Administrator, Editor, Super Users (4,7,8) * Set 1: for Registered, Manager (2,6), all else are public */ - $formValues->access = $num ? ($num === 1 ? [2, 6] : []) : ([4, 7, 8]); + $formValues->access = $num !== 0 && ($num !== '' && $num !== '0') ? ($num === 1 ? [2, 6] : []) : ([4, 7, 8]); // Assign Public to the new Set, but only when it not in use already if ($formValues->access === [] && !\in_array(1, $groupsInUse)) { diff --git a/plugins/editors/tinymce/src/PluginTraits/ResolveFiles.php b/plugins/editors/tinymce/src/PluginTraits/ResolveFiles.php index 27df319989cd6..f292247a860d9 100644 --- a/plugins/editors/tinymce/src/PluginTraits/ResolveFiles.php +++ b/plugins/editors/tinymce/src/PluginTraits/ResolveFiles.php @@ -41,7 +41,7 @@ protected function includeRelativeFiles($folder, $file) $fallback = Uri::root(true) . '/media/system/css/editor' . (JDEBUG ? '' : '.min') . '.css'; $template = $this->getActiveSiteTemplate(); - if (!(array) $template) { + if ((array) $template === []) { return $fallback; } diff --git a/plugins/extension/joomla/src/Extension/Joomla.php b/plugins/extension/joomla/src/Extension/Joomla.php index 99a8fd08621f6..cfbce0eeee1f8 100644 --- a/plugins/extension/joomla/src/Extension/Joomla.php +++ b/plugins/extension/joomla/src/Extension/Joomla.php @@ -295,7 +295,7 @@ private function processUpdateSites() $children = $updateservers ? $updateservers->children() : []; - if (\count($children)) { + if (\count($children) !== 0) { foreach ($children as $child) { $attrs = $child->attributes(); $this->addUpdateSite((string) $attrs['name'], (string) $attrs['type'], trim($child), true, $this->installer->extraQuery); diff --git a/plugins/multifactorauth/webauthn/src/CredentialRepository.php b/plugins/multifactorauth/webauthn/src/CredentialRepository.php index 5e078dc86050b..6713936db4e4f 100644 --- a/plugins/multifactorauth/webauthn/src/CredentialRepository.php +++ b/plugins/multifactorauth/webauthn/src/CredentialRepository.php @@ -221,7 +221,7 @@ public function saveCredentialSource(PublicKeyCredentialSource $publicKeyCredent /** @var MfaTable $mfaTable */ $mfaTable = $factory->createTable('Mfa', 'Administrator'); - if ($recordId) { + if ($recordId !== 0 && ($recordId !== '' && $recordId !== '0')) { $mfaTable->load($recordId); $options = $mfaTable->options; diff --git a/plugins/privacy/contact/src/Extension/Contact.php b/plugins/privacy/contact/src/Extension/Contact.php index e0b4dd38850d2..fef8e6b4c38f0 100644 --- a/plugins/privacy/contact/src/Extension/Contact.php +++ b/plugins/privacy/contact/src/Extension/Contact.php @@ -43,7 +43,7 @@ final class Contact extends PrivacyPlugin */ public function onPrivacyExportRequest(RequestTable $request, ?User $user = null) { - if (!$user && !$request->email) { + if (!$user instanceof User && !$request->email) { return []; } diff --git a/plugins/schemaorg/custom/src/Extension/Custom.php b/plugins/schemaorg/custom/src/Extension/Custom.php index dc81d232d3dcc..c209034303abe 100644 --- a/plugins/schemaorg/custom/src/Extension/Custom.php +++ b/plugins/schemaorg/custom/src/Extension/Custom.php @@ -81,7 +81,7 @@ public function onSchemaPrepareSave(PrepareSaveEvent $event): void return; } - if (!isset($json['@context']) || !preg_match('#^https://schema.org/?$#', (string) $json['@context']) || !isset($json['@type'])) { + if (!isset($json['@context']) || in_array(preg_match('#^https://schema.org/?$#', (string) $json['@context']), [0, false], true) || !isset($json['@type'])) { $this->getApplication()->enqueueMessage(Text::_('PLG_SCHEMAORG_CUSTOM_JSON_ERROR'), 'error'); return; } diff --git a/plugins/system/debug/src/DataCollector/LanguageErrorsCollector.php b/plugins/system/debug/src/DataCollector/LanguageErrorsCollector.php index 3f3a1977d1b3a..959e67af449dc 100644 --- a/plugins/system/debug/src/DataCollector/LanguageErrorsCollector.php +++ b/plugins/system/debug/src/DataCollector/LanguageErrorsCollector.php @@ -127,7 +127,7 @@ private function getData(): array $errorFiles = Factory::getLanguage()->getErrorFiles(); $errors = []; - if (\count($errorFiles)) { + if (\count($errorFiles) !== 0) { foreach ($errorFiles as $file => $lines) { foreach ($lines as $line) { $errors[] = [$file, $line]; diff --git a/plugins/system/debug/src/DataCollector/LanguageStringsCollector.php b/plugins/system/debug/src/DataCollector/LanguageStringsCollector.php index 7f01fd56df4e8..c4b677a96fbe1 100644 --- a/plugins/system/debug/src/DataCollector/LanguageStringsCollector.php +++ b/plugins/system/debug/src/DataCollector/LanguageStringsCollector.php @@ -144,7 +144,7 @@ private function getData(): array $isCaller = 0; - if (!$callerLocation && $class !== Language::class && !strpos((string) $file, 'Text.php')) { + if (($callerLocation === '' || $callerLocation === '0') && $class !== Language::class && in_array(strpos((string) $file, 'Text.php'), [0, false], true)) { $callerLocation = $location; $isCaller = 1; } diff --git a/plugins/system/debug/src/DataCollector/RequestDataCollector.php b/plugins/system/debug/src/DataCollector/RequestDataCollector.php index 038777e7ffd58..c51ba3fe019ed 100644 --- a/plugins/system/debug/src/DataCollector/RequestDataCollector.php +++ b/plugins/system/debug/src/DataCollector/RequestDataCollector.php @@ -47,7 +47,7 @@ public function collect() } array_walk_recursive($data, static function (&$value, $key) { - if (!preg_match(Debug::PROTECTED_COLLECTOR_KEYS, (string) $key)) { + if (in_array(preg_match(Debug::PROTECTED_COLLECTOR_KEYS, (string) $key), [0, false], true)) { return; } diff --git a/plugins/system/debug/src/DataCollector/SessionCollector.php b/plugins/system/debug/src/DataCollector/SessionCollector.php index 24c92fcab4dc8..f03091cb79244 100644 --- a/plugins/system/debug/src/DataCollector/SessionCollector.php +++ b/plugins/system/debug/src/DataCollector/SessionCollector.php @@ -76,7 +76,7 @@ public function collect($overwrite = false) // redact value of potentially secret keys array_walk_recursive($data, static function (&$value, $key) { - if (!preg_match(Debug::PROTECTED_COLLECTOR_KEYS, $key)) { + if (in_array(preg_match(Debug::PROTECTED_COLLECTOR_KEYS, $key), [0, false], true)) { return; } diff --git a/plugins/system/debug/src/Extension/Debug.php b/plugins/system/debug/src/Extension/Debug.php index fd64b47b36e50..58f49d10b9728 100644 --- a/plugins/system/debug/src/Extension/Debug.php +++ b/plugins/system/debug/src/Extension/Debug.php @@ -417,7 +417,7 @@ private function isAuthorisedDisplayDebug(): bool if ($filterGroups !== []) { $userGroups = $this->getApplication()->getIdentity()->get('groups'); - if (!array_intersect($filterGroups, $userGroups)) { + if (array_intersect($filterGroups, $userGroups) === []) { $result = false; return false; diff --git a/plugins/system/fields/src/Extension/Fields.php b/plugins/system/fields/src/Extension/Fields.php index 08841e1e9d3d1..0079a64bd7f4e 100644 --- a/plugins/system/fields/src/Extension/Fields.php +++ b/plugins/system/fields/src/Extension/Fields.php @@ -145,7 +145,7 @@ public function onContentAfterSave($context, $item, $isNew, $data = []): void } // If no value set (empty) remove value from database - if (\is_array($value) ? $value === [] : !\strlen($value)) { + if (\is_array($value) ? $value === [] : (string) $value === '') { $value = null; } diff --git a/plugins/system/httpheaders/src/Extension/Httpheaders.php b/plugins/system/httpheaders/src/Extension/Httpheaders.php index a08b15b615593..d6f3b2d81e462 100644 --- a/plugins/system/httpheaders/src/Extension/Httpheaders.php +++ b/plugins/system/httpheaders/src/Extension/Httpheaders.php @@ -177,7 +177,7 @@ public function applyHashesToCspRule(Event $event): void $styleHashesEnabled = (int) $this->params->get('style_hashes_enabled', 0); // Early exit when both options are disabled - if (!$scriptHashesEnabled && !$styleHashesEnabled) { + if ($scriptHashesEnabled === 0 && $styleHashesEnabled === 0) { return; } diff --git a/plugins/system/jooa11y/src/Extension/Jooa11y.php b/plugins/system/jooa11y/src/Extension/Jooa11y.php index fd6b8c93fdec6..2140dd8e1a3dd 100644 --- a/plugins/system/jooa11y/src/Extension/Jooa11y.php +++ b/plugins/system/jooa11y/src/Extension/Jooa11y.php @@ -62,7 +62,7 @@ private function isAuthorisedDisplayChecker(): bool ->getIdentity() ->get('groups'); - if (!array_intersect($filterGroups, $userGroups)) { + if (array_intersect($filterGroups, $userGroups) === []) { $result = false; return $result; } diff --git a/plugins/system/languagefilter/src/Extension/LanguageFilter.php b/plugins/system/languagefilter/src/Extension/LanguageFilter.php index 703f60be040df..6a9363b412f91 100644 --- a/plugins/system/languagefilter/src/Extension/LanguageFilter.php +++ b/plugins/system/languagefilter/src/Extension/LanguageFilter.php @@ -155,7 +155,7 @@ public function __construct( } } - if (!\count($this->sefs)) { + if (\count($this->sefs) === 0) { $this->loadLanguage(); $app->enqueueMessage(Text::_('PLG_SYSTEM_LANGUAGEFILTER_ERROR_NO_CONTENT_LANGUAGE'), 'error'); } diff --git a/plugins/system/schedulerunner/src/Extension/ScheduleRunner.php b/plugins/system/schedulerunner/src/Extension/ScheduleRunner.php index de268fb736754..7c42ea93b1435 100644 --- a/plugins/system/schedulerunner/src/Extension/ScheduleRunner.php +++ b/plugins/system/schedulerunner/src/Extension/ScheduleRunner.php @@ -199,7 +199,7 @@ public function runWebCron(Event $event) throw new \Exception($this->getApplication()->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403); } - if (!\strlen((string) $hash) || $hash !== $this->getApplication()->getInput()->get('hash')) { + if ((string) $hash === '' || $hash !== $this->getApplication()->getInput()->get('hash')) { throw new \Exception($this->getApplication()->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403); } diff --git a/plugins/system/sef/src/Extension/Sef.php b/plugins/system/sef/src/Extension/Sef.php index bf916ac500b7e..487de04710ffd 100644 --- a/plugins/system/sef/src/Extension/Sef.php +++ b/plugins/system/sef/src/Extension/Sef.php @@ -450,7 +450,7 @@ private function enforceSEF() $app = $this->getApplication(); $origUri = clone Uri::getInstance(); - if (\count($origUri->getQuery(true))) { + if (\count($origUri->getQuery(true)) !== 0) { $parsedVars = $app->getInput()->getArray(); if ($app->getLanguageFilter()) { @@ -462,7 +462,7 @@ private function enforceSEF() $newRoute = Route::_($parsedVars, false); $newUri = new Uri($newRoute); - if (!\count($newUri->getQuery(true)) && $route !== $newRoute) { + if (\count($newUri->getQuery(true)) === 0 && $route !== $newRoute) { $app->redirect($newRoute, 301); } } diff --git a/plugins/system/stats/layouts/field/data.php b/plugins/system/stats/layouts/field/data.php index 8b3cc6af01bb2..fc06344453ade 100644 --- a/plugins/system/stats/layouts/field/data.php +++ b/plugins/system/stats/layouts/field/data.php @@ -49,7 +49,7 @@ * @var array $statsData Statistics that will be sent to the stats server */ ?> - + render('stats', ['statsData' => $statsData]); ?> diff --git a/plugins/system/stats/src/Extension/Stats.php b/plugins/system/stats/src/Extension/Stats.php index ce8486ac98283..eff83cedc23aa 100644 --- a/plugins/system/stats/src/Extension/Stats.php +++ b/plugins/system/stats/src/Extension/Stats.php @@ -390,7 +390,7 @@ private function isUpdateRequired() } // Never updated or debug enabled - if (!$last || $this->isDebugEnabled()) { + if ($last === 0 || $this->isDebugEnabled()) { return true; } @@ -440,7 +440,7 @@ private function saveParams() $this->params->set('unique_id', $this->getUniqueId()); $interval = (int) $this->params->get('interval', 12); - $this->params->set('interval', $interval ?: 12); + $this->params->set('interval', $interval !== 0 ? $interval : 12); $paramsJson = $this->params->toString('JSON'); $db = $this->getDatabase(); diff --git a/plugins/system/webauthn/src/MetadataRepository.php b/plugins/system/webauthn/src/MetadataRepository.php index 6f523825846f3..8e6899f455cbc 100644 --- a/plugins/system/webauthn/src/MetadataRepository.php +++ b/plugins/system/webauthn/src/MetadataRepository.php @@ -82,13 +82,13 @@ public function getKnownAuthenticators(): array $this->load(); $mapKeys = (fn(MetadataStatement $meta) => $meta->getAaguid()); - $mapvalues = (fn(MetadataStatement $meta) => $meta->getAaguid() ? (object) [ + $mapvalues = (fn(MetadataStatement $meta) => in_array($meta->getAaguid(), [null, '', '0'], true) ? null : (object) [ 'description' => $meta->getDescription(), 'icon' => $meta->getIcon(), - ] : null); + ]); $keys = array_map($mapKeys, $this->mdsCache); $values = array_map($mapvalues, $this->mdsCache); - $return = array_combine($keys, $values) ?: []; + $return = array_combine($keys, $values); $filter = (fn($x) => !empty($x)); diff --git a/plugins/user/joomla/src/Extension/Joomla.php b/plugins/user/joomla/src/Extension/Joomla.php index d89da9d8af778..18a5d6a4df277 100644 --- a/plugins/user/joomla/src/Extension/Joomla.php +++ b/plugins/user/joomla/src/Extension/Joomla.php @@ -442,9 +442,9 @@ private function disableMfaOnSilentLogin(array $options): void $silentResponseTypes = array_map( 'trim', - explode(',', (string) $userParams->get('silentresponses', '') ?: '') + explode(',', (string) $userParams->get('silentresponses', '') !== '' && (string) $userParams->get('silentresponses', '') !== '0' ? (string) $userParams->get('silentresponses', '') : '') ); - $silentResponseTypes = $silentResponseTypes ?: ['cookie', 'passwordless']; + $silentResponseTypes = $silentResponseTypes !== [] ? $silentResponseTypes : ['cookie', 'passwordless']; // Only proceed if this is not a silent login if (!\in_array(strtolower($options['responseType'] ?? ''), $silentResponseTypes)) { diff --git a/plugins/user/profile/src/Extension/Profile.php b/plugins/user/profile/src/Extension/Profile.php index c65cb24685807..dff98a3ead123 100644 --- a/plugins/user/profile/src/Extension/Profile.php +++ b/plugins/user/profile/src/Extension/Profile.php @@ -278,7 +278,7 @@ public function onContentPrepareForm(Form $form, $data) // Drop the profile form entirely if there aren't any fields to display. $remainingfields = $form->getGroup('profile'); - if (!\count($remainingfields)) { + if (\count($remainingfields) === 0) { $form->removeGroup('profile'); } diff --git a/tests/Integration/DBTestHelper.php b/tests/Integration/DBTestHelper.php index c0c327115b536..154e3717991cc 100644 --- a/tests/Integration/DBTestHelper.php +++ b/tests/Integration/DBTestHelper.php @@ -70,7 +70,7 @@ public static function setupTest(IntegrationTestCase $test): void $sql = file_get_contents(JPATH_ROOT . '/tests/Integration/datasets/' . strtolower(JTEST_DB_ENGINE) . '/' . $file); $queries = self::splitQueries($sql); - if (!\count($queries)) { + if (\count($queries) === 0) { continue; } @@ -113,7 +113,7 @@ protected static function splitQueries($query) // Parse the schema file to break up queries. for ($i = 0; $i < \strlen($query) - 1; $i++) { - if ($query[$i] === ';' && !$in_string) { + if ($query[$i] === ';' && ($in_string === false || ($in_string === '' || $in_string === '0'))) { $queries[] = substr($query, 0, $i); $query = substr($query, $i + 1); $i = 0; @@ -121,7 +121,7 @@ protected static function splitQueries($query) if ($in_string && ($query[$i] === $in_string) && $buffer[1] !== "\\") { $in_string = false; - } elseif (!$in_string && ($query[$i] === '"' || $query[$i] === "'") && (!isset($buffer[0]) || $buffer[0] !== "\\")) { + } elseif (($in_string === false || ($in_string === '' || $in_string === '0')) && ($query[$i] === '"' || $query[$i] === "'") && (!isset($buffer[0]) || $buffer[0] !== "\\")) { $in_string = $query[$i]; }