Skip to content

Commit 18f376d

Browse files
committed
PresenterComponentReflection::convertType() NULLs are not allowed
1 parent ac2b988 commit 18f376d

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 deny 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
@@ -33,7 +33,7 @@ function testIt($type, $val, $res = NULL)
3333

3434
$obj = new stdClass;
3535

36-
testIt('string', NULL, '');
36+
testIt('string', NULL);
3737
testIt('string', []);
3838
testIt('string', $obj);
3939
testIt('string', '', '');
@@ -50,7 +50,7 @@ testIt('string', 1, '1');
5050
testIt('string', 1.0, '1');
5151
testIt('string', 1.2, '1.2');
5252

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

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

87-
testIt('bool', NULL, FALSE);
87+
testIt('bool', NULL);
8888
testIt('bool', []);
8989
testIt('bool', $obj);
9090
testIt('bool', '');
@@ -100,7 +100,7 @@ testIt('bool', 1, TRUE);
100100
testIt('bool', 1.0, TRUE);
101101
testIt('bool', 1.2);
102102

103-
testIt('array', NULL, []);
103+
testIt('array', NULL);
104104
testIt('array', [], []);
105105
testIt('array', $obj);
106106
testIt('array', '');

0 commit comments

Comments
 (0)