Skip to content

Commit

Permalink
Get rid of last instanceof in extension
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Jan 4, 2025
1 parent 4556931 commit 75e06bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1467,12 +1467,6 @@ parameters:
count: 1
path: src/Type/Php/ArrayKeyExistsFunctionTypeSpecifyingExtension.php

-
message: '#^Doing instanceof PHPStan\\Type\\Constant\\ConstantArrayType is error\-prone and deprecated\. Use Type\:\:getConstantArrays\(\) instead\.$#'
identifier: phpstanApi.instanceofType
count: 1
path: src/Type/Php/ArrayMergeFunctionDynamicReturnTypeExtension.php

-
message: '#^Doing instanceof PHPStan\\Type\\Constant\\ConstantBooleanType is error\-prone and deprecated\. Use Type\:\:isTrue\(\) or Type\:\:isFalse\(\) instead\.$#'
identifier: phpstanApi.instanceofType
Expand Down
9 changes: 7 additions & 2 deletions src/Type/Php/ArrayMergeFunctionDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
$argType = $scope->getType($arg->value);

if ($arg->unpack) {
if ($argType instanceof ConstantArrayType) {
$argTypesFound = $argType->getValueTypes();
if ($argType->isConstantArray()->yes()) {
$argTypesFound = [];
foreach ($argType->getConstantArrays() as $constantArray) {
foreach ($constantArray->getValueTypes() as $valueType) {
$argTypesFound[] = $valueType;
}
}
} else {
$argTypesFound = [$argType->getIterableValueType()];
}
Expand Down

0 comments on commit 75e06bd

Please sign in to comment.