@@ -545,23 +545,25 @@ public function getFiltersClass(): array
545
545
* MUST be called prior to initialize();
546
546
* Intended for use within routes files.
547
547
*
548
+ * @phpstan-param 'before'|'after' $position
549
+ *
548
550
* @return $this
549
551
*/
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 ' )
551
553
{
552
554
$ alias ??= md5 ($ class );
553
555
554
556
if (! isset ($ this ->config ->{$ section })) {
555
557
$ this ->config ->{$ section } = [];
556
558
}
557
559
558
- if (! isset ($ this ->config ->{$ section }[$ when ])) {
559
- $ this ->config ->{$ section }[$ when ] = [];
560
+ if (! isset ($ this ->config ->{$ section }[$ position ])) {
561
+ $ this ->config ->{$ section }[$ position ] = [];
560
562
}
561
563
562
564
$ this ->config ->aliases [$ alias ] = $ class ;
563
565
564
- $ this ->config ->{$ section }[$ when ][] = $ alias ;
566
+ $ this ->config ->{$ section }[$ position ][] = $ alias ;
565
567
566
568
return $ this ;
567
569
}
@@ -573,10 +575,11 @@ public function addFilter(string $class, ?string $alias = null, string $when = '
573
575
* after the filter name, followed by a comma-separated list of arguments that
574
576
* are passed to the filter when executed.
575
577
*
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
578
581
*/
579
- private function enableFilter (string $ name , string $ when = 'before ' ): void
582
+ private function enableFilter (string $ name , string $ position = 'before ' ): void
580
583
{
581
584
// Normalize the arguments.
582
585
[$ alias , $ arguments ] = $ this ->getCleanName ($ name );
@@ -588,13 +591,13 @@ private function enableFilter(string $name, string $when = 'before'): void
588
591
throw FilterException::forNoAlias ($ alias );
589
592
}
590
593
591
- if (! isset ($ this ->filters [$ when ][$ filter ])) {
592
- $ this ->filters [$ when ][] = $ filter ;
594
+ if (! isset ($ this ->filters [$ position ][$ filter ])) {
595
+ $ this ->filters [$ position ][] = $ filter ;
593
596
}
594
597
595
598
// Since some filters like rate limiters rely on being executed once a request,
596
599
// we filter em here.
597
- $ this ->filters [$ when ] = array_unique ($ this ->filters [$ when ]);
600
+ $ this ->filters [$ position ] = array_unique ($ this ->filters [$ position ]);
598
601
}
599
602
600
603
/**
@@ -816,6 +819,8 @@ protected function processFilters(?string $uri = null)
816
819
/**
817
820
* Maps filter aliases to the equivalent filter classes
818
821
*
822
+ * @phpstan-param 'before'|'after' $position
823
+ *
819
824
* @return void
820
825
*
821
826
* @throws FilterException
0 commit comments