|
6 | 6 |
|
7 | 7 | use Nette\Utils\Strings; |
8 | 8 | use PHPStan\Type\Accessory\AccessoryArrayListType; |
| 9 | +use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType; |
9 | 10 | use PHPStan\Type\Accessory\AccessoryLiteralStringType; |
10 | 11 | use PHPStan\Type\Accessory\AccessoryLowercaseStringType; |
11 | 12 | use PHPStan\Type\Accessory\AccessoryNonEmptyStringType; |
@@ -91,6 +92,42 @@ public function mapScalarStringToType(string $scalarName): Type |
91 | 92 | return new UnionType([new IntegerType(), new StringType()]); |
92 | 93 | } |
93 | 94 |
|
| 95 | + if ($loweredScalarName === 'callable-string') { |
| 96 | + return TypeCombinator::intersect(new StringType(), new CallableType()); |
| 97 | + } |
| 98 | + |
| 99 | + if ($loweredScalarName === 'non-empty-lowercase-string') { |
| 100 | + return TypeCombinator::intersect( |
| 101 | + new StringType(), |
| 102 | + new AccessoryNonEmptyStringType(), |
| 103 | + new AccessoryLowercaseStringType() |
| 104 | + ); |
| 105 | + } |
| 106 | + |
| 107 | + if ($loweredScalarName === 'non-empty-uppercase-string') { |
| 108 | + return TypeCombinator::intersect( |
| 109 | + new StringType(), |
| 110 | + new AccessoryNonEmptyStringType(), |
| 111 | + new AccessoryUppercaseStringType() |
| 112 | + ); |
| 113 | + } |
| 114 | + |
| 115 | + if ($loweredScalarName === 'non-empty-literal-string') { |
| 116 | + return TypeCombinator::intersect( |
| 117 | + new StringType(), |
| 118 | + new AccessoryNonEmptyStringType(), |
| 119 | + new AccessoryLiteralStringType() |
| 120 | + ); |
| 121 | + } |
| 122 | + |
| 123 | + if ($loweredScalarName === 'decimal-int-string') { |
| 124 | + return TypeCombinator::intersect(new StringType(), new AccessoryDecimalIntegerStringType()); |
| 125 | + } |
| 126 | + |
| 127 | + if ($loweredScalarName === 'non-decimal-int-string') { |
| 128 | + return TypeCombinator::intersect(new StringType(), new AccessoryDecimalIntegerStringType(true)); |
| 129 | + } |
| 130 | + |
94 | 131 | foreach (self::SCALAR_NAME_BY_TYPE as $objectType => $scalarNames) { |
95 | 132 | if (! in_array($loweredScalarName, $scalarNames, true)) { |
96 | 133 | continue; |
|
0 commit comments