Skip to content

Commit

Permalink
Presenter::argsToParams() object parameters are required too (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 22, 2016
1 parent 44c5dbf commit ac2b988
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ public static function argsToParams($class, $method, & $args, $supplemental = []
}

if (!isset($args[$name])) {
if ($param->isDefaultValueAvailable() || $type === 'NULL' || $type === 'array' || $isClass) {
if ($param->isDefaultValueAvailable() || $type === 'NULL' || $type === 'array') {
continue;
}
throw new InvalidLinkException("Missing parameter \$$name required by $class::{$rm->getName()}()");
Expand Down
4 changes: 2 additions & 2 deletions tests/UI/Presenter.link().php7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ class TestPresenter extends Application\UI\Presenter
Assert::same('#error: Argument $arr passed to TestPresenter::actionDefaults() must be array, string given.', $this->link('defaults', ['int' => '1', 'bool' => '1', 'str' => '', 'arr' => '']));

Assert::same('/index.php?action=objects&presenter=Test', $this->link('objects', ['req' => new stdClass, 'opt' => new stdClass]));
Assert::same('/index.php?action=objects&presenter=Test', $this->link('objects', []));
Assert::same('/index.php?action=objects&presenter=Test', $this->link('objects', ['req' => NULL, 'opt' => NULL]));
Assert::same('#error: Missing parameter $req required by TestPresenter::actionObjects()', $this->link('objects', []));
Assert::same('#error: Missing parameter $req required by TestPresenter::actionObjects()', $this->link('objects', ['req' => NULL, 'opt' => NULL]));
Assert::same('#error: Argument $req passed to TestPresenter::actionObjects() must be stdClass, Exception given.', $this->link('objects', ['req' => new Exception, 'opt' => NULL]));
Assert::same('#error: Argument $req passed to TestPresenter::actionObjects() must be stdClass, array given.', $this->link('objects', ['req' => []]));

Expand Down
4 changes: 2 additions & 2 deletions tests/UI/Presenter.link().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ class TestPresenter extends Application\UI\Presenter
Assert::same('#error: Argument $arr passed to TestPresenter::actionDefaults() must be array, string given.', $this->link('defaults', ['int' => '1', 'bool' => '1', 'str' => '', 'arr' => '']));

Assert::same('/index.php?action=objects&presenter=Test', $this->link('objects', ['req' => new stdClass, 'opt' => new stdClass]));
Assert::same('/index.php?action=objects&presenter=Test', $this->link('objects', []));
Assert::same('/index.php?action=objects&presenter=Test', $this->link('objects', ['req' => NULL, 'opt' => NULL]));
Assert::same('#error: Missing parameter $req required by TestPresenter::actionObjects()', $this->link('objects', []));
Assert::same('#error: Missing parameter $req required by TestPresenter::actionObjects()', $this->link('objects', ['req' => NULL, 'opt' => NULL]));
Assert::same('#error: Argument $req passed to TestPresenter::actionObjects() must be stdClass, Exception given.', $this->link('objects', ['req' => new Exception, 'opt' => NULL]));
Assert::same('#error: Argument $req passed to TestPresenter::actionObjects() must be stdClass, array given.', $this->link('objects', ['req' => []]));

Expand Down

0 comments on commit ac2b988

Please sign in to comment.