Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a56599

Browse files
Int::toString is lowercase
1 parent 4168fe5 commit 8a56599

File tree

19 files changed

+74
-69
lines changed

19 files changed

+74
-69
lines changed

‎src/Type/IntegerRangeType.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
1111
use PHPStan\Reflection\InitializerExprTypeResolver;
1212
use PHPStan\TrinaryLogic;
13+
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
1314
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
1415
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1516
use PHPStan\Type\Constant\ConstantBooleanType;
@@ -474,13 +475,15 @@ public function toString(): Type
474475
if ($isZero->no()) {
475476
return new IntersectionType([
476477
new StringType(),
478+
new AccessoryLowercaseStringType(),
477479
new AccessoryNumericStringType(),
478480
new AccessoryNonFalsyStringType(),
479481
]);
480482
}
481483

482484
return new IntersectionType([
483485
new StringType(),
486+
new AccessoryLowercaseStringType(),
484487
new AccessoryNumericStringType(),
485488
]);
486489
}

‎src/Type/IntegerType.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
77
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
88
use PHPStan\TrinaryLogic;
9+
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
910
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1011
use PHPStan\Type\Constant\ConstantArrayType;
1112
use PHPStan\Type\Constant\ConstantIntegerType;
@@ -81,6 +82,7 @@ public function toString(): Type
8182
{
8283
return new IntersectionType([
8384
new StringType(),
85+
new AccessoryLowercaseStringType(),
8486
new AccessoryNumericStringType(),
8587
]);
8688
}

‎tests/PHPStan/Analyser/nsrt/array-key-exists.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public function doBar(array $a, array $b, array $c, int $key1, string $key2, int
5050
assertType('int', $key1);
5151
}
5252
if (array_key_exists($key2, $a)) {
53-
assertType('numeric-string', $key2);
53+
assertType('lowercase-string&numeric-string', $key2);
5454
}
5555
if (array_key_exists($key3, $a)) {
56-
assertType('int|numeric-string', $key3);
56+
assertType('int|(lowercase-string&numeric-string)', $key3);
5757
}
5858
if (array_key_exists($key4, $a)) {
59-
assertType('(int|numeric-string)', $key4);
59+
assertType('(int|(lowercase-string&numeric-string))', $key4);
6060
}
6161
if (array_key_exists($key5, $a)) {
62-
assertType('int|numeric-string', $key5);
62+
assertType('int|(lowercase-string&numeric-string)', $key5);
6363
}
6464

6565
if (array_key_exists($key1, $b)) {

‎tests/PHPStan/Analyser/nsrt/bug-10863.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class Foo
1212
*/
1313
public function doFoo($b): void
1414
{
15-
assertType('non-falsy-string', '@' . $b);
15+
assertType('lowercase-string&non-falsy-string', '@' . $b);
1616
}
1717

1818
/**
1919
* @param int|false $b
2020
*/
2121
public function doFoo2($b): void
2222
{
23-
assertType('non-falsy-string', '@' . $b);
23+
assertType('lowercase-string&non-falsy-string', '@' . $b);
2424
}
2525

2626
}

