Skip to content

Commit

Permalink
native function final (#41427)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman authored Sep 30, 2023
1 parent 9bfa92e commit d38a8ff
Show file tree
Hide file tree
Showing 829 changed files with 1,980 additions and 1,978 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
// There should not be useless else cases
'no_useless_else' => true,
// Native function invocation
'native_function_invocation' => ['include' => ['@compiler_optimized']],
]
)
->setFinder($finder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ function admin_postinstall_behindproxy_condition()
return false;
}

if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
if (\array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return true;
}

if (array_key_exists('HTTP_CLIENT_IP', $_SERVER) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
if (\array_key_exists('HTTP_CLIENT_IP', $_SERVER) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
return true;
}

Expand Down
14 changes: 7 additions & 7 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function collectError(string $context, \Throwable $error)
// The errorCollector are required
// However when someone already running the script manually the code may fail.
if ($this->errorCollector) {
call_user_func($this->errorCollector, $context, $error);
\call_user_func($this->errorCollector, $context, $error);
} else {
Log::add($error->getMessage(), Log::ERROR, 'Update');
}
Expand All @@ -104,7 +104,7 @@ public function preflight($action, $installer)
if (!empty($installer->extension->manifest_cache)) {
$manifestValues = json_decode($installer->extension->manifest_cache, true);

if (array_key_exists('version', $manifestValues)) {
if (\array_key_exists('version', $manifestValues)) {
$this->fromVersion = $manifestValues['version'];

return true;
Expand Down Expand Up @@ -2463,11 +2463,11 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)

$this->fixFilenameCasing();

if ($suppressOutput === false && count($status['folders_errors'])) {
if ($suppressOutput === false && \count($status['folders_errors'])) {
echo implode('<br>', $status['folders_errors']);
}

if ($suppressOutput === false && count($status['files_errors'])) {
if ($suppressOutput === false && \count($status['files_errors'])) {
echo implode('<br>', $status['files_errors']);
}

Expand Down Expand Up @@ -2772,7 +2772,7 @@ private function migrateTinymceConfiguration(): bool
$replace = ['blocks', 'fontfamily', 'fontsize', 'styles'];

// Don't redo the template
if (!in_array('jtemplate', $params['configuration']['toolbars'][$setIdx]['menu'])) {
if (!\in_array('jtemplate', $params['configuration']['toolbars'][$setIdx]['menu'])) {
$search[] = 'template';
$replace[] = 'jtemplate';
}
Expand All @@ -2796,7 +2796,7 @@ private function migrateTinymceConfiguration(): bool
$replace = ['fontfamily', 'fontsize', 'blocks', 'styles'];

// Don't redo the template
if (!in_array('jtemplate', $params['configuration']['toolbars'][$setIdx][$toolbarIdx])) {
if (!\in_array('jtemplate', $params['configuration']['toolbars'][$setIdx][$toolbarIdx])) {
$search[] = 'template';
$replace[] = 'jtemplate';
}
Expand Down Expand Up @@ -2932,7 +2932,7 @@ protected function fixFilenameCasing()
// Check if case-insensitive file system, eg on OSX.
if (fileinode($oldRealpath) === fileinode($newRealpath)) {
// Check deeper because even realpath or glob might not return the actual case.
if (!in_array($expectedBasename, scandir(dirname($newRealpath)))) {
if (!\in_array($expectedBasename, scandir(\dirname($newRealpath)))) {
// Rename the file.
File::move(JPATH_ROOT . $old, JPATH_ROOT . $old . '.tmp');
File::move(JPATH_ROOT . $old . '.tmp', JPATH_ROOT . $expected);
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_admin/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ private function addDirectory(string $name, string $path, string $message = ''):
*/
public function &getEditor(): string
{
if (!is_null($this->editor)) {
if (!\is_null($this->editor)) {
return $this->editor;
}

Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_ajax/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

require_once JPATH_SITE . '/components/com_ajax/ajax.php';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_banners/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Component\Router\RouterFactoryInterface;
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_cache/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function getCache()
public function getTotal()
{
if (empty($this->_total)) {
$this->_total = count($this->getData());
$this->_total = \count($this->getData());
}

return $this->_total;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function getInput()
if ($allowSelect) {
static $scriptSelect = null;

if (is_null($scriptSelect)) {
if (\is_null($scriptSelect)) {
$scriptSelect = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ protected function getListQuery()
$categoryId = $this->getState('filter.category_id', []);
$level = $this->getState('filter.level');

if (!is_array($categoryId)) {
if (!\is_array($categoryId)) {
$categoryId = $categoryId ? [$categoryId] : [];
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function association($catid, $extension = 'com_content')
$content_languages = array_column($languages, 'lang_code');

foreach ($items as &$item) {
if (in_array($item->lang_code, $content_languages)) {
if (\in_array($item->lang_code, $content_languages)) {
$text = $item->lang_code;
$url = Route::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
$tooltip = '<strong>' . htmlspecialchars($item->language_title, ENT_QUOTES, 'UTF-8') . '</strong><br>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ public function display($tpl = null)
$this->activeFilters = $this->get('ActiveFilters');

// 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 = $this->get('IsEmptyState')) {
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}

// Check for errors.
if (count($errors = $this->get('Errors'))) {
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}

Expand Down Expand Up @@ -204,7 +204,7 @@ protected function addToolbar()
// Prepare the toolbar.
ToolbarHelper::title($title, 'folder categories ' . substr($component, 4) . ($section ? "-$section" : '') . '-categories');

if ($canDo->get('core.create') || count($user->getAuthorisedCategories($component, 'core.create')) > 0) {
if ($canDo->get('core.create') || \count($user->getAuthorisedCategories($component, 'core.create')) > 0) {
$toolbar->addNew('category.add');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function display($tpl = null)
$this->assoc = $this->get('Assoc');

// Check for errors.
if (count($errors = $this->get('Errors'))) {
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}

Expand Down Expand Up @@ -139,7 +139,7 @@ protected function addToolbar()
$toolbar = Toolbar::getInstance();

$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $userId);
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);

// Avoid nonsense situation.
if ($extension == 'com_categories') {
Expand All @@ -149,7 +149,7 @@ protected function addToolbar()
// The extension can be in the form com_foo.section
$parts = explode('.', $extension);
$component = $parts[0];
$section = (count($parts) > 1) ? $parts[1] : null;
$section = (\count($parts) > 1) ? $parts[1] : null;
$componentParams = ComponentHelper::getParams($component);

// Need to load the menu language file as mod_menu hasn't been loaded yet.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_checkin/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getMenuBadgeData()

$model = $this->getModel('Checkin');

$amount = (int) count($model->getItems());
$amount = (int) \count($model->getItems());

echo new JsonResponse($amount);
}
Expand All @@ -110,7 +110,7 @@ public function getQuickiconContent()

$model = $this->getModel('Checkin');

$amount = (int) count($model->getItems());
$amount = (int) \count($model->getItems());

$result = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function checkin($ids = [])
{
$db = $this->getDatabase();

if (!is_array($ids)) {
if (!\is_array($ids)) {
return 0;
}

Expand Down Expand Up @@ -205,7 +205,7 @@ public function getItems()
}
}

$this->total = count($results);
$this->total = \count($results);

// Order items by table
if ($this->getState('list.ordering') == 'table') {
Expand All @@ -227,7 +227,7 @@ public function getItems()
$limit = (int) $this->getState('list.limit');

if ($limit !== 0) {
$this->items = array_slice($results, $this->getState('list.start'), $limit);
$this->items = \array_slice($results, $this->getState('list.start'), $limit);
} else {
$this->items = $results;
}
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_config/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
\defined('_JEXEC') or die;

use Joomla\CMS\Component\Router\RouterFactoryInterface;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function save()
$errors = $model->getErrors();

// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
for ($i = 0, $n = \count($errors); $i < $n && $i < 3; $i++) {
if ($errors[$i] instanceof \Exception) {
$this->app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function display($cachable = false, $urlparams = [])

// Make sure com_joomlaupdate and com_privacy can only be accessed by SuperUser
if (
in_array(strtolower($component), ['com_joomlaupdate', 'com_privacy'])
\in_array(strtolower($component), ['com_joomlaupdate', 'com_privacy'])
&& !$this->app->getIdentity()->authorise('core.admin')
) {
$this->setRedirect(Route::_('index.php'), Text::_('JERROR_ALERTNOAUTHOR'), 'error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Dispatcher extends ComponentDispatcher
protected function checkAccess(): void
{
// sendtestmail and store do their own checks, so leave the method to handle the permission and send response itself
if (in_array($this->input->getCmd('task'), ['application.sendtestmail', 'application.store'], true)) {
if (\in_array($this->input->getCmd('task'), ['application.sendtestmail', 'application.store'], true)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function canChangeComponentConfig(string $component)
{
$user = Factory::getApplication()->getIdentity();

if (!in_array(strtolower($component), ['com_joomlaupdate', 'com_privacy'], true)) {
if (!\in_array(strtolower($component), ['com_joomlaupdate', 'com_privacy'], true)) {
return $user->authorise('core.admin', $component) || $user->authorise('core.options', $component);
}

Expand Down
Loading

0 comments on commit d38a8ff

Please sign in to comment.