Skip to content

Commit

Permalink
Presenter: added support for typehint 'object'
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 20, 2020
1 parent 3f51018 commit 0741bea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Application/UI/ComponentReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ public static function convertType(&$val, string $type): bool
if (empty($builtin[$type])) {
return $val instanceof $type;

} elseif ($type === 'object') {
return is_object($val);

} elseif ($type === 'callable') {
return false;

Expand Down
17 changes: 17 additions & 0 deletions tests/UI/ComponentReflection.convertType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,23 @@ testIt('callable', 1);
testIt('callable', 1.0);
testIt('callable', 1.2);

testIt('object', null);
testIt('object', []);
testIt('object', $obj, $obj);
testIt('object', $var = function () {}, $var);
testIt('object', '');
testIt('object', 'a');
testIt('object', '1');
testIt('object', '1.0');
testIt('object', '1.1');
testIt('object', '1a');
testIt('object', true);
testIt('object', false);
testIt('object', 0);
testIt('object', 1);
testIt('object', 1.0);
testIt('object', 1.2);

testIt('stdClass', null);
testIt('stdClass', []);
testIt('stdClass', $obj, $obj);
Expand Down

0 comments on commit 0741bea

Please sign in to comment.