‎tests/PHPStan/Analyser/nsrt/bug-11129.php‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ public function foo(
2121
$maybeNegativeConstStrings, $maybeNonNumericConstStrings, $maybeFloatConstStrings,
2222
bool $bool, float $float
2323
): void {
24-
assertType('non-falsy-string', '0'.$i);
25-
assertType('non-falsy-string&numeric-string', $i.'0');
24+
assertType('lowercase-string&non-falsy-string', '0'.$i);
25+
assertType('lowercase-string&non-falsy-string&numeric-string', $i.'0');
2626

27-
assertType('non-falsy-string&numeric-string', '0'.$positiveInt);
28-
assertType('non-falsy-string&numeric-string', $positiveInt.'0');
27+
assertType('lowercase-string&non-falsy-string&numeric-string', '0'.$positiveInt);
28+
assertType('lowercase-string&non-falsy-string&numeric-string', $positiveInt.'0');
2929

30-
assertType('non-falsy-string', '0'.$negativeInt);
31-
assertType('non-falsy-string&numeric-string', $negativeInt.'0');
30+
assertType('lowercase-string&non-falsy-string', '0'.$negativeInt);
31+
assertType('lowercase-string&non-falsy-string&numeric-string', $negativeInt.'0');
3232

3333
assertType("'00'|'01'|'02'", '0'.$positiveConstStrings);
3434
assertType( "'00'|'10'|'20'", $positiveConstStrings.'0');
@@ -39,29 +39,29 @@ public function foo(
3939
assertType("'00'|'01'|'0a'", '0'.$maybeNonNumericConstStrings);
4040
assertType("'00'|'10'|'a0'", $maybeNonNumericConstStrings.'0');
4141

42-
assertType('non-falsy-string&numeric-string', $i.$positiveConstStrings);
43-
assertType('non-falsy-string', $positiveConstStrings.$i);
42+
assertType('lowercase-string&non-falsy-string&numeric-string', $i.$positiveConstStrings);
43+
assertType('lowercase-string&non-falsy-string', $positiveConstStrings.$i);
4444

45-
assertType('non-falsy-string', $i.$maybeNegativeConstStrings);
46-
assertType('non-falsy-string', $maybeNegativeConstStrings.$i);
45+
assertType('lowercase-string&non-falsy-string', $i.$maybeNegativeConstStrings);
46+
assertType('lowercase-string&non-falsy-string', $maybeNegativeConstStrings.$i);
4747

48-
assertType('non-falsy-string', $i.$maybeNonNumericConstStrings);
49-
assertType('non-falsy-string', $maybeNonNumericConstStrings.$i);
48+
assertType('lowercase-string&non-falsy-string', $i.$maybeNonNumericConstStrings);
49+
assertType('lowercase-string&non-falsy-string', $maybeNonNumericConstStrings.$i);
5050

51-
assertType('non-falsy-string', $i.$maybeFloatConstStrings); // could be 'non-falsy-string&numeric-string'
52-
assertType('non-falsy-string', $maybeFloatConstStrings.$i);
51+
assertType('lowercase-string&non-falsy-string', $i.$maybeFloatConstStrings); // could be 'lowercase-string&non-falsy-string&numeric-string'
52+
assertType('lowercase-string&non-falsy-string', $maybeFloatConstStrings.$i);
5353

54-
assertType('non-empty-string&numeric-string', $i.$bool);
55-
assertType('non-empty-string', $bool.$i);
56-
assertType('non-falsy-string&numeric-string', $positiveInt.$bool);
57-
assertType('non-falsy-string&numeric-string', $bool.$positiveInt);
58-
assertType('non-falsy-string&numeric-string', $negativeInt.$bool);
59-
assertType('non-falsy-string', $bool.$negativeInt);
54+
assertType('lowercase-string&non-empty-string&numeric-string', $i.$bool);
55+
assertType('lowercase-string&non-empty-string', $bool.$i);
56+
assertType('lowercase-string&non-falsy-string&numeric-string', $positiveInt.$bool);
57+
assertType('lowercase-string&non-falsy-string&numeric-string', $bool.$positiveInt);
58+
assertType('lowercase-string&non-falsy-string&numeric-string', $negativeInt.$bool);
59+
assertType('lowercase-string&non-falsy-string', $bool.$negativeInt);
6060

61-
assertType('non-falsy-string', $i.$i);
62-
assertType('non-falsy-string', $negativeInt.$negativeInt);
63-
assertType('non-falsy-string', $maybeNegativeConstStrings.$negativeInt);
64-
assertType('non-falsy-string', $negativeInt.$maybeNegativeConstStrings);
61+
assertType('lowercase-string&non-falsy-string', $i.$i);
62+
assertType('lowercase-string&non-falsy-string', $negativeInt.$negativeInt);
63+
assertType('lowercase-string&non-falsy-string', $maybeNegativeConstStrings.$negativeInt);
64+
assertType('lowercase-string&non-falsy-string', $negativeInt.$maybeNegativeConstStrings);
6565

6666
// https://3v4l.org/BCS2K
6767
assertType('non-falsy-string', $float.$float);
@@ -75,9 +75,9 @@ public function foo(
7575
// https://3v4l.org/Ia4r0
7676
$scientificFloatAsString = '3e4';
7777
assertType('non-falsy-string', $numericString.$scientificFloatAsString);
78-
assertType('non-falsy-string', $i.$scientificFloatAsString);
78+
assertType('lowercase-string&non-falsy-string', $i.$scientificFloatAsString);
7979
assertType('non-falsy-string', $scientificFloatAsString.$numericString);
80-
assertType('non-falsy-string', $scientificFloatAsString.$i);
80+
assertType('lowercase-string&non-falsy-string', $scientificFloatAsString.$i);
8181
}
8282

8383
}

‎tests/PHPStan/Analyser/nsrt/bug-11716.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function narrowKey($mixed, string $s, int $i, array $generalArr, array $intKeyed
7575
assertType('int', $i);
7676

7777
if (isset($intKeyedArr[$s])) {
78-
assertType("numeric-string", $s);
78+
assertType("lowercase-string&numeric-string", $s);
7979
} else {
8080
assertType('string', $s);
8181
}

‎tests/PHPStan/Analyser/nsrt/bug-4587.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public function b(): void
2727
$type = array_map(static function (array $result): array {
2828
assertType('array{a: int}', $result);
2929
$result['a'] = (string) $result['a'];
30-
assertType('array{a: numeric-string}', $result);
30+
assertType('array{a: lowercase-string&numeric-string}', $result);
3131

3232
return $result;
3333
}, $results);
3434

35-
assertType('list<array{a: numeric-string}>', $type);
35+
assertType('list<array{a: lowercase-string&numeric-string}>', $type);
3636
}
3737
}

