Skip to content

Commit

Permalink
fix: add null safe
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuftaufiq committed Apr 21, 2022
1 parent 6715f76 commit 396a718
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Casts/AbstractMethodCallNodeCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ public function isArgumentsTypeExpressionArray(array $args): bool
*/
protected function castScalarStringArguments(array $args): ?PropertyTagDto
{
if (array_key_exists(static::$classParameterPosition, $args) === false) {
if (
array_key_exists(static::$classParameterPosition, $args) === false
|| $args[static::$classParameterPosition]->value instanceof String_ === false
) {
return null;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Casts/LoadLibraryNodeCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ protected function castExpressionArrayItem(ArrayItem $item): ?PropertyTagDto
*/
protected function castExpressionArrayArguments(array $args): array
{
if (array_key_exists(static::$classParameterPosition, $args) === false) {
if (
array_key_exists(static::$classParameterPosition, $args) === false
|| $args[static::$classParameterPosition]->value instanceof String_ === false
) {
return [];
}

Expand Down

0 comments on commit 396a718

Please sign in to comment.