Skip to content

Commit 8f0e20d

Browse files
committed
refactor: rename parameter names
1 parent f347ea4 commit 8f0e20d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

system/Filters/Filters.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -545,23 +545,25 @@ public function getFiltersClass(): array
545545
* MUST be called prior to initialize();
546546
* Intended for use within routes files.
547547
*
548+
* @phpstan-param 'before'|'after' $position
549+
*
548550
* @return $this
549551
*/
550-
public function addFilter(string $class, ?string $alias = null, string $when = 'before', string $section = 'globals')
552+
public function addFilter(string $class, ?string $alias = null, string $position = 'before', string $section = 'globals')
551553
{
552554
$alias ??= md5($class);
553555

554556
if (! isset($this->config->{$section})) {
555557
$this->config->{$section} = [];
556558
}
557559

558-
if (! isset($this->config->{$section}[$when])) {
559-
$this->config->{$section}[$when] = [];
560+
if (! isset($this->config->{$section}[$position])) {
561+
$this->config->{$section}[$position] = [];
560562
}
561563

562564
$this->config->aliases[$alias] = $class;
563565

564-
$this->config->{$section}[$when][] = $alias;
566+
$this->config->{$section}[$position][] = $alias;
565567

566568
return $this;
567569
}
@@ -573,10 +575,11 @@ public function addFilter(string $class, ?string $alias = null, string $when = '
573575
* after the filter name, followed by a comma-separated list of arguments that
574576
* are passed to the filter when executed.
575577
*
576-
* @param string $name filter_name or filter_name:arguments like 'role:admin,manager'
577-
* or filter classname.
578+
* @param string $name filter_name or filter_name:arguments like 'role:admin,manager'
579+
* or filter classname.
580+
* @phpstan-param 'before'|'after' $position
578581
*/
579-
private function enableFilter(string $name, string $when = 'before'): void
582+
private function enableFilter(string $name, string $position = 'before'): void
580583
{
581584
// Normalize the arguments.
582585
[$alias, $arguments] = $this->getCleanName($name);
@@ -588,13 +591,13 @@ private function enableFilter(string $name, string $when = 'before'): void
588591
throw FilterException::forNoAlias($alias);
589592
}
590593

591-
if (! isset($this->filters[$when][$filter])) {
592-
$this->filters[$when][] = $filter;
594+
if (! isset($this->filters[$position][$filter])) {
595+
$this->filters[$position][] = $filter;
593596
}
594597

595598
// Since some filters like rate limiters rely on being executed once a request,
596599
// we filter em here.
597-
$this->filters[$when] = array_unique($this->filters[$when]);
600+
$this->filters[$position] = array_unique($this->filters[$position]);
598601
}
599602

600603
/**
@@ -816,6 +819,8 @@ protected function processFilters(?string $uri = null)
816819
/**
817820
* Maps filter aliases to the equivalent filter classes
818821
*
822+
* @phpstan-param 'before'|'after' $position
823+
*
819824
* @return void
820825
*
821826
* @throws FilterException

0 commit comments

Comments
 (0)