Skip to content

Commit

Permalink
use TrinaryLogic over bool
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 19, 2025
1 parent 507727d commit 61d8f3b
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Type/Accessory/AccessoryArrayListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function unsetOffset(Type $offsetType): Type
return new ErrorType();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Accessory/HasOffsetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function looseCompare(Type $type, PhpVersion $phpVersion): BooleanType
return new BooleanType();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Accessory/HasOffsetValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function unsetOffset(Type $offsetType): Type
return $this;
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Accessory/NonEmptyArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function unsetOffset(Type $offsetType): Type
return new ErrorType();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Accessory/OversizedArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function unsetOffset(Type $offsetType): Type
return new ErrorType();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function generalizeValues(): self
return new self($this->keyType, $this->itemType->generalize(GeneralizePrecision::lessSpecific()));
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Constant/ConstantArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ public function generalizeValues(): self
return new self($this->keyTypes, $valueTypes, $this->nextAutoIndexes, $this->optionalKeys, $this->isList);
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
$keysArray = $this->getKeysOrValuesArray($this->keyTypes);

Expand Down
2 changes: 1 addition & 1 deletion src/Type/IntersectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ public function unsetOffset(Type $offsetType): Type
return $this->intersectTypes(static fn (Type $type): Type => $type->unsetOffset($offsetType));
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->intersectTypes(static fn (Type $type): Type => $type->getKeysArrayFiltered($filterValueType, $strict));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/MixedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function unsetOffset(Type $offsetType): Type
return $this;
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/NeverType.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function unsetOffset(Type $offsetType): Type
return new NeverType();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
5 changes: 3 additions & 2 deletions src/Type/Php/ArrayKeysFunctionDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Analyser\Scope;
use PHPStan\Php\PhpVersion;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
use PHPStan\Type\NeverType;
use PHPStan\Type\NullType;
Expand Down Expand Up @@ -39,9 +40,9 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
if (count($functionCall->getArgs()) >= 2) {
$filterType = $scope->getType($functionCall->getArgs()[1]->value);

$strict = false;
$strict = TrinaryLogic::createNo();
if (count($functionCall->getArgs()) >= 3) {
$strict = $scope->getType($functionCall->getArgs()[2]->value)->isTrue()->yes();
$strict = $scope->getType($functionCall->getArgs()[2]->value)->isTrue();
}

return $arrayType->getKeysArrayFiltered($filterType, $strict);
Expand Down
2 changes: 1 addition & 1 deletion src/Type/StaticType.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function unsetOffset(Type $offsetType): Type
return $this->getStaticObjectType()->unsetOffset($offsetType);
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getStaticObjectType()->getKeysArrayFiltered($filterValueType, $strict);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Traits/LateResolvableTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function unsetOffset(Type $offsetType): Type
return $this->resolve()->unsetOffset($offsetType);
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->resolve()->getKeysArrayFiltered($filterValueType, $strict);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Traits/MaybeArrayTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function isList(): TrinaryLogic
return TrinaryLogic::createMaybe();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Traits/NonArrayTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function isList(): TrinaryLogic
return TrinaryLogic::createNo();
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->getKeysArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function setExistingOffsetValueType(Type $offsetType, Type $valueType): T

public function unsetOffset(Type $offsetType): Type;

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type;
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type;

public function getKeysArray(): Type;

Expand Down
2 changes: 1 addition & 1 deletion src/Type/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public function unsetOffset(Type $offsetType): Type
return $this->unionTypes(static fn (Type $type): Type => $type->unsetOffset($offsetType));
}

public function getKeysArrayFiltered(Type $filterValueType, bool $strict): Type
public function getKeysArrayFiltered(Type $filterValueType, TrinaryLogic $strict): Type
{
return $this->unionTypes(static fn (Type $type): Type => $type->getKeysArrayFiltered($filterValueType, $strict));
}
Expand Down

0 comments on commit 61d8f3b

Please sign in to comment.