Skip to content

Commit

Permalink
Another micro optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 26, 2024
1 parent 537c12c commit c04555b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Rules/RuleLevelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use PHPStan\Type\MixedType;
use PHPStan\Type\NeverType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\ObjectWithoutClassType;
use PHPStan\Type\StaticType;
use PHPStan\Type\StrictMixedType;
Expand Down Expand Up @@ -497,7 +498,15 @@ private function findTypeToCheckImplementation(
}

$tip = null;
if (str_contains($type->describe(VerbosityLevel::typeOnly()), 'PhpParser\\Node\\Arg|PhpParser\\Node\\VariadicPlaceholder') && !$unionTypeCriteriaCallback($type)) {
if (
$type instanceof UnionType
&& count($type->getTypes()) === 2
&& $type->getTypes()[0] instanceof ObjectType
&& $type->getTypes()[1] instanceof ObjectType
&& $type->getTypes()[0]->getClassName() === 'PhpParser\\Node\\Arg'
&& $type->getTypes()[1]->getClassName() === 'PhpParser\\Node\\VariadicPlaceholder'
&& !$unionTypeCriteriaCallback($type)
) {
$tip = 'Use <fg=cyan>->getArgs()</> instead of <fg=cyan>->args</>.';
}

Expand Down

0 comments on commit c04555b

Please sign in to comment.