Skip to content

Commit 0741bea

Browse files
committed
Presenter: added support for typehint 'object'
1 parent 3f51018 commit 0741bea

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Application/UI/ComponentReflection.php

+3
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ public static function convertType(&$val, string $type): bool
198198
if (empty($builtin[$type])) {
199199
return $val instanceof $type;
200200

201+
} elseif ($type === 'object') {
202+
return is_object($val);
203+
201204
} elseif ($type === 'callable') {
202205
return false;
203206

tests/UI/ComponentReflection.convertType.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@ testIt('callable', 1);
192192
testIt('callable', 1.0);
193193
testIt('callable', 1.2);
194194

195+
testIt('object', null);
196+
testIt('object', []);
197+
testIt('object', $obj, $obj);
198+
testIt('object', $var = function () {}, $var);
199+
testIt('object', '');
200+
testIt('object', 'a');
201+
testIt('object', '1');
202+
testIt('object', '1.0');
203+
testIt('object', '1.1');
204+
testIt('object', '1a');
205+
testIt('object', true);
206+
testIt('object', false);
207+
testIt('object', 0);
208+
testIt('object', 1);
209+
testIt('object', 1.0);
210+
testIt('object', 1.2);
211+
195212
testIt('stdClass', null);
196213
testIt('stdClass', []);
197214
testIt('stdClass', $obj, $obj);

0 commit comments

Comments
 (0)