Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Dec 13, 2024
1 parent d698ce8 commit 151cb18
Show file tree
Hide file tree
Showing 354 changed files with 589 additions and 598 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_admin/src/Model/HelpModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function getLangTag()
*/
public function &getToc()
{
if (\count($this->toc)) {
if (\count($this->toc) !== 0) {
return $this->toc;
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public function &getToc()
foreach ($files as $file) {
$buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file);

if (!preg_match('#<title>(.*?)</title>#', $buffer, $m)) {
if (in_array(preg_match('#<title>(.*?)</title>#', $buffer, $m), [0, false], true)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -68,7 +68,7 @@ protected function getInput()
$html[] = '<button'
. ' type="button"'
. ' id="select-change"'
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' class="btn btn-secondary' . ($value !== 0 && $value !== '0' ? '' : ' hidden') . '"'
. ' data-bs-toggle="modal"'
. ' data-select="' . Text::_('COM_ASSOCIATIONS_SELECT_TARGET') . '"'
. ' data-change="' . Text::_('COM_ASSOCIATIONS_CHANGE_TARGET') . '"'
Expand All @@ -80,7 +80,7 @@ protected function getInput()
// Clear association button
$html[] = '<button'
. ' type="button"'
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' class="btn btn-secondary' . ($value !== 0 && $value !== '0' ? '' : ' hidden') . '"'
. ' onclick="return Joomla.submitbutton(\'undo-association\');"'
. ' id="remove-assoc">'
. '<span class="icon-times" aria-hidden="true"></span> ' . Text::_('JCLEAR')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)));
Expand All @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
Loading

0 comments on commit 151cb18

Please sign in to comment.