Skip to content

Commit

Permalink
native function invocation and trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil E. Taylor committed Dec 23, 2021
1 parent 0001586 commit cbec119
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function edit()
$errors = $model->getErrors();
$messages = [];

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)
{
Expand All @@ -153,7 +153,7 @@ public function edit()
$data = [
'params' => $validData,
'id' => ExtensionHelper::getExtensionRecord($option, 'component')->extension_id,
'option' => $option
'option' => $option,
];

if (!$model->save($data))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function displayList(array $items = null)

$offset = $currentPageQuery['offset'];
$limit = $currentPageQuery['limit'];
$totalItemsCount = count($items);
$totalItemsCount = \count($items);
$totalPagesAvailable = ceil($totalItemsCount / $limit);

$items = array_splice($items, $offset, $limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function displayList(array $items = null)

$offset = $currentPageQuery['offset'];
$limit = $currentPageQuery['limit'];
$totalItemsCount = count($items);
$totalItemsCount = \count($items);
$totalPagesAvailable = ceil($totalItemsCount / $limit);

$items = array_splice($items, $offset, $limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function submitForm($id = null)
$errors = $model->getErrors();
$messages = [];

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)
{
Expand Down Expand Up @@ -217,7 +217,7 @@ private function _sendEmail($data, $contact, $emailCopyToSender)
'subject' => $data['contact_subject'],
'body' => stripslashes($data['contact_message']),
'url' => Uri::base(),
'customfields' => ''
'customfields' => '',
];

// Load the custom fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class JsonapiView extends BaseApiView
*/
public function __construct($config = [])
{
if (array_key_exists('contentType', $config))
if (\array_key_exists('contentType', $config))
{
$this->serializer = new ContactSerializer($config['contentType']);
}
Expand Down
10 changes: 5 additions & 5 deletions api/components/com_content/src/Controller/ArticlesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@ public function displayList()
$apiFilterInfo = $this->input->get('filter', [], 'array');
$filter = InputFilter::getInstance();

if (array_key_exists('author', $apiFilterInfo))
if (\array_key_exists('author', $apiFilterInfo))
{
$this->modelState->set('filter.author_id', $filter->clean($apiFilterInfo['author'], 'INT'));
}

if (array_key_exists('category', $apiFilterInfo))
if (\array_key_exists('category', $apiFilterInfo))
{
$this->modelState->set('filter.category_id', $filter->clean($apiFilterInfo['category'], 'INT'));
}

if (array_key_exists('search', $apiFilterInfo))
if (\array_key_exists('search', $apiFilterInfo))
{
$this->modelState->set('filter.search', $filter->clean($apiFilterInfo['search'], 'STRING'));
}

if (array_key_exists('state', $apiFilterInfo))
if (\array_key_exists('state', $apiFilterInfo))
{
$this->modelState->set('filter.published', $filter->clean($apiFilterInfo['state'], 'INT'));
}

if (array_key_exists('language', $apiFilterInfo))
if (\array_key_exists('language', $apiFilterInfo))
{
$this->modelState->set('filter.language', $filter->clean($apiFilterInfo['language'], 'STRING'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class JsonapiView extends BaseApiView
*/
public function __construct($config = [])
{
if (array_key_exists('contentType', $config))
if (\array_key_exists('contentType', $config))
{
$this->serializer = new ContentSerializer($config['contentType']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function keep()

if (!$model->keep($cid))
{
throw new Exception\Save(Text::plural('COM_CONTENTHISTORY_N_ITEMS_KEEP_TOGGLE', count($cid)));
throw new Exception\Save(Text::plural('COM_CONTENTHISTORY_N_ITEMS_KEEP_TOGGLE', \count($cid)));
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ public function displayList()
{
$requestBool = $this->input->get('core', $this->input->get->get('core'));

if (!is_null($requestBool) && $requestBool !== 'true' && $requestBool !== 'false')
if (!\is_null($requestBool) && $requestBool !== 'true' && $requestBool !== 'false')
{
// Send the error response
$error = Text::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'core');

throw new InvalidParameterException($error, 400, null, 'core');
}

if (!is_null($requestBool))
if (!\is_null($requestBool))
{
$this->modelState->set('filter.core', ($requestBool === 'true') ? '1' : '0', 'STRING');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected function save($recordKey = null)
$errors = $model->getErrors();
$messages = [];

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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public function search()
{
$data = $this->input->get('data', json_decode($this->input->json->getRaw(), true), 'array');

if (!isset($data['searchstring']) || !is_string($data['searchstring']))
if (!isset($data['searchstring']) || !\is_string($data['searchstring']))
{
throw new InvalidParameterException("Invalid param 'searchstring'");
}

if (!isset($data['searchtype']) || !in_array($data['searchtype'], ['constant', 'value']))
if (!isset($data['searchtype']) || !\in_array($data['searchtype'], ['constant', 'value']))
{
throw new InvalidParameterException("Invalid param 'searchtype'");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function displayList(array $items = null)
}

// Check for errors.
if (count($errors = $this->get('Errors')))
if (\count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
Expand Down
4 changes: 2 additions & 2 deletions api/components/com_menus/src/View/Items/JsonapiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function displayListTypes()

$offset = $currentPageQuery['offset'];
$limit = $currentPageQuery['limit'];
$totalItemsCount = count($items);
$totalItemsCount = \count($items);
$totalPagesAvailable = ceil($totalItemsCount / $limit);

$items = array_splice($items, $offset, $limit);
Expand Down Expand Up @@ -199,7 +199,7 @@ public function displayListTypes()
*/
protected function prepareItem($item)
{
if (is_string($item->params))
if (\is_string($item->params))
{
$item->params = json_decode($item->params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class JsonapiView extends BaseApiView
*/
public function __construct($config = [])
{
if (array_key_exists('contentType', $config))
if (\array_key_exists('contentType', $config))
{
$this->serializer = new NewsfeedSerializer($config['contentType']);
}
Expand Down
10 changes: 5 additions & 5 deletions api/components/com_plugins/src/Controller/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function edit()

foreach ($data as $key => $value)
{
if (!in_array($key, ['enabled', 'access', 'ordering']))
if (!\in_array($key, ['enabled', 'access', 'ordering']))
{
throw new InvalidParameterException("Invalid parameter {$key}.", 400);
}
Expand Down Expand Up @@ -104,22 +104,22 @@ public function displayList()
$apiFilterInfo = $this->input->get('filter', [], 'array');
$filter = InputFilter::getInstance();

if (array_key_exists('element', $apiFilterInfo))
if (\array_key_exists('element', $apiFilterInfo))
{
$this->modelState->set('filter.element', $filter->clean($apiFilterInfo['element'], 'STRING'));
}

if (array_key_exists('status', $apiFilterInfo))
if (\array_key_exists('status', $apiFilterInfo))
{
$this->modelState->set('filter.enabled', $filter->clean($apiFilterInfo['status'], 'INT'));
}

if (array_key_exists('search', $apiFilterInfo))
if (\array_key_exists('search', $apiFilterInfo))
{
$this->modelState->set('filter.search', $filter->clean($apiFilterInfo['search'], 'STRING'));
}

if (array_key_exists('type', $apiFilterInfo))
if (\array_key_exists('type', $apiFilterInfo))
{
$this->modelState->set('filter.folder', $filter->clean($apiFilterInfo['type'], 'STRING'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function displayItem($item = null)
}

// Check for errors.
if (count($errors = $this->get('Errors')))
if (\count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function preprocessSaveData(array $data): array
// If we are updating an item the template is a readonly property based on the ID
if ($this->input->getMethod() === 'PATCH')
{
if (array_key_exists('template', $data))
if (\array_key_exists('template', $data))
{
throw new InvalidParameterException('The template property cannot be modified for an existing style');
}
Expand Down
24 changes: 12 additions & 12 deletions api/components/com_users/src/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,27 @@ public function displayList()
$apiFilterInfo = $this->input->get('filter', [], 'array');
$filter = InputFilter::getInstance();

if (array_key_exists('state', $apiFilterInfo))
if (\array_key_exists('state', $apiFilterInfo))
{
$this->modelState->set('filter.state', $filter->clean($apiFilterInfo['state'], 'INT'));
}

if (array_key_exists('active', $apiFilterInfo))
if (\array_key_exists('active', $apiFilterInfo))
{
$this->modelState->set('filter.active', $filter->clean($apiFilterInfo['active'], 'INT'));
}

if (array_key_exists('groupid', $apiFilterInfo))
if (\array_key_exists('groupid', $apiFilterInfo))
{
$this->modelState->set('filter.group_id', $filter->clean($apiFilterInfo['groupid'], 'INT'));
}

if (array_key_exists('search', $apiFilterInfo))
if (\array_key_exists('search', $apiFilterInfo))
{
$this->modelState->set('filter.search', $filter->clean($apiFilterInfo['search'], 'STRING'));
}

if (array_key_exists('registrationDateStart', $apiFilterInfo))
if (\array_key_exists('registrationDateStart', $apiFilterInfo))
{
$registrationStartInput = $filter->clean($apiFilterInfo['registrationDateStart'], 'STRING');
$registrationStartDate = Date::createFromFormat(\DateTimeInterface::RFC3339, $registrationStartInput);
Expand All @@ -115,7 +115,7 @@ public function displayList()
$this->modelState->set('filter.registrationDateStart', $registrationStartDate);
}

if (array_key_exists('registrationDateEnd', $apiFilterInfo))
if (\array_key_exists('registrationDateEnd', $apiFilterInfo))
{
$registrationEndInput = $filter->clean($apiFilterInfo['registrationDateEnd'], 'STRING');
$registrationEndDate = Date::createFromFormat(\DateTimeInterface::RFC3339, $registrationEndInput);
Expand All @@ -129,14 +129,14 @@ public function displayList()

$this->modelState->set('filter.registrationDateEnd', $registrationEndDate);
}
elseif (array_key_exists('registrationDateStart', $apiFilterInfo)
&& !array_key_exists('registrationDateEnd', $apiFilterInfo))
elseif (\array_key_exists('registrationDateStart', $apiFilterInfo)
&& !\array_key_exists('registrationDateEnd', $apiFilterInfo))
{
// If no end date specified the end date is now
$this->modelState->set('filter.registrationDateEnd', new Date);
}

if (array_key_exists('lastVisitDateStart', $apiFilterInfo))
if (\array_key_exists('lastVisitDateStart', $apiFilterInfo))
{
$lastVisitStartInput = $filter->clean($apiFilterInfo['lastVisitDateStart'], 'STRING');
$lastVisitStartDate = Date::createFromFormat(\DateTimeInterface::RFC3339, $lastVisitStartInput);
Expand All @@ -151,7 +151,7 @@ public function displayList()
$this->modelState->set('filter.lastVisitStart', $lastVisitStartDate);
}

if (array_key_exists('lastVisitDateEnd', $apiFilterInfo))
if (\array_key_exists('lastVisitDateEnd', $apiFilterInfo))
{
$lastVisitEndInput = $filter->clean($apiFilterInfo['lastVisitDateEnd'], 'STRING');
$lastVisitEndDate = Date::createFromFormat(\DateTimeInterface::RFC3339, $lastVisitEndInput);
Expand All @@ -166,8 +166,8 @@ public function displayList()

$this->modelState->set('filter.lastVisitEnd', $lastVisitEndDate);
}
elseif (array_key_exists('lastVisitDateStart', $apiFilterInfo)
&& !array_key_exists('lastVisitDateEnd', $apiFilterInfo))
elseif (\array_key_exists('lastVisitDateStart', $apiFilterInfo)
&& !\array_key_exists('lastVisitDateEnd', $apiFilterInfo))
{
// If no end date specified the end date is now
$this->modelState->set('filter.lastVisitEnd', new Date);
Expand Down
2 changes: 1 addition & 1 deletion api/includes/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
$errorHandler->setExceptionHandler(
[
new \Symfony\Component\ErrorHandler\ErrorHandler(null, true),
'renderException'
'renderException',
]
);
}
Expand Down

0 comments on commit cbec119

Please sign in to comment.