Skip to content

Commit

Permalink
refactor: rename variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 18, 2023
1 parent a54095b commit daa1e97
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions system/Filters/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,22 +288,22 @@ public function runRequired(string $position = 'before')
$this->config->required['after'][] = 'toolbar';
}

$filtersClass = [];
$filterClasses = [];

foreach ($this->config->required[$position] as $alias) {
if (! array_key_exists($alias, $this->config->aliases)) {
throw FilterException::forNoAlias($alias);
}

if (is_array($this->config->aliases[$alias])) {
$filtersClass[$position] = array_merge($filtersClass[$position], $this->config->aliases[$alias]);
$filterClasses[$position] = array_merge($filterClasses[$position], $this->config->aliases[$alias]);
} else {
$filtersClass[$position][] = $this->config->aliases[$alias];
$filterClasses[$position][] = $this->config->aliases[$alias];
}
}

if ($position === 'before') {
$result = $this->runBefore($filtersClass);
$result = $this->runBefore($filterClasses);

// If the response object was sent back,
// then send it and quit.
Expand All @@ -316,7 +316,7 @@ public function runRequired(string $position = 'before')
}

if ($position === 'after') {
$result = $this->runAfter($filtersClass);
$result = $this->runAfter($filterClasses);
}

return $result;

Check failure on line 322 in system/Filters/Filters.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Variable $result might not be defined.
Expand Down Expand Up @@ -705,7 +705,7 @@ private function registerArguments(string $name, array $arguments, bool $check =
*/
protected function processAliasesToClass(string $position)
{
$filtersClass = [];
$filterClasses = [];

foreach ($this->filters[$position] as $alias => $rules) {
if (is_numeric($alias) && is_string($rules)) {
Expand All @@ -717,18 +717,18 @@ protected function processAliasesToClass(string $position)
}

if (is_array($this->config->aliases[$alias])) {
$filtersClass = array_merge($filtersClass, $this->config->aliases[$alias]);
$filterClasses = array_merge($filterClasses, $this->config->aliases[$alias]);
} else {
$filtersClass[] = $this->config->aliases[$alias];
$filterClasses[] = $this->config->aliases[$alias];
}
}

// when using enableFilter() we already write the class name in $filtersClass as well as the
// when using enableFilter() we already write the class name in $filterClasses as well as the
// alias in $filters. This leads to duplicates when using route filters.
if ($position === 'before') {
$this->filtersClass[$position] = array_merge($filtersClass, $this->filtersClass[$position]);
$this->filtersClass[$position] = array_merge($filterClasses, $this->filtersClass[$position]);
} else {
$this->filtersClass[$position] = array_merge($this->filtersClass[$position], $filtersClass);
$this->filtersClass[$position] = array_merge($this->filtersClass[$position], $filterClasses);
}

// Since some filters like rate limiters rely on being executed once a request we filter em here.
Expand Down

0 comments on commit daa1e97

Please sign in to comment.