Skip to content

Commit 9c3b6d5

Browse files
authored
New types: decimal-int-string and non-decimal-int-string
1 parent a9983f4 commit 9c3b6d5

43 files changed

Lines changed: 997 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎phpstan-baseline.neon‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,12 @@ parameters:
777777
count: 1
778778
path: src/Type/Accessory/AccessoryArrayListType.php
779779

780+
-
781+
rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated.
782+
identifier: phpstanApi.instanceofType
783+
count: 1
784+
path: src/Type/Accessory/AccessoryDecimalIntegerStringType.php
785+
780786
-
781787
rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated.
782788
identifier: phpstanApi.instanceofType
@@ -1716,7 +1722,7 @@ parameters:
17161722
-
17171723
rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated.
17181724
identifier: phpstanApi.instanceofType
1719-
count: 3
1725+
count: 4
17201726
path: src/Type/TypeCombinator.php
17211727

17221728
-

‎src/PhpDoc/TypeNodeResolver.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
use PHPStan\ShouldNotHappenException;
4848
use PHPStan\TrinaryLogic;
4949
use PHPStan\Type\Accessory\AccessoryArrayListType;
50+
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
5051
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
5152
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
5253
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
@@ -235,6 +236,15 @@ private function resolveIdentifierTypeNode(IdentifierTypeNode $typeNode, NameSco
235236
case 'string':
236237
return new StringType();
237238

239+
case 'decimal-int-string':
240+
return new IntersectionType([new StringType(), new AccessoryDecimalIntegerStringType()]);
241+
242+
case 'non-decimal-int-string':
243+
return new IntersectionType([
244+
new StringType(),
245+
new AccessoryDecimalIntegerStringType(inverse: true),
246+
]);
247+
238248
case 'lowercase-string':
239249
return new IntersectionType([new StringType(), new AccessoryLowercaseStringType()]);
240250

‎src/Type/Accessory/AccessoryArrayListType.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ public function isNumericString(): TrinaryLogic
385385
return TrinaryLogic::createNo();
386386
}
387387

388+
public function isDecimalIntegerString(): TrinaryLogic
389+
{
390+
return TrinaryLogic::createNo();
391+
}
392+
388393
public function isNonEmptyString(): TrinaryLogic
389394
{
390395
return TrinaryLogic::createNo();

0 commit comments

Comments
 (0)