Skip to content

Commit

Permalink
#8200 - simplify ExistingAtomicStaticCallAnalyzer::hasStaticType()
Browse files Browse the repository at this point in the history
  • Loading branch information
someniatko committed Jul 12, 2022
1 parent ecbceb1 commit 931b3bb
Showing 1 changed file with 5 additions and 13 deletions.
Expand Up @@ -35,7 +35,6 @@
use Psalm\Type\Union;

use function array_map;
use function assert;
use function count;
use function explode;
use function in_array;
Expand Down Expand Up @@ -628,21 +627,14 @@ private static function getMethodReturnType(
*/
private static function hasStaticInType(Type\TypeNode $type): bool
{
assert($type instanceof Atomic || $type instanceof Union);
$union_parts = $type instanceof Union
? $type->getAtomicTypes()
: [ $type ];
if ($type instanceof TNamedObject && $type->value === 'static') {
return true;
}

foreach ($union_parts as $atomic_type) {
if ($atomic_type instanceof TNamedObject && $atomic_type->value === 'static') {
foreach ($type->getChildNodes() as $child_type) {
if (self::hasStaticInType($child_type)) {
return true;
}

foreach ($atomic_type->getChildNodes() as $child_type) {
if (self::hasStaticInType($child_type)) {
return true;
}
}
}

return false;
Expand Down

0 comments on commit 931b3bb

Please sign in to comment.