Skip to content

Commit 1826359

Browse files
authored
Merge branch '2.1.x' into equals
2 parents a36fd15 + a5f7c06 commit 1826359

32 files changed

+265
-103
lines changed

build/phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ parameters:
6161
- 'PHPStan\Reflection\MissingPropertyFromReflectionException'
6262
- 'PHPStan\Reflection\MissingConstantFromReflectionException'
6363
- 'PHPStan\Type\CircularTypeAliasDefinitionException'
64-
- 'PHPStan\Broker\ClassAutoloadingException'
6564
- 'LogicException'
6665
- 'Error'
6766
check:

conf/bleedingEdge.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ parameters:
66
stricterFunctionMap: true
77
reportPreciseLineForUnusedFunctionParameter: true
88
internalTag: true
9+
newStaticInAbstractClassStaticMethod: true

conf/config.level0.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ conditionalTags:
110110
phpstan.restrictedClassNameUsageExtension: %featureToggles.internalTag%
111111
PHPStan\Rules\InternalTag\RestrictedInternalFunctionUsageExtension:
112112
phpstan.restrictedFunctionUsageExtension: %featureToggles.internalTag%
113+
PHPStan\Rules\Classes\NewStaticInAbstractClassStaticMethodRule:
114+
phpstan.rules.rule: %featureToggles.newStaticInAbstractClassStaticMethod%
113115

114116
services:
115117
-
@@ -178,6 +180,9 @@ services:
178180
checkFunctionNameCase: %checkFunctionNameCase%
179181
discoveringSymbolsTip: %tips.discoveringSymbols%
180182

183+
-
184+
class: PHPStan\Rules\Classes\NewStaticInAbstractClassStaticMethodRule
185+
181186
-
182187
class: PHPStan\Rules\Constants\OverridingConstantRule
183188
arguments:

conf/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ parameters:
2727
stricterFunctionMap: false
2828
reportPreciseLineForUnusedFunctionParameter: false
2929
internalTag: false
30+
newStaticInAbstractClassStaticMethod: false
3031
fileExtensions:
3132
- php
3233
checkAdvancedIsset: false

conf/parametersSchema.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ parametersSchema:
3333
stricterFunctionMap: bool()
3434
reportPreciseLineForUnusedFunctionParameter: bool()
3535
internalTag: bool()
36+
newStaticInAbstractClassStaticMethod: bool()
3637
])
3738
fileExtensions: listOf(string())
3839
checkAdvancedIsset: bool()

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ private function resolveType(string $exprString, Expr $node): Type
843843
}
844844

845845
if ($node instanceof AlwaysRememberedExpr) {
846-
return $node->getExprType();
846+
return $this->nativeTypesPromoted ? $node->getNativeExprType() : $node->getExprType();
847847
}
848848

849849
if ($node instanceof Expr\BinaryOp\Smaller) {

src/Analyser/NodeScopeResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5404,7 +5404,7 @@ private function processAssignVar(
54045404
$conditionalExpressions = $this->processSureTypesForConditionalExpressionsAfterAssign($scope, $var->name, $conditionalExpressions, $falseySpecifiedTypes, $falseyType);
54055405
$conditionalExpressions = $this->processSureNotTypesForConditionalExpressionsAfterAssign($scope, $var->name, $conditionalExpressions, $falseySpecifiedTypes, $falseyType);
54065406

5407-
$nodeCallback(new VariableAssignNode($var, $assignedExpr, $isAssignOp), $result->getScope());
5407+
$nodeCallback(new VariableAssignNode($var, $assignedExpr), $result->getScope());
54085408
$scope = $scope->assignVariable($var->name, $type, $scope->getNativeType($assignedExpr), TrinaryLogic::createYes());
54095409
foreach ($conditionalExpressions as $exprString => $holders) {
54105410
$scope = $scope->addConditionalExpressions($exprString, $holders);
@@ -5542,7 +5542,7 @@ private function processAssignVar(
55425542

55435543
if ($varType->isArray()->yes() || !(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->yes()) {
55445544
if ($var instanceof Variable && is_string($var->name)) {
5545-
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr, $isAssignOp), $scope);
5545+
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr), $scope);
55465546
$scope = $scope->assignVariable($var->name, $valueToWrite, $nativeValueToWrite, TrinaryLogic::createYes());
55475547
} else {
55485548
if ($var instanceof PropertyFetch || $var instanceof StaticPropertyFetch) {
@@ -5574,7 +5574,7 @@ private function processAssignVar(
55745574
}
55755575
} else {
55765576
if ($var instanceof Variable) {
5577-
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr, $isAssignOp), $scope);
5577+
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr), $scope);
55785578
} elseif ($var instanceof PropertyFetch || $var instanceof StaticPropertyFetch) {
55795579
$nodeCallback(new PropertyAssignNode($var, $assignedPropertyExpr, $isAssignOp), $scope);
55805580
if ($var instanceof PropertyFetch && $var->name instanceof Node\Identifier && !$isAssignOp) {
@@ -5861,7 +5861,7 @@ static function (): void {
58615861
}
58625862

58635863
if ($var instanceof Variable && is_string($var->name)) {
5864-
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr, $isAssignOp), $scope);
5864+
$nodeCallback(new VariableAssignNode($var, $assignedPropertyExpr), $scope);
58655865
$scope = $scope->assignVariable($var->name, $valueToWrite, $nativeValueToWrite, TrinaryLogic::createYes());
58665866
} else {
58675867
if ($var instanceof PropertyFetch || $var instanceof StaticPropertyFetch) {

src/Analyser/UndefinedVariableException.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
use PHPStan\AnalysedCodeException;
66
use function sprintf;
77

8+
/**
9+
* @api
10+
*
11+
* Unchecked exception thrown from `PHPStan\Analyser\Scope::getVariableType()`
12+
* in case the user doesn't check `hasVariableType()` is not `no()`.
13+
*/
814
final class UndefinedVariableException extends AnalysedCodeException
915
{
1016

src/Broker/ClassAutoloadingException.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/Broker/ClassNotFoundException.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
use PHPStan\AnalysedCodeException;
66
use function sprintf;
77

8+
/**
9+
* @api
10+
*
11+
* Unchecked exception thrown from `ReflectionProvider` and other places
12+
* in case the user does not check the existence of the class beforehand
13+
* with `hasClass()` or similar.
14+
*/
815
final class ClassNotFoundException extends AnalysedCodeException
916
{
1017

0 commit comments

Comments
 (0)