mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 00:25:04 +00:00
Update to PHPStan 2.x
This commit is contained in:
@ -30,7 +30,6 @@ use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Rules\Rule;
|
||||
use PHPStan\Rules\RuleErrorBuilder;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\UnionType;
|
||||
use PHPStan\Type\VerbosityLevel;
|
||||
@ -61,7 +60,7 @@ class DisallowEnumComparisonRule implements Rule{
|
||||
$node instanceof Identical ? '===' : '!==',
|
||||
$leftType->describe(VerbosityLevel::value()),
|
||||
$rightType->describe(VerbosityLevel::value())
|
||||
))->build()];
|
||||
))->identifier('pocketmine.enum.badComparison')->build()];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
@ -69,7 +68,7 @@ class DisallowEnumComparisonRule implements Rule{
|
||||
private function checkForEnumTypes(Type $comparedType) : bool{
|
||||
//TODO: what we really want to do here is iterate over the contained types, but there's no universal way to
|
||||
//do that. This might break with other circumstances.
|
||||
if($comparedType instanceof ObjectType){
|
||||
if($comparedType->isObject()->yes()){
|
||||
$types = [$comparedType];
|
||||
}elseif($comparedType instanceof UnionType){
|
||||
$types = $comparedType->getTypes();
|
||||
@ -77,12 +76,14 @@ class DisallowEnumComparisonRule implements Rule{
|
||||
return false;
|
||||
}
|
||||
foreach($types as $containedType){
|
||||
if(!($containedType instanceof ObjectType)){
|
||||
if(!($containedType->isObject()->yes())){
|
||||
continue;
|
||||
}
|
||||
$class = $containedType->getClassReflection();
|
||||
if($class !== null && $class->hasTraitUse(EnumTrait::class)){
|
||||
return true;
|
||||
$classes = $containedType->getObjectClassReflections();
|
||||
foreach($classes as $class){
|
||||
if($class->hasTraitUse(EnumTrait::class)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user