Skip to content

Commit 3fe619f

Browse files
committed
PresenterComponentReflection::convertType() NULLs are not allowed
1 parent 05259e7 commit 3fe619f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/Application/UI/PresenterComponentReflection.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,10 @@ public static function convertType(& $val, $type, $isClass = FALSE)
166166
} elseif ($type === 'NULL') { // means 'not array'
167167
return !is_array($val);
168168

169-
} elseif ($val === NULL) {
170-
settype($val, $type); // to scalar or array
171-
172169
} elseif ($type === 'array') {
173170
return is_array($val);
174171

175-
} elseif (!is_scalar($val)) { // array, resource, etc.
172+
} elseif (!is_scalar($val)) { // array, resource, NULL, etc.
176173
return FALSE;
177174

178175
} else {

tests/UI/PresenterComponentReflection.convertType.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require __DIR__ . '/../bootstrap.php';
1313

1414
// [$type] null scalar array object callable
1515
// [$val] ----------------------------------------------------------
16-
// null pass cast cast deny deny
16+
// null pass deny deny deny deny
1717
// scalar pass cast/deny deny deny deny
1818
// array deny deny pass deny deny
1919
// object pass deny deny pass/deny deny
@@ -50,7 +50,7 @@ testIt('NULL', 1, 1);
5050
testIt('NULL', 1.0, 1.0);
5151
testIt('NULL', 1.2, 1.2);
5252

53-
testIt('string', NULL, '');
53+
testIt('string', NULL);
5454
testIt('string', []);
5555
testIt('string', $obj);
5656
testIt('string', '', '');
@@ -67,7 +67,7 @@ testIt('string', 1, '1');
6767
testIt('string', 1.0, '1');
6868
testIt('string', 1.2, '1.2');
6969

70-
testIt('int', NULL, 0);
70+
testIt('int', NULL);
7171
testIt('int', []);
7272
testIt('int', $obj);
7373
testIt('int', '');
@@ -84,7 +84,7 @@ testIt('int', 1, 1);
8484
testIt('int', 1.0, 1);
8585
testIt('int', 1.2);
8686

87-
testIt('double', NULL, 0.0);
87+
testIt('double', NULL);
8888
testIt('double', []);
8989
testIt('double', $obj);
9090
testIt('double', '');
@@ -101,7 +101,7 @@ testIt('double', 1, 1.0);
101101
testIt('double', 1.0, 1.0);
102102
testIt('double', 1.2, 1.2);
103103

104-
testIt('bool', NULL, FALSE);
104+
testIt('bool', NULL);
105105
testIt('bool', []);
106106
testIt('bool', $obj);
107107
testIt('bool', '');
@@ -117,7 +117,7 @@ testIt('bool', 1, TRUE);
117117
testIt('bool', 1.0, TRUE);
118118
testIt('bool', 1.2);
119119

120-
testIt('array', NULL, []);
120+
testIt('array', NULL);
121121
testIt('array', [], []);
122122
testIt('array', $obj);
123123
testIt('array', '');

0 commit comments

Comments
 (0)