‎tests/PHPStan/Analyser/nsrt/bug-7387.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function inputTypes(int $i, float $f, string $s, int $intRange) {
2929

3030
public function specifiers(int $i) {
3131
// https://3v4l.org/fmVIg
32-
assertType('numeric-string', sprintf('%14s', $i));
32+
assertType('lowercase-string&numeric-string', sprintf('%14s', $i));
3333

3434
assertType('numeric-string', sprintf('%d', $i));
3535

@@ -59,9 +59,9 @@ public function specifiers(int $i) {
5959
*/
6060
public function positionalArgs($mixed, int $i, float $f, string $s, int $posInt, int $negInt, int $nonZeroIntRange, int $intRange) {
6161
// https://3v4l.org/vVL0c
62-
assertType('numeric-string', sprintf('%26ドルs', $mixed, $i));
63-
assertType('non-falsy-string&numeric-string', sprintf('%26ドルs', $mixed, $posInt));
64-
assertType('non-falsy-string&numeric-string', sprintf('%26ドルs', $mixed, $negInt));
62+
assertType('lowercase-string&numeric-string', sprintf('%26ドルs', $mixed, $i));
63+
assertType('lowercase-string&non-falsy-string&numeric-string', sprintf('%26ドルs', $mixed, $posInt));
64+
assertType('lowercase-string&non-falsy-string&numeric-string', sprintf('%26ドルs', $mixed, $negInt));
6565
assertType("' 1'|' 2'|' 3'|' 4'|' 5'", sprintf('%26ドルs', $mixed, $nonZeroIntRange));
6666

6767
// https://3v4l.org/1ECIq

‎tests/PHPStan/Analyser/nsrt/bug-8568.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class HelloWorld
88
{
99
public function sayHello(): void
1010
{
11-
assertType('non-falsy-string', 'a' . $this->get());
11+
assertType('lowercase-string&non-falsy-string', 'a' . $this->get());
1212
}
1313

1414
public function get(): ?int

‎tests/PHPStan/Analyser/nsrt/bug-8635.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class HelloWorld
88
{
99
public function EchoInt(int $value): void
1010
{
11-
assertType('numeric-string', "$value");
11+
assertType('lowercase-string&numeric-string', "$value");
1212
}
1313
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /