Skip to content

Commit a80fa22

Browse files
authored
Merge branch 'phpstan:2.2.x' into 2.2.x
2 parents 76da17b + 4b0538b commit a80fa22

21 files changed

+359
-118
lines changed

compiler/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": "^8.2",
88
"nette/neon": "^3.0.0",
9-
"ondrejmirtes/simple-downgrader": "^2.2.3",
9+
"ondrejmirtes/simple-downgrader": "^2.2.5",
1010
"seld/phar-utils": "^1.2",
1111
"symfony/console": "^5.4.43",
1212
"symfony/filesystem": "^5.4.43",

compiler/composer.lock

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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"hoa/compiler": "3.17.08.08",
1616
"hoa/exception": "^1.0",
1717
"hoa/file": "1.17.07.11",
18-
"jetbrains/phpstorm-stubs": "dev-master#2cdd054c4109dfb76667c9198bf9427606354243",
18+
"jetbrains/phpstorm-stubs": "dev-master#089eb05b06ff1947677b765f9f14ad1d6b6b8af5",
1919
"nette/bootstrap": "^3.0",
2020
"nette/di": "^3.1.4",
2121
"nette/neon": "3.3.4",

composer.lock

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

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,12 +1731,6 @@ parameters:
17311731
count: 1
17321732
path: src/Type/TypeCombinator.php
17331733

1734-
-
1735-
rawMessage: 'Doing instanceof PHPStan\Type\Constant\ConstantArrayType is error-prone and deprecated. Use Type::getConstantArrays() instead.'
1736-
identifier: phpstanApi.instanceofType
1737-
count: 2
1738-
path: src/Type/TypeUtils.php
1739-
17401734
-
17411735
rawMessage: Doing instanceof PHPStan\Type\IntersectionType is error-prone and deprecated.
17421736
identifier: phpstanApi.instanceofType

src/Analyser/MutatingScope.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,6 @@ private function resolveType(string $exprString, Expr $node): Type
14671467
$node->var,
14681468
$this->getTypeFromArrayDimFetch(
14691469
$node,
1470-
$this->getType($node->dim),
1471-
$this->getType($node->var),
14721470
),
14731471
);
14741472
}
@@ -1845,14 +1843,13 @@ private function promoteNativeTypes(): self
18451843

18461844
private function getTypeFromArrayDimFetch(
18471845
Expr\ArrayDimFetch $arrayDimFetch,
1848-
Type $offsetType,
1849-
Type $offsetAccessibleType,
18501846
): Type
18511847
{
18521848
if ($arrayDimFetch->dim === null) {
18531849
throw new ShouldNotHappenException();
18541850
}
18551851

1852+
$offsetAccessibleType = $this->getType($arrayDimFetch->var);
18561853
if ($offsetAccessibleType instanceof NeverType) {
18571854
return $offsetAccessibleType;
18581855
}
@@ -1872,6 +1869,7 @@ private function getTypeFromArrayDimFetch(
18721869
);
18731870
}
18741871

1872+
$offsetType = $this->getType($arrayDimFetch->dim);
18751873
return $offsetAccessibleType->getOffsetValueType($offsetType);
18761874
}
18771875

@@ -4143,17 +4141,21 @@ private function createConditionalExpressions(
41434141
continue;
41444142
}
41454143

4146-
$conditionalExpression = new ConditionalExpressionHolder($variableTypeGuards, $holder);
4147-
$conditionalExpressions[$exprString][$conditionalExpression->getKey()] = $conditionalExpression;
4144+
foreach ($variableTypeGuards as $guardExprString => $guardHolder) {
4145+
$conditionalExpression = new ConditionalExpressionHolder([$guardExprString => $guardHolder], $holder);
4146+
$conditionalExpressions[$exprString][$conditionalExpression->getKey()] = $conditionalExpression;
4147+
}
41484148
}
41494149

41504150
foreach ($mergedExpressionTypes as $exprString => $mergedExprTypeHolder) {
41514151
if (array_key_exists($exprString, $ourExpressionTypes)) {
41524152
continue;
41534153
}
41544154

4155-
$conditionalExpression = new ConditionalExpressionHolder($typeGuards, new ExpressionTypeHolder($mergedExprTypeHolder->getExpr(), new ErrorType(), TrinaryLogic::createNo()));
4156-
$conditionalExpressions[$exprString][$conditionalExpression->getKey()] = $conditionalExpression;
4155+
foreach ($typeGuards as $guardExprString => $guardHolder) {
4156+
$conditionalExpression = new ConditionalExpressionHolder([$guardExprString => $guardHolder], new ExpressionTypeHolder($mergedExprTypeHolder->getExpr(), new ErrorType(), TrinaryLogic::createNo()));
4157+
$conditionalExpressions[$exprString][$conditionalExpression->getKey()] = $conditionalExpression;
4158+
}
41574159
}
41584160

41594161
return $conditionalExpressions;

src/Command/AnalysisResult.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,25 @@ public function getChangedProjectExtensionFilesOutsideOfAnalysedPaths(): array
148148
return $this->changedProjectExtensionFilesOutsideOfAnalysedPaths;
149149
}
150150

151+
/**
152+
* @api
153+
* @param list<Error> $fileSpecificErrors
154+
*/
155+
public function withFileSpecificErrors(array $fileSpecificErrors): self
156+
{
157+
return new self(
158+
$fileSpecificErrors,
159+
$this->notFileSpecificErrors,
160+
$this->internalErrors,
161+
$this->warnings,
162+
$this->collectedData,
163+
$this->defaultLevelUsed,
164+
$this->projectConfigFile,
165+
$this->savedResultCache,
166+
$this->peakMemoryUsageBytes,
167+
$this->isResultCacheUsed,
168+
$this->changedProjectExtensionFilesOutsideOfAnalysedPaths,
169+
);
170+
}
171+
151172
}

src/Internal/CombinationsHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace PHPStan\Internal;
44

5+
use Traversable;
56
use function array_pop;
67

78
final class CombinationsHelper
89
{
910

1011
/**
1112
* @param array<iterable<mixed>> $arrays
12-
* @return iterable<list<mixed>>
13+
* @return Traversable<list<mixed>>
1314
*/
1415
public static function combinations(array $arrays): iterable
1516
{

src/Type/Constant/ConstantArrayType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ public function getAllArrays(): array
216216
} else {
217217
$optionalKeysCombinations = [
218218
[],
219+
array_slice($this->optionalKeys, 0, 1, true),
220+
array_slice($this->optionalKeys, -1, 1, true),
219221
$this->optionalKeys,
220222
];
221223
}

0 commit comments

Comments
 (0)