Skip to content

Commit a9e3c52

Browse files
committed
PresenterComponentReflection::convertType() objects can be passed only to parameters without array or scalar type (without array / scalar default value) (BC break)
1 parent 692dfa1 commit a9e3c52

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Application/UI/PresenterComponentReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static function convertType(& $val, $type)
147147
settype($val, $type);
148148

149149
} elseif (is_object($val)) {
150-
// ignore
150+
return $type === 'NULL';
151151

152152
} elseif ($type === 'array') {
153153
return is_array($val);

tests/Application/Presenter.link().phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TestPresenter extends Application\UI\Presenter
118118
Assert::same("#error: Invalid value for parameter 'bool' in method TestPresenter::handlebuy(), expected boolean.", $this->link('buy!', 1, 2, 3));
119119
Assert::same("#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer.", $this->link('buy!', [[]]));
120120
Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!'));
121-
Assert::same('/index.php?action=default&do=buy&presenter=Test', $this->link('buy!', [new stdClass]));
121+
Assert::same("#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer.", $this->link('buy!', [new stdClass]));
122122

123123
Assert::same('/index.php?a=x&action=default&do=obj&presenter=Test', $this->link('obj!', ['x']));
124124
Assert::same('/index.php?action=default&do=obj&presenter=Test', $this->link('obj!', [new stdClass]));

tests/Application/PresenterComponentReflection.convertType.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require __DIR__ . '/../bootstrap.php';
1616
// null (not used) pass cast cast error error
1717
// scalar pass cast/deny deny error error
1818
// array deny deny pass deny deny
19-
// object pass pass error pass/error pass/error
19+
// object pass deny error pass/error pass/error
2020
//
2121
// error = E_RECOVERABLE_ERROR * = only as native typehint
2222

@@ -36,7 +36,7 @@ $obj = new stdClass;
3636

3737
testIt('string', NULL, '');
3838
testIt('string', []);
39-
testIt('string', $obj, $obj);
39+
testIt('string', $obj);
4040
testIt('string', '', '');
4141
testIt('string', 'a', 'a');
4242
testIt('string', '0', '0');
@@ -53,7 +53,7 @@ testIt('string', 1.2, '1.2');
5353

5454
testIt('int', NULL, 0);
5555
testIt('int', []);
56-
testIt('int', $obj, $obj);
56+
testIt('int', $obj);
5757
testIt('int', '');
5858
testIt('int', 'a');
5959
testIt('int', '0', 0);
@@ -70,7 +70,7 @@ testIt('int', 1.2);
7070

7171
testIt('double', NULL, 0.0);
7272
testIt('double', []);
73-
testIt('double', $obj, $obj);
73+
testIt('double', $obj);
7474
testIt('double', '');
7575
testIt('double', 'a');
7676
testIt('double', '0', 0.0);
@@ -87,7 +87,7 @@ testIt('double', 1.2, 1.2);
8787

8888
testIt('bool', NULL, FALSE);
8989
testIt('bool', []);
90-
testIt('bool', $obj, $obj);
90+
testIt('bool', $obj);
9191
testIt('bool', '');
9292
testIt('bool', 'a');
9393
testIt('bool', '1', TRUE);
@@ -103,7 +103,7 @@ testIt('bool', 1.2);
103103

104104
testIt('array', NULL, []);
105105
testIt('array', [], []);
106-
testIt('array', $obj, $obj);
106+
testIt('array', $obj);
107107
testIt('array', '');
108108
testIt('array', 'a');
109109
testIt('array', '1');

0 commit comments

Comments
 (0)