Skip to content

Commit 59a06d2

Browse files
committed
Return given filter from install()
1 parent 7ae10bc commit 59a06d2

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/main/php/web/Application.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public abstract function routes();
6262
* Installs global filters
6363
*
6464
* @param web.Filter|function(web.Request, web.Response, web.filters.Invocation): var|web.Filter[] $arg
65-
* @return void
65+
* @return web.Filter|function(web.Request, web.Response, web.filters.Invocation): var|web.Filter[]
6666
*/
6767
public function install($arg) {
6868
if ($arg instanceof Filter || $arg instanceof Closure) {
@@ -72,6 +72,7 @@ public function install($arg) {
7272
$this->filters[]= $filter;
7373
}
7474
}
75+
return $arg;
7576
}
7677

7778
/**

src/test/php/web/unittest/ApplicationTest.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ public function does_not_equal_clone() {
290290
Assert::equals(1, $app->compareTo(clone $app));
291291
}
292292

293+
#[Test, Values(from: 'filters')]
294+
public function install($install) {
295+
$app= new class($this->environment) extends Application {
296+
public function routes() { /* Implementation irrelevant for this test */ }
297+
};
298+
Assert::equals($install, $app->install($install));
299+
}
300+
293301
#[Test, Values(from: 'filters')]
294302
public function install_filter($install) {
295303
list($request, $response)= $this->handle(function() use($install) {

0 commit comments

Comments
 (0)