-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An option for checking explicit mixed
Eventually this will become level 9
- Loading branch information
1 parent
6a38951
commit da0b2eb
Showing
41 changed files
with
372 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type; | ||
|
||
use PHPStan\Reflection\ClassMemberAccessAnswerer; | ||
use PHPStan\Reflection\ConstantReflection; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Reflection\PropertyReflection; | ||
use PHPStan\TrinaryLogic; | ||
use PHPStan\Type\Generic\TemplateMixedType; | ||
use PHPStan\Type\Generic\TemplateTypeMap; | ||
use PHPStan\Type\Generic\TemplateTypeVariance; | ||
|
||
class StrictMixedType implements CompoundType | ||
{ | ||
|
||
public function getReferencedClasses(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function accepts(Type $type, bool $strictTypes): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function isAcceptedBy(Type $acceptingType, bool $strictTypes): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createFromBoolean( | ||
$acceptingType instanceof MixedType && !$acceptingType instanceof TemplateMixedType | ||
); | ||
} | ||
|
||
public function isSuperTypeOf(Type $type): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createFromBoolean($type instanceof self); | ||
} | ||
|
||
public function isSubTypeOf(Type $otherType): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createFromBoolean($otherType instanceof self); | ||
} | ||
|
||
public function equals(Type $type): bool | ||
{ | ||
return $type instanceof self; | ||
} | ||
|
||
public function describe(VerbosityLevel $level): string | ||
{ | ||
return 'mixed'; | ||
} | ||
|
||
public function canAccessProperties(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function hasProperty(string $propertyName): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function getProperty(string $propertyName, ClassMemberAccessAnswerer $scope): PropertyReflection | ||
{ | ||
throw new \PHPStan\ShouldNotHappenException(); | ||
} | ||
|
||
public function canCallMethods(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function hasMethod(string $methodName): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function getMethod(string $methodName, ClassMemberAccessAnswerer $scope): MethodReflection | ||
{ | ||
throw new \PHPStan\ShouldNotHappenException(); | ||
} | ||
|
||
public function canAccessConstants(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function hasConstant(string $constantName): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function getConstant(string $constantName): ConstantReflection | ||
{ | ||
throw new \PHPStan\ShouldNotHappenException(); | ||
} | ||
|
||
public function isIterable(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function isIterableAtLeastOnce(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function getIterableKeyType(): Type | ||
{ | ||
return $this; | ||
} | ||
|
||
public function getIterableValueType(): Type | ||
{ | ||
return $this; | ||
} | ||
|
||
public function isArray(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function isOffsetAccessible(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function hasOffsetValueType(Type $offsetType): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function getOffsetValueType(Type $offsetType): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function setOffsetValueType(?Type $offsetType, Type $valueType): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function isCallable(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function getCallableParametersAcceptors(ClassMemberAccessAnswerer $scope): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function isCloneable(): TrinaryLogic | ||
{ | ||
return TrinaryLogic::createNo(); | ||
} | ||
|
||
public function toBoolean(): BooleanType | ||
{ | ||
return new BooleanType(); | ||
} | ||
|
||
public function toNumber(): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function toInteger(): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function toFloat(): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function toString(): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function toArray(): Type | ||
{ | ||
return new ErrorType(); | ||
} | ||
|
||
public function inferTemplateTypes(Type $receivedType): TemplateTypeMap | ||
{ | ||
return TemplateTypeMap::createEmpty(); | ||
} | ||
|
||
public function getReferencedTemplateTypes(TemplateTypeVariance $positionVariance): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function traverse(callable $cb): Type | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param mixed[] $properties | ||
* @return Type | ||
*/ | ||
public static function __set_state(array $properties): Type | ||
{ | ||
return new self(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.