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('#(.*?)#', $buffer, $m)) { + if (in_array(preg_match('#(.*?)#', $buffer, $m), [0, false], true)) { continue; } diff --git a/administrator/components/com_associations/src/Field/Modal/AssociationField.php b/administrator/components/com_associations/src/Field/Modal/AssociationField.php index e68292c596f38..b74acba3e151c 100644 --- a/administrator/components/com_associations/src/Field/Modal/AssociationField.php +++ b/administrator/components/com_associations/src/Field/Modal/AssociationField.php @@ -46,7 +46,7 @@ protected function getInput() { // @todo USE Layouts here!!! // The active item id field. - $value = (int) $this->value ?: ''; + $value = (int) $this->value !== 0 ? (int) $this->value : ''; $doc = Factory::getApplication()->getDocument(); $wa = $doc->getWebAssetManager(); @@ -68,7 +68,7 @@ protected function getInput() $html[] = '' . ' ' . Text::_('JCLEAR') diff --git a/administrator/components/com_associations/src/Model/AssociationsModel.php b/administrator/components/com_associations/src/Model/AssociationsModel.php index c29192e454680..f203bd69489fc 100644 --- a/administrator/components/com_associations/src/Model/AssociationsModel.php +++ b/administrator/components/com_associations/src/Model/AssociationsModel.php @@ -359,7 +359,7 @@ protected function getListQuery() if ($typeName === 'category') { $query->where($db->quoteName('a.extension') . ' = :extensionname') ->bind(':extensionname', $extensionName); - } elseif ($typeNameExploded = explode('.', $typeName)) { + } elseif ($typeNameExploded = explode('.', $typeName) !== []) { if (\count($typeNameExploded) > 1 && array_pop($typeNameExploded) === 'category') { $section = implode('.', $typeNameExploded); $extensionNameSection = $extensionName . '.' . $section; diff --git a/administrator/components/com_associations/src/View/Association/HtmlView.php b/administrator/components/com_associations/src/View/Association/HtmlView.php index d34065cb50802..5d0c44ab0fa60 100644 --- a/administrator/components/com_associations/src/View/Association/HtmlView.php +++ b/administrator/components/com_associations/src/View/Association/HtmlView.php @@ -225,7 +225,7 @@ public function display($tpl = null): void $model = $this->getModel(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_associations/src/View/Associations/HtmlView.php b/administrator/components/com_associations/src/View/Associations/HtmlView.php index 84a43527dbe55..bb6b38a134b08 100644 --- a/administrator/components/com_associations/src/View/Associations/HtmlView.php +++ b/administrator/components/com_associations/src/View/Associations/HtmlView.php @@ -234,7 +234,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new \Exception(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/Controller/DisplayController.php b/administrator/components/com_banners/src/Controller/DisplayController.php index fe11bc9a1bc68..3fc824fb71a08 100644 --- a/administrator/components/com_banners/src/Controller/DisplayController.php +++ b/administrator/components/com_banners/src/Controller/DisplayController.php @@ -56,7 +56,7 @@ public function display($cachable = false, $urlparams = []) // Check for edit form. if ($view === 'banner' && $layout === 'edit' && !$this->checkEditId('com_banners.edit.banner', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } @@ -67,7 +67,7 @@ public function display($cachable = false, $urlparams = []) if ($view === 'client' && $layout === 'edit' && !$this->checkEditId('com_banners.edit.client', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_banners/src/View/Banner/HtmlView.php b/administrator/components/com_banners/src/View/Banner/HtmlView.php index b36a6087f5b82..ef8e1a8a364d0 100644 --- a/administrator/components/com_banners/src/View/Banner/HtmlView.php +++ b/administrator/components/com_banners/src/View/Banner/HtmlView.php @@ -76,7 +76,7 @@ public function display($tpl = null): void $this->state = $model->getState(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/View/Banners/HtmlView.php b/administrator/components/com_banners/src/View/Banners/HtmlView.php index dced0e0e68bcd..c346cb5214418 100644 --- a/administrator/components/com_banners/src/View/Banners/HtmlView.php +++ b/administrator/components/com_banners/src/View/Banners/HtmlView.php @@ -110,12 +110,12 @@ public function display($tpl = null): void $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/View/Client/HtmlView.php b/administrator/components/com_banners/src/View/Client/HtmlView.php index 05a5cb7a5740d..78b7f0a507fe7 100644 --- a/administrator/components/com_banners/src/View/Client/HtmlView.php +++ b/administrator/components/com_banners/src/View/Client/HtmlView.php @@ -86,7 +86,7 @@ public function display($tpl = null): void $this->canDo = ContentHelper::getActions('com_banners'); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/View/Clients/HtmlView.php b/administrator/components/com_banners/src/View/Clients/HtmlView.php index ccfd552f42f37..7387fad0d3f0e 100644 --- a/administrator/components/com_banners/src/View/Clients/HtmlView.php +++ b/administrator/components/com_banners/src/View/Clients/HtmlView.php @@ -100,12 +100,12 @@ public function display($tpl = null): void $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/View/Download/HtmlView.php b/administrator/components/com_banners/src/View/Download/HtmlView.php index a9bf5b198bd2b..09427ea70cafe 100644 --- a/administrator/components/com_banners/src/View/Download/HtmlView.php +++ b/administrator/components/com_banners/src/View/Download/HtmlView.php @@ -52,7 +52,7 @@ public function display($tpl = null): void $this->form = $model->getForm(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/View/Tracks/HtmlView.php b/administrator/components/com_banners/src/View/Tracks/HtmlView.php index 4e843879b38b4..3cd16a9ab3ce4 100644 --- a/administrator/components/com_banners/src/View/Tracks/HtmlView.php +++ b/administrator/components/com_banners/src/View/Tracks/HtmlView.php @@ -100,12 +100,12 @@ public function display($tpl = null): void $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_banners/src/View/Tracks/RawView.php b/administrator/components/com_banners/src/View/Tracks/RawView.php index ff7652ac2f78a..d5570d83ef48f 100644 --- a/administrator/components/com_banners/src/View/Tracks/RawView.php +++ b/administrator/components/com_banners/src/View/Tracks/RawView.php @@ -48,7 +48,7 @@ public function display($tpl = null): void $content = $model->getContent(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_cache/src/View/Cache/HtmlView.php b/administrator/components/com_cache/src/View/Cache/HtmlView.php index b5b8947a06c1d..121be7844f9c4 100644 --- a/administrator/components/com_cache/src/View/Cache/HtmlView.php +++ b/administrator/components/com_cache/src/View/Cache/HtmlView.php @@ -101,11 +101,11 @@ public function display($tpl = null): void $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } - if (!\count($this->data) && ($this->state->get('filter.search') === null || $this->state->get('filter.search') === '')) { + if (\count($this->data) === 0 && ($this->state->get('filter.search') === null || $this->state->get('filter.search') === '')) { $this->setLayout('emptystate'); } @@ -128,7 +128,7 @@ protected function addToolbar(): void // Get the toolbar object instance $toolbar = $this->getDocument()->getToolbar(); - if (\count($this->data)) { + if (\count($this->data) !== 0) { $toolbar->delete('delete') ->listCheck(true); diff --git a/administrator/components/com_categories/src/Controller/DisplayController.php b/administrator/components/com_categories/src/Controller/DisplayController.php index 41e6790a2dfa6..27ff100823a96 100644 --- a/administrator/components/com_categories/src/Controller/DisplayController.php +++ b/administrator/components/com_categories/src/Controller/DisplayController.php @@ -89,7 +89,7 @@ public function display($cachable = false, $urlparams = []) // Check for edit form. if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_categories/src/Field/ComponentsCategoryField.php b/administrator/components/com_categories/src/Field/ComponentsCategoryField.php index 88dcc3257687f..45c2889e383f3 100644 --- a/administrator/components/com_categories/src/Field/ComponentsCategoryField.php +++ b/administrator/components/com_categories/src/Field/ComponentsCategoryField.php @@ -71,7 +71,7 @@ protected function getOptions() } // If the component section string exists, let's use it - if ($lang->hasKey($component_section_key = strtoupper($component . ($section ? '_' . $section : '')))) { + if ($lang->hasKey($component_section_key = strtoupper($component . ($section !== null && $section !== '' && $section !== '0' ? '_' . $section : '')))) { $option->text = Text::_($component_section_key); } else { // Else use the component title $option->text = Text::_(strtoupper($component)); diff --git a/administrator/components/com_categories/src/Field/Modal/CategoryField.php b/administrator/components/com_categories/src/Field/Modal/CategoryField.php index ee29d8c312cec..a96d381500859 100644 --- a/administrator/components/com_categories/src/Field/Modal/CategoryField.php +++ b/administrator/components/com_categories/src/Field/Modal/CategoryField.php @@ -141,23 +141,21 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) */ protected function getValueTitle() { - $value = (int) $this->value ?: ''; + $value = (int) $this->value !== 0 ? (int) $this->value : ''; $title = ''; - if ($value) { - try { - $db = $this->getDatabase(); - $query = $db->getQuery(true) - ->select($db->quoteName('title')) - ->from($db->quoteName('#__categories')) - ->where($db->quoteName('id') . ' = :value') - ->bind(':value', $value, ParameterType::INTEGER); - $db->setQuery($query); - - $title = $db->loadResult(); - } catch (\Throwable $e) { - Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); - } + try { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select($db->quoteName('title')) + ->from($db->quoteName('#__categories')) + ->where($db->quoteName('id') . ' = :value') + ->bind(':value', $value, ParameterType::INTEGER); + $db->setQuery($query); + + $title = $db->loadResult(); + } catch (\Throwable $throwable) { + Factory::getApplication()->enqueueMessage($throwable->getMessage(), 'error'); } return $title ?: $value; diff --git a/administrator/components/com_categories/src/Model/CategoriesModel.php b/administrator/components/com_categories/src/Model/CategoriesModel.php index 895f67435e3b3..f08d51e1a2246 100644 --- a/administrator/components/com_categories/src/Model/CategoriesModel.php +++ b/administrator/components/com_categories/src/Model/CategoriesModel.php @@ -422,7 +422,7 @@ public function getAssoc() $component = array_shift($extension); $cname = str_replace('com_', '', $component); - if (!$this->hasAssociation || !$component || !$cname) { + if (!$this->hasAssociation || !$component || ($cname === '' || $cname === '0' || $cname === [])) { $this->hasAssociation = false; return $this->hasAssociation; diff --git a/administrator/components/com_categories/src/Model/CategoryModel.php b/administrator/components/com_categories/src/Model/CategoryModel.php index 1e75ac44c53af..5dfbdba509bc3 100644 --- a/administrator/components/com_categories/src/Model/CategoryModel.php +++ b/administrator/components/com_categories/src/Model/CategoryModel.php @@ -1285,7 +1285,7 @@ public function getAssoc() $component = array_shift($extension); $cname = str_replace('com_', '', $component); - if (!$this->hasAssociation || !$component || !$cname) { + if (!$this->hasAssociation || !$component || ($cname === '' || $cname === '0' || $cname === [])) { $this->hasAssociation = false; return $this->hasAssociation; diff --git a/administrator/components/com_categories/src/View/Categories/HtmlView.php b/administrator/components/com_categories/src/View/Categories/HtmlView.php index 87644d4342f9f..85e566da5ec45 100644 --- a/administrator/components/com_categories/src/View/Categories/HtmlView.php +++ b/administrator/components/com_categories/src/View/Categories/HtmlView.php @@ -116,12 +116,12 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Written this way because we only want to call IsEmptyState if no items, to prevent always calling it when not needed. - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_categories/src/View/Category/HtmlView.php b/administrator/components/com_categories/src/View/Category/HtmlView.php index 46e23f8c4930d..9ff686a6d5af1 100644 --- a/administrator/components/com_categories/src/View/Category/HtmlView.php +++ b/administrator/components/com_categories/src/View/Category/HtmlView.php @@ -115,7 +115,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } @@ -196,9 +196,9 @@ protected function addToolbar() $canDo = $this->canDo; // If a component categories title string is present, let's use it. - if ($lang->hasKey($component_title_key = $component . ($section ? '_' . $section : '') . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE')) { + if ($lang->hasKey($component_title_key = $component . ($section !== null && $section !== '' && $section !== '0' ? '_' . $section : '') . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE')) { $title = Text::_($component_title_key); - } elseif ($lang->hasKey($component_section_key = $component . ($section ? '_' . $section : ''))) { + } elseif ($lang->hasKey($component_section_key = $component . ($section !== null && $section !== '' && $section !== '0' ? '_' . $section : ''))) { // Else if the component section string exists, let's use it. $title = Text::sprintf('COM_CATEGORIES_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE', $this->escape(Text::_($component_section_key))); @@ -222,7 +222,7 @@ protected function addToolbar() ToolbarHelper::title( $title, 'folder category-' . ($isNew ? 'add' : 'edit') - . ' ' . substr($component, 4) . ($section ? '-' . $section : '') . '-category-' . ($isNew ? 'add' : 'edit') + . ' ' . substr($component, 4) . ($section !== null && $section !== '' && $section !== '0' ? '-' . $section : '') . '-category-' . ($isNew ? 'add' : 'edit') ); if ($isNew) { @@ -303,13 +303,13 @@ function (Toolbar $childBar) use ($checkedOut, $canDo, $itemEditable, $component // Try with a language string if ($ref_key === '' || $ref_key === '0') { // Compute the ref_key if it does exist in the component - $languageKey = strtoupper($component . ($section ? '_' . $section : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_HELP_KEY'; + $languageKey = strtoupper($component . ($section !== null && $section !== '' && $section !== '0' ? '_' . $section : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_HELP_KEY'; if ($lang->hasKey($languageKey)) { $ref_key = $languageKey; } else { $languageKey = 'JHELP_COMPONENTS_' - . strtoupper(substr($component, 4) . ($section ? '_' . $section : '')) + . strtoupper(substr($component, 4) . ($section !== null && $section !== '' && $section !== '0' ? '_' . $section : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT'); if ($lang->hasKey($languageKey)) { diff --git a/administrator/components/com_checkin/src/View/Checkin/HtmlView.php b/administrator/components/com_checkin/src/View/Checkin/HtmlView.php index 8afa86b24818f..8002ff0371cb3 100644 --- a/administrator/components/com_checkin/src/View/Checkin/HtmlView.php +++ b/administrator/components/com_checkin/src/View/Checkin/HtmlView.php @@ -104,13 +104,13 @@ public function display($tpl = null) $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items)) { + if (\count($this->items) === 0) { $this->isEmptyState = true; $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_config/src/View/Component/HtmlView.php b/administrator/components/com_config/src/View/Component/HtmlView.php index 01aaf7156ccb1..36c89978e009c 100644 --- a/administrator/components/com_config/src/View/Component/HtmlView.php +++ b/administrator/components/com_config/src/View/Component/HtmlView.php @@ -160,7 +160,7 @@ protected function addToolbar() $toolbar->divider(); $inlinehelp = (string) $this->form->getXml()->config->inlinehelp['button'] === 'show'; - $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] ?: 'hide-aware-inline-help'; + $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] !== '' && (string) $this->form->getXml()->config->inlinehelp['targetclass'] !== '0' ? (string) $this->form->getXml()->config->inlinehelp['targetclass'] : 'hide-aware-inline-help'; if ($inlinehelp) { $toolbar->inlinehelp($targetClass); diff --git a/administrator/components/com_contact/src/Controller/DisplayController.php b/administrator/components/com_contact/src/Controller/DisplayController.php index 0b78a94eab855..014f89f9d0cf7 100644 --- a/administrator/components/com_contact/src/Controller/DisplayController.php +++ b/administrator/components/com_contact/src/Controller/DisplayController.php @@ -53,7 +53,7 @@ public function display($cachable = false, $urlparams = []) // Check for edit form. if ($view == 'contact' && $layout == 'edit' && !$this->checkEditId('com_contact.edit.contact', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_contact/src/Field/Modal/ContactField.php b/administrator/components/com_contact/src/Field/Modal/ContactField.php index 6c2100f37d520..1bfec8d4ad313 100644 --- a/administrator/components/com_contact/src/Field/Modal/ContactField.php +++ b/administrator/components/com_contact/src/Field/Modal/ContactField.php @@ -134,23 +134,21 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) */ protected function getValueTitle() { - $value = (int) $this->value ?: ''; + $value = (int) $this->value !== 0 ? (int) $this->value : ''; $title = ''; - if ($value) { - try { - $db = $this->getDatabase(); - $query = $db->getQuery(true) - ->select($db->quoteName('name')) - ->from($db->quoteName('#__contact_details')) - ->where($db->quoteName('id') . ' = :value') - ->bind(':value', $value, ParameterType::INTEGER); - $db->setQuery($query); - - $title = $db->loadResult(); - } catch (\Throwable $e) { - Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); - } + try { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select($db->quoteName('name')) + ->from($db->quoteName('#__contact_details')) + ->where($db->quoteName('id') . ' = :value') + ->bind(':value', $value, ParameterType::INTEGER); + $db->setQuery($query); + + $title = $db->loadResult(); + } catch (\Throwable $throwable) { + Factory::getApplication()->enqueueMessage($throwable->getMessage(), 'error'); } return $title ?: $value; diff --git a/administrator/components/com_contact/src/View/Contact/HtmlView.php b/administrator/components/com_contact/src/View/Contact/HtmlView.php index 19b066b231574..3811e27c98bb8 100644 --- a/administrator/components/com_contact/src/View/Contact/HtmlView.php +++ b/administrator/components/com_contact/src/View/Contact/HtmlView.php @@ -88,7 +88,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_contact/src/View/Contacts/HtmlView.php b/administrator/components/com_contact/src/View/Contacts/HtmlView.php index 3c4feb882e4a2..0fa9e563294a2 100644 --- a/administrator/components/com_contact/src/View/Contacts/HtmlView.php +++ b/administrator/components/com_contact/src/View/Contacts/HtmlView.php @@ -96,12 +96,12 @@ public function display($tpl = null) $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_content/src/Controller/DisplayController.php b/administrator/components/com_content/src/Controller/DisplayController.php index 158c8f3a17ce3..41d2ad7b53343 100644 --- a/administrator/components/com_content/src/Controller/DisplayController.php +++ b/administrator/components/com_content/src/Controller/DisplayController.php @@ -53,7 +53,7 @@ public function display($cachable = false, $urlparams = []) // Check for edit form. if ($view == 'article' && $layout == 'edit' && !$this->checkEditId('com_content.edit.article', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_content/src/Field/Modal/ArticleField.php b/administrator/components/com_content/src/Field/Modal/ArticleField.php index 01b8df4ca86aa..cec0d1dee1a00 100644 --- a/administrator/components/com_content/src/Field/Modal/ArticleField.php +++ b/administrator/components/com_content/src/Field/Modal/ArticleField.php @@ -134,23 +134,21 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) */ protected function getValueTitle() { - $value = (int) $this->value ?: ''; + $value = (int) $this->value !== 0 ? (int) $this->value : ''; $title = ''; - if ($value) { - try { - $db = $this->getDatabase(); - $query = $db->getQuery(true) - ->select($db->quoteName('title')) - ->from($db->quoteName('#__content')) - ->where($db->quoteName('id') . ' = :value') - ->bind(':value', $value, ParameterType::INTEGER); - $db->setQuery($query); - - $title = $db->loadResult(); - } catch (\Throwable $e) { - Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); - } + try { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select($db->quoteName('title')) + ->from($db->quoteName('#__content')) + ->where($db->quoteName('id') . ' = :value') + ->bind(':value', $value, ParameterType::INTEGER); + $db->setQuery($query); + + $title = $db->loadResult(); + } catch (\Throwable $throwable) { + Factory::getApplication()->enqueueMessage($throwable->getMessage(), 'error'); } return $title ?: $value; diff --git a/administrator/components/com_content/src/View/Article/HtmlView.php b/administrator/components/com_content/src/View/Article/HtmlView.php index 49e0cad451f74..afb7d8d68a013 100644 --- a/administrator/components/com_content/src/View/Article/HtmlView.php +++ b/administrator/components/com_content/src/View/Article/HtmlView.php @@ -115,7 +115,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_content/src/View/Articles/HtmlView.php b/administrator/components/com_content/src/View/Articles/HtmlView.php index be808ff8b04ba..357dd2985168b 100644 --- a/administrator/components/com_content/src/View/Articles/HtmlView.php +++ b/administrator/components/com_content/src/View/Articles/HtmlView.php @@ -123,7 +123,7 @@ public function display($tpl = null) $this->vote = PluginHelper::isEnabled('content', 'vote'); $this->hits = ComponentHelper::getParams('com_content')->get('record_hits', 1) == 1; - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } diff --git a/administrator/components/com_content/src/View/Featured/HtmlView.php b/administrator/components/com_content/src/View/Featured/HtmlView.php index 0a8c8c330ac50..c853abc6882c0 100644 --- a/administrator/components/com_content/src/View/Featured/HtmlView.php +++ b/administrator/components/com_content/src/View/Featured/HtmlView.php @@ -111,7 +111,7 @@ public function display($tpl = null) $this->vote = PluginHelper::isEnabled('content', 'vote'); $this->hits = ComponentHelper::getParams('com_content')->get('record_hits', 1); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } @@ -122,7 +122,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } @@ -166,7 +166,7 @@ protected function addToolbar() $childBar = $dropdown->getChildToolbar(); - if (\count($this->transitions)) { + if (\count($this->transitions) !== 0) { $childBar->separatorButton('transition-headline', 'COM_CONTENT_RUN_TRANSITIONS') ->buttonClass('text-center py-2 h3'); diff --git a/administrator/components/com_contenthistory/src/View/Compare/HtmlView.php b/administrator/components/com_contenthistory/src/View/Compare/HtmlView.php index ba30239944fa2..ce63e168ca98e 100644 --- a/administrator/components/com_contenthistory/src/View/Compare/HtmlView.php +++ b/administrator/components/com_contenthistory/src/View/Compare/HtmlView.php @@ -58,7 +58,7 @@ public function display($tpl = null) $this->items = $model->getItems(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_contenthistory/src/View/History/HtmlView.php b/administrator/components/com_contenthistory/src/View/History/HtmlView.php index cd47fd722889b..92a420336e6c7 100644 --- a/administrator/components/com_contenthistory/src/View/History/HtmlView.php +++ b/administrator/components/com_contenthistory/src/View/History/HtmlView.php @@ -80,7 +80,7 @@ public function display($tpl = null) $this->pagination = $model->getPagination(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_contenthistory/src/View/Preview/HtmlView.php b/administrator/components/com_contenthistory/src/View/Preview/HtmlView.php index 534e8fa76920a..49479e8804035 100644 --- a/administrator/components/com_contenthistory/src/View/Preview/HtmlView.php +++ b/administrator/components/com_contenthistory/src/View/Preview/HtmlView.php @@ -65,7 +65,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_fields/src/Controller/DisplayController.php b/administrator/components/com_fields/src/Controller/DisplayController.php index d35845b3d6c81..ea5da6a53d648 100644 --- a/administrator/components/com_fields/src/Controller/DisplayController.php +++ b/administrator/components/com_fields/src/Controller/DisplayController.php @@ -57,7 +57,7 @@ public function display($cachable = false, $urlparams = false) // Check for edit form. if ($vName == 'field' && !$this->checkEditId('com_fields.edit.field', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_fields/src/Helper/FieldsHelper.php b/administrator/components/com_fields/src/Helper/FieldsHelper.php index 2539e38851133..a3bdd08aa8669 100644 --- a/administrator/components/com_fields/src/Helper/FieldsHelper.php +++ b/administrator/components/com_fields/src/Helper/FieldsHelper.php @@ -329,7 +329,7 @@ public static function prepareForm($context, Form $form, $data) ? (int) reset($assignedCatids) : (int) $assignedCatids; - if (!$assignedCatids && $formField = $form->getField('catid')) { + if ($assignedCatids === 0 && $formField = $form->getField('catid')) { $assignedCatids = $formField->getAttribute('default', null); if (!$assignedCatids) { diff --git a/administrator/components/com_fields/src/Model/FieldModel.php b/administrator/components/com_fields/src/Model/FieldModel.php index 52e8356d66b35..92ac4a86029e3 100644 --- a/administrator/components/com_fields/src/Model/FieldModel.php +++ b/administrator/components/com_fields/src/Model/FieldModel.php @@ -628,7 +628,7 @@ public function setFieldValue($fieldId, $itemId, $value) } elseif (\count($value) === 1 && \count((array) $oldValue) === 1) { // Only a single row value update can be done when not empty $needsUpdate = \is_array($value[0]) ? \count($value[0]) : \strlen($value[0]); - $needsDelete = !$needsUpdate; + $needsDelete = $needsUpdate === 0; } else { // Multiple values, we need to purge the data and do a new // insert diff --git a/administrator/components/com_fields/src/View/Field/HtmlView.php b/administrator/components/com_fields/src/View/Field/HtmlView.php index e3f8d175738ef..27600bfd0acb3 100644 --- a/administrator/components/com_fields/src/View/Field/HtmlView.php +++ b/administrator/components/com_fields/src/View/Field/HtmlView.php @@ -78,7 +78,7 @@ public function display($tpl = null) $this->canDo = ContentHelper::getActions($this->state->get('field.component'), 'field', $this->item->id); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_fields/src/View/Fields/HtmlView.php b/administrator/components/com_fields/src/View/Fields/HtmlView.php index cdff33f2d16b5..334592ba3cddf 100644 --- a/administrator/components/com_fields/src/View/Fields/HtmlView.php +++ b/administrator/components/com_fields/src/View/Fields/HtmlView.php @@ -96,7 +96,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_fields/src/View/Group/HtmlView.php b/administrator/components/com_fields/src/View/Group/HtmlView.php index f67a0eb556d08..14d637ad8f502 100644 --- a/administrator/components/com_fields/src/View/Group/HtmlView.php +++ b/administrator/components/com_fields/src/View/Group/HtmlView.php @@ -92,7 +92,7 @@ public function display($tpl = null) $this->canDo = ContentHelper::getActions($component, 'fieldgroup', $this->item->id); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_fields/src/View/Groups/HtmlView.php b/administrator/components/com_fields/src/View/Groups/HtmlView.php index 06eb696d42e9e..c8b410bd7e22d 100644 --- a/administrator/components/com_fields/src/View/Groups/HtmlView.php +++ b/administrator/components/com_fields/src/View/Groups/HtmlView.php @@ -96,7 +96,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_finder/src/Controller/DisplayController.php b/administrator/components/com_finder/src/Controller/DisplayController.php index 4178ae969931d..97587b3a77340 100644 --- a/administrator/components/com_finder/src/Controller/DisplayController.php +++ b/administrator/components/com_finder/src/Controller/DisplayController.php @@ -53,7 +53,7 @@ public function display($cachable = false, $urlparams = []) // Check for edit form. if ($view === 'filter' && $layout === 'edit' && !$this->checkEditId('com_finder.edit.filter', $filterId)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $filterId), 'error'); } diff --git a/administrator/components/com_finder/src/Controller/FilterController.php b/administrator/components/com_finder/src/Controller/FilterController.php index 4f6d88a8a2444..098c0b279fbf1 100644 --- a/administrator/components/com_finder/src/Controller/FilterController.php +++ b/administrator/components/com_finder/src/Controller/FilterController.php @@ -79,7 +79,7 @@ public function save($key = null, $urlVar = null) // Check-in the original row. if ($checkin && $model->checkin($data[$key]) === false) { // Check-in failed. Go back to the item and display a notice. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'error'); } diff --git a/administrator/components/com_finder/src/Indexer/Language/El.php b/administrator/components/com_finder/src/Indexer/Language/El.php index 6d2942e7c7a85..671446bc09f0d 100644 --- a/administrator/components/com_finder/src/Indexer/Language/El.php +++ b/administrator/components/com_finder/src/Indexer/Language/El.php @@ -401,7 +401,7 @@ public function stem($token) $token = $match[1]; $re = '/(ΟΚ|ΜΑΜ|ΜΑΝ|ΜΠΑΜΠ|ΠΑΤΕΡ|ΓΙΑΓΙ|ΝΤΑΝΤ|ΚΥΡ|ΘΕΙ|ΠΕΘΕΡ)$/'; - if (!preg_match($re, $token)) { + if (in_array(preg_match($re, $token), [0, false], true)) { $token .= "ΑΔ"; } } @@ -667,7 +667,7 @@ public function stem($token) if ( (preg_match($exept18, $token) || preg_match($exept19, $token)) - && (!preg_match($exept17, $token) && !preg_match($exept20, $token)) + && (in_array(preg_match($exept17, $token), [0, false], true) && in_array(preg_match($exept20, $token), [0, false], true)) ) { $token .= "ΑΓ"; } diff --git a/administrator/components/com_finder/src/Indexer/Query.php b/administrator/components/com_finder/src/Indexer/Query.php index bf703305f1a26..b4c4e81438955 100644 --- a/administrator/components/com_finder/src/Indexer/Query.php +++ b/administrator/components/com_finder/src/Indexer/Query.php @@ -1150,7 +1150,7 @@ protected function processString($input, $lang, $mode) // Tokenize the phrase. $token = Helper::tokenize($phrases[$i], $lang, true); - if (!\count($token)) { + if (\count($token) === 0) { continue; } diff --git a/administrator/components/com_finder/src/Indexer/Taxonomy.php b/administrator/components/com_finder/src/Indexer/Taxonomy.php index 09d566da8b155..20d0d49c15412 100644 --- a/administrator/components/com_finder/src/Indexer/Taxonomy.php +++ b/administrator/components/com_finder/src/Indexer/Taxonomy.php @@ -466,7 +466,7 @@ public static function removeOrphanNodes() */ public static function getTaxonomy($id = 0) { - if (!\count(self::$taxonomies)) { + if (\count(self::$taxonomies) === 0) { $db = Factory::getDbo(); $query = $db->getQuery(true); @@ -496,7 +496,7 @@ public static function getTaxonomy($id = 0) */ public static function getBranch($title = '') { - if (!\count(self::$branches)) { + if (\count(self::$branches) === 0) { $taxonomies = self::getTaxonomy(); foreach ($taxonomies as $t) { diff --git a/administrator/components/com_finder/src/Model/IndexModel.php b/administrator/components/com_finder/src/Model/IndexModel.php index a1e23c7381ba7..44769acf592b3 100644 --- a/administrator/components/com_finder/src/Model/IndexModel.php +++ b/administrator/components/com_finder/src/Model/IndexModel.php @@ -228,7 +228,7 @@ protected function getListQuery() $orSearchSql = $db->quoteName('l.title') . ' LIKE ' . $search . ' OR ' . $db->quoteName('l.url') . ' LIKE ' . $search; // Filter by indexdate only if $search doesn't contains non-ascii characters - if (!preg_match('/[^\x00-\x7F]/', $search)) { + if (in_array(preg_match('/[^\x00-\x7F]/', $search), [0, false], true)) { $orSearchSql .= ' OR ' . $query->castAsChar($db->quoteName('l.indexdate')) . ' LIKE ' . $search; } diff --git a/administrator/components/com_finder/src/Service/HTML/Query.php b/administrator/components/com_finder/src/Service/HTML/Query.php index 4164d4c99586a..5c6d83ee41434 100644 --- a/administrator/components/com_finder/src/Service/HTML/Query.php +++ b/administrator/components/com_finder/src/Service/HTML/Query.php @@ -106,7 +106,7 @@ public static function explained(IndexerQuery $query) } // Build the interpreted query. - return \count($parts) ? implode(Text::_('COM_FINDER_QUERY_TOKEN_GLUE'), $parts) : null; + return $parts !== [] ? implode(Text::_('COM_FINDER_QUERY_TOKEN_GLUE'), $parts) : null; } /** diff --git a/administrator/components/com_finder/src/View/Filter/HtmlView.php b/administrator/components/com_finder/src/View/Filter/HtmlView.php index ec4ad560df2e8..f5fad02daa11c 100644 --- a/administrator/components/com_finder/src/View/Filter/HtmlView.php +++ b/administrator/components/com_finder/src/View/Filter/HtmlView.php @@ -109,7 +109,7 @@ public function display($tpl = null) $this->total = $model->getTotal(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_finder/src/View/Filters/HtmlView.php b/administrator/components/com_finder/src/View/Filters/HtmlView.php index 973ce40578d73..04b7b0dcafbbf 100644 --- a/administrator/components/com_finder/src/View/Filters/HtmlView.php +++ b/administrator/components/com_finder/src/View/Filters/HtmlView.php @@ -120,7 +120,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_finder/src/View/Index/HtmlView.php b/administrator/components/com_finder/src/View/Index/HtmlView.php index 929a44dd5be8f..06948c8abd054 100644 --- a/administrator/components/com_finder/src/View/Index/HtmlView.php +++ b/administrator/components/com_finder/src/View/Index/HtmlView.php @@ -150,7 +150,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_finder/src/View/Maps/HtmlView.php b/administrator/components/com_finder/src/View/Maps/HtmlView.php index 79bccea580466..cb373e00bc5d2 100644 --- a/administrator/components/com_finder/src/View/Maps/HtmlView.php +++ b/administrator/components/com_finder/src/View/Maps/HtmlView.php @@ -124,7 +124,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_finder/src/View/Searches/HtmlView.php b/administrator/components/com_finder/src/View/Searches/HtmlView.php index aa0ed836143e2..a6bba1ce00d51 100644 --- a/administrator/components/com_finder/src/View/Searches/HtmlView.php +++ b/administrator/components/com_finder/src/View/Searches/HtmlView.php @@ -121,12 +121,12 @@ public function display($tpl = null) $link = 'index.php?option=com_config&view=component&component=com_finder&return=' . base64_encode($uri); $output = HTMLHelper::_('link', Route::_($link), Text::_('JOPTIONS')); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_finder/src/View/Statistics/HtmlView.php b/administrator/components/com_finder/src/View/Statistics/HtmlView.php index 3333e19384015..503337dcd10b5 100644 --- a/administrator/components/com_finder/src/View/Statistics/HtmlView.php +++ b/administrator/components/com_finder/src/View/Statistics/HtmlView.php @@ -53,7 +53,7 @@ public function display($tpl = null) $this->data = $model->getData(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_guidedtours/src/View/Step/HtmlView.php b/administrator/components/com_guidedtours/src/View/Step/HtmlView.php index daf2edb1d19f1..f29b00d460d2a 100644 --- a/administrator/components/com_guidedtours/src/View/Step/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Step/HtmlView.php @@ -78,7 +78,7 @@ public function display($tpl = null) $this->item = $model->getItem(); $this->state = $model->getState(); - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } @@ -152,7 +152,7 @@ protected function addToolbar() ToolbarHelper::divider(); $inlinehelp = (string) $this->form->getXml()->config->inlinehelp['button'] === 'show'; - $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] ?: 'hide-aware-inline-help'; + $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] !== '' && (string) $this->form->getXml()->config->inlinehelp['targetclass'] !== '0' ? (string) $this->form->getXml()->config->inlinehelp['targetclass'] : 'hide-aware-inline-help'; if ($inlinehelp) { ToolbarHelper::inlinehelp($targetClass); diff --git a/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php b/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php index 5faccaafcce0c..bc7c44e4b2403 100644 --- a/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Steps/HtmlView.php @@ -96,12 +96,12 @@ public function display($tpl = null) $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php b/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php index 45d1c75673990..327663481d075 100644 --- a/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Tour/HtmlView.php @@ -78,7 +78,7 @@ public function display($tpl = null) $this->item = $model->getItem(); $this->state = $model->getState(); - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } @@ -153,7 +153,7 @@ protected function addToolbar() ToolbarHelper::divider(); $inlinehelp = (string) $this->form->getXml()->config->inlinehelp['button'] === 'show'; - $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] ?: 'hide-aware-inline-help'; + $targetClass = (string) $this->form->getXml()->config->inlinehelp['targetclass'] !== '' && (string) $this->form->getXml()->config->inlinehelp['targetclass'] !== '0' ? (string) $this->form->getXml()->config->inlinehelp['targetclass'] : 'hide-aware-inline-help'; if ($inlinehelp) { ToolbarHelper::inlinehelp($targetClass); diff --git a/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php b/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php index 8aaecfce8f735..825de5dd23971 100644 --- a/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php +++ b/administrator/components/com_guidedtours/src/View/Tours/HtmlView.php @@ -94,12 +94,12 @@ public function display($tpl = null) $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_installer/src/Controller/DisplayController.php b/administrator/components/com_installer/src/Controller/DisplayController.php index 428087dd6e0c6..e68055b98ee59 100644 --- a/administrator/components/com_installer/src/Controller/DisplayController.php +++ b/administrator/components/com_installer/src/Controller/DisplayController.php @@ -51,7 +51,7 @@ public function display($cachable = false, $urlparams = false) // Check for edit form. if ($vName === 'updatesite' && $lName === 'edit' && !$this->checkEditId('com_installer.edit.updatesite', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_installer/src/Model/InstallerModel.php b/administrator/components/com_installer/src/Model/InstallerModel.php index b2e6b0f2137c3..beecbebedda74 100644 --- a/administrator/components/com_installer/src/Model/InstallerModel.php +++ b/administrator/components/com_installer/src/Model/InstallerModel.php @@ -102,7 +102,7 @@ protected function _getList($query, $limitstart = 0, $limit = 0) $found = 0; foreach ($searchFields as $field) { - if (!$found && preg_match('/' . $escapedSearchString . '/i', (string) $item->{$field})) { + if ($found === 0 && preg_match('/' . $escapedSearchString . '/i', (string) $item->{$field})) { $found = 1; } } @@ -184,10 +184,10 @@ protected function translate(&$items) case 'library': $parts = explode('/', $item->element); $vendor = (isset($parts[1]) ? $parts[0] : null); - $extension = 'lib_' . ($vendor ? implode('_', $parts) : $item->element); + $extension = 'lib_' . ($vendor !== null && $vendor !== '' && $vendor !== '0' ? implode('_', $parts) : $item->element); if (!$lang->load($extension . '.sys', $path)) { - $source = $path . '/libraries/' . ($vendor ? $vendor . '/' . $parts[1] : $item->element); + $source = $path . '/libraries/' . ($vendor !== null && $vendor !== '' && $vendor !== '0' ? $vendor . '/' . $parts[1] : $item->element); $lang->load($extension . '.sys', $source); } break; diff --git a/administrator/components/com_installer/src/Model/WarningsModel.php b/administrator/components/com_installer/src/Model/WarningsModel.php index 3d54ab120cc0c..c9209ead989a9 100644 --- a/administrator/components/com_installer/src/Model/WarningsModel.php +++ b/administrator/components/com_installer/src/Model/WarningsModel.php @@ -92,7 +92,7 @@ public function getItems() $file_uploads = \ini_get('file_uploads'); - if (!$file_uploads) { + if ($file_uploads === '' || $file_uploads === '0' || $file_uploads === false) { $messages[] = [ 'message' => Text::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADSDISABLED'), 'description' => Text::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADISDISABLEDDESC'), @@ -101,7 +101,7 @@ public function getItems() $upload_dir = \ini_get('upload_tmp_dir'); - if (!$upload_dir) { + if ($upload_dir === '' || $upload_dir === '0' || $upload_dir === false) { $messages[] = [ 'message' => Text::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSET'), 'description' => Text::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSETDESC'), diff --git a/administrator/components/com_installer/src/View/Discover/HtmlView.php b/administrator/components/com_installer/src/View/Discover/HtmlView.php index e18514e4998d1..bf0099454e503 100644 --- a/administrator/components/com_installer/src/View/Discover/HtmlView.php +++ b/administrator/components/com_installer/src/View/Discover/HtmlView.php @@ -92,12 +92,12 @@ public function display($tpl = null) $this->filterForm = $model->getFilterForm(); $this->activeFilters = $model->getActiveFilters(); - if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) { + if (\count($this->items) === 0 && $this->isEmptyState = $model->getIsEmptyState()) { $this->setLayout('emptystate'); } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_installer/src/View/Languages/HtmlView.php b/administrator/components/com_installer/src/View/Languages/HtmlView.php index 8f21b2fef7bea..91b4976564bf8 100644 --- a/administrator/components/com_installer/src/View/Languages/HtmlView.php +++ b/administrator/components/com_installer/src/View/Languages/HtmlView.php @@ -82,7 +82,7 @@ public function display($tpl = null) $this->installedLang = LanguageHelper::getInstalledLanguages(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_installer/src/View/Manage/HtmlView.php b/administrator/components/com_installer/src/View/Manage/HtmlView.php index c12913f72e5ac..6533932ff340f 100644 --- a/administrator/components/com_installer/src/View/Manage/HtmlView.php +++ b/administrator/components/com_installer/src/View/Manage/HtmlView.php @@ -84,7 +84,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_installer/src/View/Updatesite/HtmlView.php b/administrator/components/com_installer/src/View/Updatesite/HtmlView.php index 35038a5138a8f..bfa72f29b0b92 100644 --- a/administrator/components/com_installer/src/View/Updatesite/HtmlView.php +++ b/administrator/components/com_installer/src/View/Updatesite/HtmlView.php @@ -77,7 +77,7 @@ public function display($tpl = null): void } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_installer/src/View/Updatesites/HtmlView.php b/administrator/components/com_installer/src/View/Updatesites/HtmlView.php index 2bfa9b0e3420d..26422f5321609 100644 --- a/administrator/components/com_installer/src/View/Updatesites/HtmlView.php +++ b/administrator/components/com_installer/src/View/Updatesites/HtmlView.php @@ -82,7 +82,7 @@ public function display($tpl = null): void $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_installer/src/View/Warnings/HtmlView.php b/administrator/components/com_installer/src/View/Warnings/HtmlView.php index 6fb2bd95d4436..38e006e2e1e6d 100644 --- a/administrator/components/com_installer/src/View/Warnings/HtmlView.php +++ b/administrator/components/com_installer/src/View/Warnings/HtmlView.php @@ -41,7 +41,7 @@ public function display($tpl = null) $this->messages = $model->getItems(); - if (!\count($this->messages)) { + if (\count($this->messages) === 0) { $this->setLayout('emptystate'); } diff --git a/administrator/components/com_joomlaupdate/extract.php b/administrator/components/com_joomlaupdate/extract.php index 4a4ce3200ac27..29bb55eec8ff2 100644 --- a/administrator/components/com_joomlaupdate/extract.php +++ b/administrator/components/com_joomlaupdate/extract.php @@ -869,10 +869,10 @@ private function binStringLength(?string $string): int } if (\function_exists('mb_strlen')) { - return mb_strlen($string, '8bit') ?: 0; + return mb_strlen($string, '8bit'); } - return \strlen($string) ?: 0; + return \strlen($string); } /** @@ -1605,7 +1605,7 @@ private function getPhpMaxExecTime(): int } $phpMaxTime = @\ini_get("maximum_execution_time"); - $phpMaxTime = (is_numeric($phpMaxTime) ? @\intval($phpMaxTime) : 10) ?: 10; + $phpMaxTime = (is_numeric($phpMaxTime) ? @\intval($phpMaxTime) : 10 !== 0) ? is_numeric($phpMaxTime) ? @\intval($phpMaxTime) : 10 : 10; return max(1, $phpMaxTime); } @@ -1668,7 +1668,7 @@ private function initializeLog(string $logPath): void return; } - $logPath = $logPath ?: \dirname($this->filename); + $logPath = $logPath !== '' && $logPath !== '0' ? $logPath : \dirname($this->filename); $logFile = rtrim($logPath, '/' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'joomla_update.txt'; self::$logFilePath = $logFile; @@ -1697,7 +1697,7 @@ function clearFileInOPCache(string $file): bool if (\is_null($hasOpCache)) { $hasOpCache = \ini_get('opcache.enable') && \function_exists('opcache_invalidate') - && (!\ini_get('opcache.restrict_api') || stripos(realpath($_SERVER['SCRIPT_FILENAME']), \ini_get('opcache.restrict_api')) === 0); + && (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); } if ($hasOpCache && (strtolower(substr($file, -4)) === '.php')) { diff --git a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php index 7bf50d8129c05..45599747e1e71 100644 --- a/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php +++ b/administrator/components/com_joomlaupdate/src/Model/UpdateModel.php @@ -1743,7 +1743,7 @@ public function isTemplateActive($template) $menu = false; - if (\count($ids)) { + if (\count($ids) !== 0) { $query = $db->getQuery(true); $query->select( @@ -1941,7 +1941,7 @@ private function checkPackageFileNoZip(string $filePath, $packageName) } // If no central directory file header found for the manifest XML file it's not a valid Joomla package - if (!$headerInfo) { + if ($headerInfo === [] || $headerInfo === false) { @fclose($fp); throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE', $packageName), 500); @@ -1986,7 +1986,7 @@ private function checkPackageFileNoZip(string $filePath, $packageName) break; } - if (!$manifestFile) { + if ($manifestFile === '' || $manifestFile === '0' || $manifestFile === false) { throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_MANIFEST_FILE', $packageName), 500); } @@ -2012,7 +2012,7 @@ private function checkManifestXML(string $manifest, $packageName) throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND', $packageName), 500); } - $versionPackage = (string) $manifestXml->version ?: ''; + $versionPackage = (string) $manifestXml->version !== '' && (string) $manifestXml->version !== '0' ? (string) $manifestXml->version : ''; if ($versionPackage === '' || $versionPackage === '0') { throw new \RuntimeException(Text::sprintf('COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NO_VERSION_FOUND', $packageName), 500); diff --git a/administrator/components/com_languages/src/Controller/DisplayController.php b/administrator/components/com_languages/src/Controller/DisplayController.php index 31e9156c88edb..a851c96241398 100644 --- a/administrator/components/com_languages/src/Controller/DisplayController.php +++ b/administrator/components/com_languages/src/Controller/DisplayController.php @@ -51,7 +51,7 @@ public function display($cachable = false, $urlparams = false) // Check for edit form. if ($view == 'language' && $layout == 'edit' && !$this->checkEditId('com_languages.edit.language', $id)) { // Somehow the person just went to the form - we don't allow that. - if (!\count($this->app->getMessageQueue())) { + if (\count($this->app->getMessageQueue()) === 0) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } diff --git a/administrator/components/com_languages/src/Controller/OverrideController.php b/administrator/components/com_languages/src/Controller/OverrideController.php index fc95aa8b052e8..34f0272f6a56f 100644 --- a/administrator/components/com_languages/src/Controller/OverrideController.php +++ b/administrator/components/com_languages/src/Controller/OverrideController.php @@ -45,7 +45,7 @@ public function edit($key = null, $urlVar = null) $context = sprintf('%s.edit.%s', $this->option, $this->context); // Get the constant name. - $recordId = (\count($cid) ? $cid[0] : $this->input->get('id')); + $recordId = ($cid !== [] ? $cid[0] : $this->input->get('id')); // Access check. if (!$this->allowEdit()) { diff --git a/administrator/components/com_languages/src/Model/LanguageModel.php b/administrator/components/com_languages/src/Model/LanguageModel.php index 04ae2866379f4..e654f5545b306 100644 --- a/administrator/components/com_languages/src/Model/LanguageModel.php +++ b/administrator/components/com_languages/src/Model/LanguageModel.php @@ -206,7 +206,7 @@ public function save($data) $data['lang_code'] = str_replace($spaces, '', $data['lang_code']); // Prevent saving an incorrect language tag - if (!preg_match('#\b([a-z]{2,3})[-]([A-Z]{2})\b#', $data['lang_code'])) { + if (in_array(preg_match('#\b([a-z]{2,3})[-]([A-Z]{2})\b#', $data['lang_code']), [0, false], true)) { $this->setError(Text::_('COM_LANGUAGES_ERROR_LANG_TAG')); return false; diff --git a/administrator/components/com_languages/src/View/Installed/HtmlView.php b/administrator/components/com_languages/src/View/Installed/HtmlView.php index c3820dbc8023a..b53a3f1dadef9 100644 --- a/administrator/components/com_languages/src/View/Installed/HtmlView.php +++ b/administrator/components/com_languages/src/View/Installed/HtmlView.php @@ -103,7 +103,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_languages/src/View/Language/HtmlView.php b/administrator/components/com_languages/src/View/Language/HtmlView.php index df19049bb5a9e..7a0562ec3252b 100644 --- a/administrator/components/com_languages/src/View/Language/HtmlView.php +++ b/administrator/components/com_languages/src/View/Language/HtmlView.php @@ -80,7 +80,7 @@ public function display($tpl = null) $this->canDo = ContentHelper::getActions('com_languages'); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_languages/src/View/Languages/HtmlView.php b/administrator/components/com_languages/src/View/Languages/HtmlView.php index 7d98b8fd62339..110ae925086a7 100644 --- a/administrator/components/com_languages/src/View/Languages/HtmlView.php +++ b/administrator/components/com_languages/src/View/Languages/HtmlView.php @@ -91,7 +91,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_languages/src/View/Override/HtmlView.php b/administrator/components/com_languages/src/View/Override/HtmlView.php index 3daf15057ba61..873f8699c80f7 100644 --- a/administrator/components/com_languages/src/View/Override/HtmlView.php +++ b/administrator/components/com_languages/src/View/Override/HtmlView.php @@ -83,7 +83,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors)); } diff --git a/administrator/components/com_languages/src/View/Overrides/HtmlView.php b/administrator/components/com_languages/src/View/Overrides/HtmlView.php index 377fafe947368..729454e91a076 100644 --- a/administrator/components/com_languages/src/View/Overrides/HtmlView.php +++ b/administrator/components/com_languages/src/View/Overrides/HtmlView.php @@ -96,7 +96,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors)); } diff --git a/administrator/components/com_mails/src/Helper/MailsHelper.php b/administrator/components/com_mails/src/Helper/MailsHelper.php index 7eb1b23a60b7d..2f68101c1367b 100644 --- a/administrator/components/com_mails/src/Helper/MailsHelper.php +++ b/administrator/components/com_mails/src/Helper/MailsHelper.php @@ -37,7 +37,7 @@ public static function mailtags($mail, $fieldname) { Factory::getApplication()->triggerEvent('onMailBeforeTagsRendering', [$mail->template_id, &$mail]); - if (!isset($mail->params['tags']) || !\count($mail->params['tags'])) { + if (!isset($mail->params['tags']) || \count($mail->params['tags']) === 0) { return ''; } diff --git a/administrator/components/com_mails/src/Model/TemplateModel.php b/administrator/components/com_mails/src/Model/TemplateModel.php index 90b2ac5df7f3f..5f45e5c57c599 100644 --- a/administrator/components/com_mails/src/Model/TemplateModel.php +++ b/administrator/components/com_mails/src/Model/TemplateModel.php @@ -131,7 +131,7 @@ public function getForm($data = [], $loadData = true) $attachmentPath = ''; } - if (!$attachmentPath || $attachmentPath === Path::clean(JPATH_ROOT) || !is_dir($attachmentPath)) { + if ($attachmentPath === '' || $attachmentPath === '0' || $attachmentPath === Path::clean(JPATH_ROOT) || !is_dir($attachmentPath)) { $form->removeField('attachments'); return $form; diff --git a/administrator/components/com_mails/src/View/Template/HtmlView.php b/administrator/components/com_mails/src/View/Template/HtmlView.php index da3192a1fb59c..19a159ce47c51 100644 --- a/administrator/components/com_mails/src/View/Template/HtmlView.php +++ b/administrator/components/com_mails/src/View/Template/HtmlView.php @@ -86,7 +86,7 @@ public function display($tpl = null) $this->form = $model->getForm(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_mails/src/View/Templates/HtmlView.php b/administrator/components/com_mails/src/View/Templates/HtmlView.php index b82493fdfbef8..1d29ef32eca26 100644 --- a/administrator/components/com_mails/src/View/Templates/HtmlView.php +++ b/administrator/components/com_mails/src/View/Templates/HtmlView.php @@ -104,7 +104,7 @@ public function display($tpl = null) $extensions = $model->getExtensions(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_mails/tmpl/template/edit.php b/administrator/components/com_mails/tmpl/template/edit.php index a46d3cc8c8d65..c778cacfc7cdf 100644 --- a/administrator/components/com_mails/tmpl/template/edit.php +++ b/administrator/components/com_mails/tmpl/template/edit.php @@ -108,7 +108,7 @@ - form->getFieldset('basic'))) : ?> + form->getFieldset('basic')) !== 0) : ?> diff --git a/administrator/components/com_media/src/Model/ApiModel.php b/administrator/components/com_media/src/Model/ApiModel.php index c6436d8575da8..a1160d2d3eb73 100644 --- a/administrator/components/com_media/src/Model/ApiModel.php +++ b/administrator/components/com_media/src/Model/ApiModel.php @@ -445,7 +445,7 @@ public function search($adapter, $needle, $path = '/', $recursive = true) private function isMediaFile($path) { // Check if there is an extension available - if (!strrpos($path, '.')) { + if (in_array(strrpos($path, '.'), [0, false], true)) { return false; } diff --git a/administrator/components/com_media/src/Provider/ProviderManagerHelperTrait.php b/administrator/components/com_media/src/Provider/ProviderManagerHelperTrait.php index 06af1fb20ffa5..a9a41695d9790 100644 --- a/administrator/components/com_media/src/Provider/ProviderManagerHelperTrait.php +++ b/administrator/components/com_media/src/Provider/ProviderManagerHelperTrait.php @@ -129,7 +129,7 @@ protected function resolveAdapterAndPath(string $path): array $result['adapter'] = $this->getDefaultAdapterName(); // If we have 1 part, we return it as the path. Otherwise we return a default path - $result['path'] = \count($parts) ? $parts[0] : '/'; + $result['path'] = $parts !== [] ? $parts[0] : '/'; return $result; } diff --git a/administrator/components/com_media/src/View/Media/HtmlView.php b/administrator/components/com_media/src/View/Media/HtmlView.php index 076adf45a0509..f2147740fd051 100644 --- a/administrator/components/com_media/src/View/Media/HtmlView.php +++ b/administrator/components/com_media/src/View/Media/HtmlView.php @@ -70,7 +70,7 @@ public function display($tpl = null) $this->providers = $model->getProviders(); // Check that there are providers - if (!\count($this->providers)) { + if (\count($this->providers) === 0) { $link = Route::_('index.php?option=com_plugins&view=plugins&filter[folder]=filesystem'); Factory::getApplication()->enqueueMessage(Text::sprintf('COM_MEDIA_ERROR_NO_PROVIDERS', $link), CMSApplication::MSG_WARNING); } diff --git a/administrator/components/com_menus/src/Controller/MenuController.php b/administrator/components/com_menus/src/Controller/MenuController.php index 39f63b1c3b917..e34c471d2562c 100644 --- a/administrator/components/com_menus/src/Controller/MenuController.php +++ b/administrator/components/com_menus/src/Controller/MenuController.php @@ -117,7 +117,7 @@ public function save($key = null, $urlVar = null) } if (isset($validData['preset'])) { - $preset = trim((string) $validData['preset']) ?: null; + $preset = in_array(trim((string) $validData['preset']), ['', '0'], true) ? null : trim((string) $validData['preset']); unset($validData['preset']); } diff --git a/administrator/components/com_menus/src/Field/MenutypeField.php b/administrator/components/com_menus/src/Field/MenutypeField.php index 51d5c0dd6203f..6f480178b005b 100644 --- a/administrator/components/com_menus/src/Field/MenutypeField.php +++ b/administrator/components/com_menus/src/Field/MenutypeField.php @@ -57,7 +57,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) } $recordId = (int) $this->form->getValue('id'); - $clientId = (int) $this->element['clientid'] ?: 0; + $clientId = (int) $this->element['clientid']; $url = 'index.php?option=com_menus&view=menutypes&tmpl=component&client_id=' . $clientId . '&recordId=' . $recordId; @@ -79,7 +79,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) protected function getValueTitle() { $title = ''; - $clientId = (int) $this->element['clientid'] ?: 0; + $clientId = (int) $this->element['clientid']; // Get a reverse lookup of the base link URL to Title switch ($this->value) { diff --git a/administrator/components/com_menus/src/Field/Modal/MenuField.php b/administrator/components/com_menus/src/Field/Modal/MenuField.php index d049edaa45294..efa10e333524d 100644 --- a/administrator/components/com_menus/src/Field/Modal/MenuField.php +++ b/administrator/components/com_menus/src/Field/Modal/MenuField.php @@ -236,23 +236,21 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) */ protected function getValueTitle() { - $value = (int) $this->value ?: ''; + $value = (int) $this->value !== 0 ? (int) $this->value : ''; $title = ''; - if ($value) { - try { - $db = $this->getDatabase(); - $query = $db->getQuery(true) - ->select($db->quoteName('title')) - ->from($db->quoteName('#__menu')) - ->where($db->quoteName('id') . ' = :id') - ->bind(':id', $value, ParameterType::INTEGER); - $db->setQuery($query); - - $title = $db->loadResult(); - } catch (\Throwable $e) { - Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); - } + try { + $db = $this->getDatabase(); + $query = $db->getQuery(true) + ->select($db->quoteName('title')) + ->from($db->quoteName('#__menu')) + ->where($db->quoteName('id') . ' = :id') + ->bind(':id', $value, ParameterType::INTEGER); + $db->setQuery($query); + + $title = $db->loadResult(); + } catch (\Throwable $throwable) { + Factory::getApplication()->enqueueMessage($throwable->getMessage(), 'error'); } return $title ?: $value; diff --git a/administrator/components/com_menus/src/Helper/MenusHelper.php b/administrator/components/com_menus/src/Helper/MenusHelper.php index 33d35a39ab62f..67a7c6e19607b 100644 --- a/administrator/components/com_menus/src/Helper/MenusHelper.php +++ b/administrator/components/com_menus/src/Helper/MenusHelper.php @@ -333,7 +333,7 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude = 'OR' ); - if (\count($exclude)) { + if (\count($exclude) !== 0) { $exId = array_map('intval', array_filter($exclude, 'is_numeric')); $exEl = array_filter($exclude, 'is_string'); @@ -873,7 +873,7 @@ protected static function parseXmlNode($node, $replace = []) $item->class = (string) $node['class']; $item->icon = (string) $node['icon']; $item->access = (int) $node['access']; - $item->scope = (string) $node['scope'] ?: 'default'; + $item->scope = (string) $node['scope'] !== '' && (string) $node['scope'] !== '0' ? (string) $node['scope'] : 'default'; $item->ajaxbadge = (string) $node['ajax-badge']; $item->dashboard = (string) $node['dashboard']; diff --git a/administrator/components/com_menus/src/Model/ItemModel.php b/administrator/components/com_menus/src/Model/ItemModel.php index c8f93a7bd95bf..501e5d59e3b1b 100644 --- a/administrator/components/com_menus/src/Model/ItemModel.php +++ b/administrator/components/com_menus/src/Model/ItemModel.php @@ -1169,8 +1169,8 @@ protected function preprocessForm(Form $form, $data, $group = 'content') $helpURL = trim((string) $help[0]['url']); $helpLoc = trim((string) $help[0]['local']); - $this->helpKey = $helpKey ?: $this->helpKey; - $this->helpURL = $helpURL ?: $this->helpURL; + $this->helpKey = $helpKey !== '' && $helpKey !== '0' ? $helpKey : $this->helpKey; + $this->helpURL = $helpURL !== '' && $helpURL !== '0' ? $helpURL : $this->helpURL; $this->helpLocal = (($helpLoc === 'true') || ($helpLoc === '1') || ($helpLoc === 'local')); } diff --git a/administrator/components/com_menus/src/View/Item/HtmlView.php b/administrator/components/com_menus/src/View/Item/HtmlView.php index 23a612baeff47..51ab52ec57b8f 100644 --- a/administrator/components/com_menus/src/View/Item/HtmlView.php +++ b/administrator/components/com_menus/src/View/Item/HtmlView.php @@ -113,7 +113,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_menus/src/View/Items/HtmlView.php b/administrator/components/com_menus/src/View/Items/HtmlView.php index 845175e12e8de..d9c06d9ceb6b0 100644 --- a/administrator/components/com_menus/src/View/Items/HtmlView.php +++ b/administrator/components/com_menus/src/View/Items/HtmlView.php @@ -116,7 +116,7 @@ public function display($tpl = null) $this->activeFilters = $model->getActiveFilters(); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_menus/src/View/Menu/HtmlView.php b/administrator/components/com_menus/src/View/Menu/HtmlView.php index ef26622d9d1ed..659223d908e56 100644 --- a/administrator/components/com_menus/src/View/Menu/HtmlView.php +++ b/administrator/components/com_menus/src/View/Menu/HtmlView.php @@ -81,7 +81,7 @@ public function display($tpl = null) $this->canDo = ContentHelper::getActions('com_menus', 'menu', $this->item->id); // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_menus/src/View/Menus/HtmlView.php b/administrator/components/com_menus/src/View/Menus/HtmlView.php index 161ab3e2889ae..9784880005645 100644 --- a/administrator/components/com_menus/src/View/Menus/HtmlView.php +++ b/administrator/components/com_menus/src/View/Menus/HtmlView.php @@ -109,7 +109,7 @@ public function display($tpl = null) } // Check for errors. - if (\count($errors = $model->getErrors())) { + if (\count($errors = $model->getErrors()) !== 0) { throw new GenericDataException(implode("\n", $errors), 500); } diff --git a/administrator/components/com_menus/tmpl/item/edit_container.php b/administrator/components/com_menus/tmpl/item/edit_container.php index e190b3cc46b20..209e2e89ce5ff 100644 --- a/administrator/components/com_menus/tmpl/item/edit_container.php +++ b/administrator/components/com_menus/tmpl/item/edit_container.php @@ -51,7 +51,7 @@ - + - mediaFiles)) : ?> + mediaFiles) !== 0) : ?> - mediaFiles)) : ?> + mediaFiles) !== 0) : ?> - mediaFiles)) : ?> + mediaFiles) !== 0) : ?>