Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Update Container.php
Browse files Browse the repository at this point in the history
- add support for php7.4
  • Loading branch information
vvval committed Mar 12, 2020
1 parent 673ba66 commit ddf48b8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/Spiral/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,18 @@ private function assertType(
}

$type = $parameter->getType();
$typeName = method_exists($type, 'getName') ? $type->getName() : (string)$type;

if ($type == 'array' && !is_array($value)) {
if ($typeName == 'array' && !is_array($value)) {
throw new ArgumentException($parameter, $context);
}

if (($type == 'int' || $type == 'float') && !is_numeric($value)) {
if (($typeName == 'int' || $typeName == 'float') && !is_numeric($value)) {
throw new ArgumentException($parameter, $context);
}

if ($type == 'bool' && !is_bool($value) && !is_numeric($value)) {
if ($typeName == 'bool' && !is_bool($value) && !is_numeric($value)) {
throw new ArgumentException($parameter, $context);
}
}
}
}

0 comments on commit ddf48b8

Please sign in to comment.