Skip to content

Commit 3876f4a

Browse files
committed
Merge remote-tracking branch 'origin/1.10.x' into 1.11.x
2 parents 5cd4b6a + 2fb6632 commit 3876f4a

File tree

6 files changed

+49
-22
lines changed

6 files changed

+49
-22
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"hoa/compiler": "3.17.08.08",
1515
"hoa/exception": "^1.0",
1616
"hoa/regex": "1.17.01.13",
17-
"jetbrains/phpstorm-stubs": "dev-master#8ea3bf44722f76a3a32c89fe769b6144c253f8a6",
17+
"jetbrains/phpstorm-stubs": "dev-master#be32b6125b9bcbd7deabe830c5935d4c47b9481c",
1818
"nette/bootstrap": "^3.0",
1919
"nette/di": "3.1.10",
2020
"nette/finder": "^2.5",
@@ -24,7 +24,7 @@
2424
"nikic/php-parser": "^4.17.1",
2525
"ondram/ci-detector": "^3.4.0",
2626
"ondrejmirtes/better-reflection": "6.21.0",
27-
"phpstan/php-8-stubs": "0.3.82",
27+
"phpstan/php-8-stubs": "0.3.84",
2828
"phpstan/phpdoc-parser": "1.25.0",
2929
"react/async": "^3",
3030
"react/child-process": "^0.6.4",

composer.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline.neon

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,19 +838,14 @@ parameters:
838838

839839
-
840840
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantStringType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantStrings\\(\\) instead\\.$#"
841-
count: 4
841+
count: 3
842842
path: src/Type/Constant/ConstantArrayType.php
843843

844844
-
845845
message: "#^Doing instanceof PHPStan\\\\Type\\\\IntersectionType is error\\-prone and deprecated\\.$#"
846846
count: 1
847847
path: src/Type/Constant/ConstantArrayType.php
848848

849-
-
850-
message: "#^Doing instanceof PHPStan\\\\Type\\\\StringType is error\\-prone and deprecated\\. Use Type\\:\\:isString\\(\\) instead\\.$#"
851-
count: 1
852-
path: src/Type/Constant/ConstantArrayType.php
853-
854849
-
855850
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantStringType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantStrings\\(\\) instead\\.$#"
856851
count: 2

src/Type/Constant/ConstantArrayType.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
use PHPStan\Type\IntersectionType;
4141
use PHPStan\Type\MixedType;
4242
use PHPStan\Type\NeverType;
43-
use PHPStan\Type\StringType;
4443
use PHPStan\Type\Type;
4544
use PHPStan\Type\TypeCombinator;
4645
use PHPStan\Type\UnionType;
@@ -619,8 +618,8 @@ public function hasOffsetValueType(Type $offsetType): TrinaryLogic
619618
foreach ($this->keyTypes as $i => $keyType) {
620619
if (
621620
$keyType instanceof ConstantIntegerType
622-
&& $offsetType instanceof StringType
623-
&& !$offsetType instanceof ConstantStringType
621+
&& !$offsetType->isString()->no()
622+
&& $offsetType->isConstantScalarValue()->no()
624623
) {
625624
return TrinaryLogic::createMaybe();
626625
}

tests/PHPStan/Rules/Variables/NullCoalesceRuleTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,12 @@ public function testBug8084(): void
368368
$this->analyse([__DIR__ . '/data/bug-8084.php'], []);
369369
}
370370

371+
public function testBug10577(): void
372+
{
373+
$this->treatPhpDocTypesAsCertain = true;
374+
$this->strictUnnecessaryNullsafePropertyFetch = true;
375+
376+
$this->analyse([__DIR__ . '/data/bug-10577.php'], []);
377+
}
378+
371379
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug10577;
4+
5+
class HelloWorld
6+
{
7+
private const MAP = [
8+
'10' => 'Test1',
9+
'20' => 'Test2',
10+
];
11+
12+
13+
public function validate(string $value): void
14+
{
15+
$value = trim($value);
16+
17+
if ($value === '') {
18+
throw new \RuntimeException();
19+
}
20+
21+
$value = self::MAP[$value] ?? $value;
22+
23+
// ...
24+
}
25+
}

0 commit comments

Comments
 (0)