Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Type/BooleanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Type\Constant\ConstantFloatType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonCallableTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
Expand All @@ -21,6 +22,7 @@ class BooleanType implements Type
{

use JustNullableTypeTrait;
use NonArrayTypeTrait;
use NonCallableTypeTrait;
use NonIterableTypeTrait;
use NonObjectTypeTrait;
Expand Down
12 changes: 2 additions & 10 deletions src/Type/ClosureType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
use PHPStan\Type\Traits\NonIterableTypeTrait;
use PHPStan\Type\Traits\NonOffsetAccessibleTypeTrait;
use PHPStan\Type\Traits\NonRemoveableTypeTrait;
use PHPStan\Type\Traits\UndecidedComparisonTypeTrait;
Expand All @@ -39,6 +40,7 @@ class ClosureType implements TypeWithClassName, ParametersAcceptor

use NonArrayTypeTrait;
use NonGenericTypeTrait;
use NonIterableTypeTrait;
use UndecidedComparisonTypeTrait;
use NonOffsetAccessibleTypeTrait;
use NonRemoveableTypeTrait;
Expand Down Expand Up @@ -238,16 +240,6 @@ public function isIterableAtLeastOnce(): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getIterableKeyType(): Type
{
return new ErrorType();
}

public function getIterableValueType(): Type
{
return new ErrorType();
}

public function isCallable(): TrinaryLogic
{
return TrinaryLogic::createYes();
Expand Down
2 changes: 2 additions & 0 deletions src/Type/IntegerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPStan\Type\Accessory\AccessoryNumericStringType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonCallableTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
Expand All @@ -19,6 +20,7 @@ class IntegerType implements Type
{

use JustNullableTypeTrait;
use NonArrayTypeTrait;
use NonCallableTypeTrait;
use NonIterableTypeTrait;
use NonObjectTypeTrait;
Expand Down
20 changes: 20 additions & 0 deletions src/Type/IterableType.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,31 @@ public function getIterableKeyType(): Type
return $this->keyType;
}

public function getFirstIterableKeyType(): Type
{
return $this->keyType;
}

public function getLastIterableKeyType(): Type
{
return $this->keyType;
}

public function getIterableValueType(): Type
{
return $this->getItemType();
}

public function getFirstIterableValueType(): Type
{
return $this->getItemType();
}

public function getLastIterableValueType(): Type
{
return $this->getItemType();
}

public function isString(): TrinaryLogic
{
return TrinaryLogic::createNo();
Expand Down
3 changes: 0 additions & 3 deletions src/Type/JustNullableTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
namespace PHPStan\Type;

use PHPStan\TrinaryLogic;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use function get_class;

trait JustNullableTypeTrait
{

use NonArrayTypeTrait;

/**
* @return string[]
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Type/NeverType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
use PHPStan\Type\Traits\NonIterableTypeTrait;
use PHPStan\Type\Traits\NonRemoveableTypeTrait;
use PHPStan\Type\Traits\UndecidedBooleanTypeTrait;
use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait;
Expand All @@ -26,6 +27,7 @@ class NeverType implements CompoundType
use UndecidedBooleanTypeTrait;
use NonArrayTypeTrait;
use NonGenericTypeTrait;
use NonIterableTypeTrait;
use UndecidedComparisonCompoundTypeTrait;
use NonRemoveableTypeTrait;
use NonGeneralizableTypeTrait;
Expand Down
2 changes: 2 additions & 0 deletions src/Type/NonexistentParentClassType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPStan\Reflection\Type\UnresolvedPropertyPrototypeReflection;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonCallableTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
Expand All @@ -23,6 +24,7 @@ class NonexistentParentClassType implements Type
{

use JustNullableTypeTrait;
use NonArrayTypeTrait;
use NonCallableTypeTrait;
use NonIterableTypeTrait;
use NonOffsetAccessibleTypeTrait;
Expand Down
22 changes: 22 additions & 0 deletions src/Type/ObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\Enum\EnumCaseObjectType;
use PHPStan\Type\Generic\GenericObjectType;
use PHPStan\Type\Traits\MaybeIterableTypeTrait;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
Expand All @@ -53,6 +54,7 @@
class ObjectType implements TypeWithClassName, SubtractableType
{

use MaybeIterableTypeTrait;
use NonArrayTypeTrait;
use NonGenericTypeTrait;
use UndecidedComparisonTypeTrait;
Expand Down Expand Up @@ -753,6 +755,16 @@ public function getIterableKeyType(): Type
return new ErrorType();
}

public function getFirstIterableKeyType(): Type
{
return $this->getIterableKeyType();
}

public function getLastIterableKeyType(): Type
{
return $this->getIterableKeyType();
}

public function getIterableValueType(): Type
{
$isTraversable = false;
Expand Down Expand Up @@ -794,6 +806,16 @@ public function getIterableValueType(): Type
return new ErrorType();
}

public function getFirstIterableValueType(): Type
{
return $this->getIterableValueType();
}

public function getLastIterableValueType(): Type
{
return $this->getIterableValueType();
}

public function isString(): TrinaryLogic
{
return TrinaryLogic::createNo();
Expand Down
2 changes: 2 additions & 0 deletions src/Type/ResourceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonCallableTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
Expand All @@ -19,6 +20,7 @@ class ResourceType implements Type
{

use JustNullableTypeTrait;
use NonArrayTypeTrait;
use NonCallableTypeTrait;
use NonIterableTypeTrait;
use NonObjectTypeTrait;
Expand Down
2 changes: 2 additions & 0 deletions src/Type/StrictMixedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPStan\Type\Generic\TemplateTypeVariance;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonIterableTypeTrait;
use PHPStan\Type\Traits\NonRemoveableTypeTrait;
use PHPStan\Type\Traits\UndecidedComparisonCompoundTypeTrait;

Expand All @@ -23,6 +24,7 @@ class StrictMixedType implements CompoundType

use UndecidedComparisonCompoundTypeTrait;
use NonArrayTypeTrait;
use NonIterableTypeTrait;
use NonRemoveableTypeTrait;
use NonGeneralizableTypeTrait;

Expand Down
2 changes: 2 additions & 0 deletions src/Type/StringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\Traits\MaybeCallableTypeTrait;
use PHPStan\Type\Traits\NonArrayTypeTrait;
use PHPStan\Type\Traits\NonGeneralizableTypeTrait;
use PHPStan\Type\Traits\NonGenericTypeTrait;
use PHPStan\Type\Traits\NonIterableTypeTrait;
Expand All @@ -22,6 +23,7 @@ class StringType implements Type

use JustNullableTypeTrait;
use MaybeCallableTypeTrait;
use NonArrayTypeTrait;
use NonIterableTypeTrait;
use NonObjectTypeTrait;
use UndecidedBooleanTypeTrait;
Expand Down
22 changes: 0 additions & 22 deletions src/Type/Traits/MaybeArrayTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace PHPStan\Type\Traits;

use PHPStan\TrinaryLogic;
use PHPStan\Type\MixedType;
use PHPStan\Type\Type;

trait MaybeArrayTypeTrait
{
Expand All @@ -19,26 +17,6 @@ public function getConstantArrays(): array
return [];
}

public function getFirstIterableKeyType(): Type
{
return new MixedType();
}

public function getLastIterableKeyType(): Type
{
return new MixedType();
}

public function getFirstIterableValueType(): Type
{
return new MixedType();
}

public function getLastIterableValueType(): Type
{
return new MixedType();
}

public function isArray(): TrinaryLogic
{
return TrinaryLogic::createMaybe();
Expand Down
20 changes: 20 additions & 0 deletions src/Type/Traits/MaybeIterableTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,29 @@ public function getIterableKeyType(): Type
return new MixedType();
}

public function getFirstIterableKeyType(): Type
{
return new MixedType();
}

public function getLastIterableKeyType(): Type
{
return new MixedType();
}

public function getIterableValueType(): Type
{
return new MixedType();
}

public function getFirstIterableValueType(): Type
{
return new MixedType();
}

public function getLastIterableValueType(): Type
{
return new MixedType();
}

}
22 changes: 0 additions & 22 deletions src/Type/Traits/NonArrayTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace PHPStan\Type\Traits;

use PHPStan\TrinaryLogic;
use PHPStan\Type\ErrorType;
use PHPStan\Type\Type;

trait NonArrayTypeTrait
{
Expand All @@ -19,26 +17,6 @@ public function getConstantArrays(): array
return [];
}

public function getFirstIterableKeyType(): Type
{
return new ErrorType();
}

public function getLastIterableKeyType(): Type
{
return new ErrorType();
}

public function getFirstIterableValueType(): Type
{
return new ErrorType();
}

public function getLastIterableValueType(): Type
{
return new ErrorType();
}

public function isArray(): TrinaryLogic
{
return TrinaryLogic::createNo();
Expand Down
20 changes: 20 additions & 0 deletions src/Type/Traits/NonIterableTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,29 @@ public function getIterableKeyType(): Type
return new ErrorType();
}

public function getFirstIterableKeyType(): Type
{
return new ErrorType();
}

public function getLastIterableKeyType(): Type
{
return new ErrorType();
}

public function getIterableValueType(): Type
{
return new ErrorType();
}

public function getFirstIterableValueType(): Type
{
return new ErrorType();
}

public function getLastIterableValueType(): Type
{
return new ErrorType();
}

}