mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
da70700f98
ce32685688
[PHPStan] Reduce PHPStan errors for narrow public - take 2 (#2673)
28 lines
891 B
PHP
28 lines
891 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\DeadCode\TypeNodeAnalyzer;
|
|
|
|
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
|
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
|
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
|
final class MixedArrayTypeNodeAnalyzer
|
|
{
|
|
public function hasMixedArrayType(BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool
|
|
{
|
|
$types = $bracketsAwareUnionTypeNode->types;
|
|
foreach ($types as $type) {
|
|
if ($type instanceof SpacingAwareArrayTypeNode) {
|
|
$typeNode = $type->type;
|
|
if (!$typeNode instanceof IdentifierTypeNode) {
|
|
continue;
|
|
}
|
|
if ($typeNode->name === 'mixed') {
|
|
return \true;
|
|
}
|
|
}
|
|
}
|
|
return \false;
|
|
}
|
|
}
|