Skip to content

Commit e33f4cb

Browse files
committed
Fixes
1 parent ad72432 commit e33f4cb

File tree

8 files changed

+18
-31
lines changed

8 files changed

+18
-31
lines changed

src/Analyser/MutatingScope.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
use PhpParser\Node\InterpolatedStringPart;
2525
use PhpParser\Node\Name;
2626
use PhpParser\Node\Name\FullyQualified;
27-
use PhpParser\Node\Scalar\DNumber;
28-
use PhpParser\Node\Scalar\LNumber;
2927
use PhpParser\Node\Scalar\String_;
3028
use PhpParser\NodeFinder;
3129
use PHPStan\Node\ExecutionEndNode;
@@ -1082,7 +1080,7 @@ private function resolveType(string $exprString, Expr $node): Type
10821080
return $this->getType($node->expr);
10831081
}
10841082

1085-
if ($node instanceof LNumber) {
1083+
if ($node instanceof Node\Scalar\Int_) {
10861084
return $this->initializerExprTypeResolver->getType($node, InitializerExprContext::fromScope($this));
10871085
} elseif ($node instanceof String_) {
10881086
return $this->initializerExprTypeResolver->getType($node, InitializerExprContext::fromScope($this));
@@ -1106,7 +1104,7 @@ private function resolveType(string $exprString, Expr $node): Type
11061104
}
11071105

11081106
return $resultType ?? new ConstantStringType('');
1109-
} elseif ($node instanceof DNumber) {
1107+
} elseif ($node instanceof Node\Scalar\Float_) {
11101108
return $this->initializerExprTypeResolver->getType($node, InitializerExprContext::fromScope($this));
11111109
} elseif ($node instanceof Expr\CallLike && $node->isFirstClassCallable()) {
11121110
if ($node instanceof FuncCall) {
@@ -1466,10 +1464,10 @@ private function resolveType(string $exprString, Expr $node): Type
14661464
}
14671465

14681466
if ($node instanceof Expr\PreInc) {
1469-
return $this->getType(new BinaryOp\Plus($node->var, new LNumber(1)));
1467+
return $this->getType(new BinaryOp\Plus($node->var, new Node\Scalar\Int_(1)));
14701468
}
14711469

1472-
return $this->getType(new BinaryOp\Minus($node->var, new LNumber(1)));
1470+
return $this->getType(new BinaryOp\Minus($node->var, new Node\Scalar\Int_(1)));
14731471
} elseif ($node instanceof Expr\Yield_) {
14741472
$functionReflection = $this->getFunction();
14751473
if ($functionReflection === null) {

src/Analyser/NodeScopeResolver.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ private function processStmtNode(
376376
&& !$stmt instanceof Foreach_
377377
&& !$stmt instanceof Node\Stmt\Global_
378378
&& !$stmt instanceof Node\Stmt\Property
379-
&& !$stmt instanceof Node\Stmt\PropertyProperty
380379
&& !$stmt instanceof Node\Stmt\ClassConst
381380
&& !$stmt instanceof Node\Stmt\Const_
382381
) {
@@ -739,7 +738,9 @@ private function processStmtNode(
739738
$this->processAttributeGroups($stmt, $stmt->attrGroups, $scope, $nodeCallback);
740739

741740
foreach ($stmt->props as $prop) {
742-
$this->processStmtNode($prop, $scope, $nodeCallback, $context);
741+
if ($prop->default !== null) {
742+
$this->processExprNode($stmt, $prop->default, $scope, $nodeCallback, ExpressionContext::createDeep());
743+
}
743744
[,,,,,,,,,,$isReadOnly, $docComment, ,,,$varTags, $isAllowedPrivateMutation] = $this->getPhpDocs($scope, $stmt);
744745
if (!$scope->isInClass()) {
745746
throw new ShouldNotHappenException();
@@ -775,12 +776,6 @@ private function processStmtNode(
775776
if ($stmt->type !== null) {
776777
$nodeCallback($stmt->type, $scope);
777778
}
778-
} elseif ($stmt instanceof Node\Stmt\PropertyProperty) {
779-
$hasYield = false;
780-
$throwPoints = [];
781-
if ($stmt->default !== null) {
782-
$this->processExprNode($stmt, $stmt->default, $scope, $nodeCallback, ExpressionContext::createDeep());
783-
}
784779
} elseif ($stmt instanceof If_) {
785780
$conditionType = ($this->treatPhpDocTypesAsCertain ? $scope->getType($stmt->cond) : $scope->getNativeType($stmt->cond))->toBoolean();
786781
$ifAlwaysTrue = $conditionType->isTrue()->yes();
@@ -1515,7 +1510,7 @@ private function processStmtNode(
15151510
$hasYield = false;
15161511
$throwPoints = [];
15171512
foreach ($stmt->uses as $use) {
1518-
$this->processStmtNode($use, $scope, $nodeCallback, $context);
1513+
$nodeCallback($use, $scope);
15191514
}
15201515
} elseif ($stmt instanceof Node\Stmt\Global_) {
15211516
$hasYield = false;
@@ -1599,14 +1594,11 @@ private function processStmtNode(
15991594
} elseif ($stmt instanceof Node\Stmt\Nop) {
16001595
$hasYield = false;
16011596
$throwPoints = $overridingThrowPoints ?? [];
1602-
} elseif ($stmt instanceof Node\Stmt\UseUse) {
1603-
$hasYield = false;
1604-
$throwPoints = [];
16051597
} elseif ($stmt instanceof Node\Stmt\GroupUse) {
16061598
$hasYield = false;
16071599
$throwPoints = [];
16081600
foreach ($stmt->uses as $use) {
1609-
$this->processStmtNode($use, $scope, $nodeCallback, $context);
1601+
$nodeCallback($use, $scope);
16101602
}
16111603
} else {
16121604
$hasYield = false;

src/Dependency/ExportedNodeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private function exportClassStatement(Node\Stmt $node, string $fileName, string
336336
$docComment = $node->getDocComment();
337337

338338
return new ExportedPropertiesNode(
339-
array_map(static fn (Node\Stmt\PropertyProperty $prop): string => $prop->name->toString(), $node->props),
339+
array_map(static fn (Node\PropertyItem $prop): string => $prop->name->toString(), $node->props),
340340
$this->exportPhpDocNode(
341341
$fileName,
342342
$namespacedName,

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use PhpParser\Node\Expr\PropertyFetch;
1111
use PhpParser\Node\Identifier;
1212
use PhpParser\Node\Name;
13-
use PhpParser\Node\Scalar\DNumber;
14-
use PhpParser\Node\Scalar\LNumber;
13+
use PhpParser\Node\Scalar\Float_;
14+
use PhpParser\Node\Scalar\Int_;
1515
use PhpParser\Node\Scalar\MagicConst;
1616
use PhpParser\Node\Scalar\MagicConst\Dir;
1717
use PhpParser\Node\Scalar\MagicConst\File;
@@ -109,10 +109,10 @@ public function getType(Expr $expr, InitializerExprContext $context): Type
109109
if ($expr instanceof TypeExpr) {
110110
return $expr->getExprType();
111111
}
112-
if ($expr instanceof LNumber) {
112+
if ($expr instanceof Int_) {
113113
return new ConstantIntegerType($expr->value);
114114
}
115-
if ($expr instanceof DNumber) {
115+
if ($expr instanceof Float_) {
116116
return new ConstantFloatType($expr->value);
117117
}
118118
if ($expr instanceof String_) {

src/Rules/Namespaces/ExistingNamesInUseRule.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function processNode(Node $node, Scope $scope): array
5858
}
5959

6060
/**
61-
* @param Node\Stmt\UseUse[] $uses
61+
* @param Node\UseItem[] $uses
6262
* @return list<IdentifierRuleError>
6363
*/
6464
private function checkConstants(array $uses): array
@@ -80,7 +80,7 @@ private function checkConstants(array $uses): array
8080
}
8181

8282
/**
83-
* @param Node\Stmt\UseUse[] $uses
83+
* @param Node\UseItem[] $uses
8484
* @return list<IdentifierRuleError>
8585
*/
8686
private function checkFunctions(array $uses): array
@@ -117,13 +117,13 @@ private function checkFunctions(array $uses): array
117117
}
118118

119119
/**
120-
* @param Node\Stmt\UseUse[] $uses
120+
* @param Node\UseItem[] $uses
121121
* @return list<IdentifierRuleError>
122122
*/
123123
private function checkClasses(array $uses): array
124124
{
125125
return $this->classCaseSensitivityCheck->checkClassNames(
126-
array_map(static fn (Node\Stmt\UseUse $use): ClassNameNodePair => new ClassNameNodePair((string) $use->name, $use->name), $uses),
126+
array_map(static fn (Node\UseItem $use): ClassNameNodePair => new ClassNameNodePair((string) $use->name, $use->name), $uses),
127127
);
128128
}
129129

src/Rules/PhpDoc/InvalidPhpDocVarTagTypeRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function processNode(Node $node, Scope $scope): array
4848
{
4949
if (
5050
$node instanceof Node\Stmt\Property
51-
|| $node instanceof Node\Stmt\PropertyProperty
5251
|| $node instanceof Node\Stmt\ClassConst
5352
|| $node instanceof Node\Stmt\Const_
5453
) {

src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function processNode(Node $node, Scope $scope): array
5151
{
5252
if (
5353
$node instanceof Node\Stmt\Property
54-
|| $node instanceof Node\Stmt\PropertyProperty
5554
|| $node instanceof Node\Stmt\ClassConst
5655
|| $node instanceof Node\Stmt\Const_
5756
|| ($node instanceof VirtualNode && !$node instanceof InFunctionNode && !$node instanceof InClassMethodNode && !$node instanceof InClassNode)

src/Type/FileTypeMapper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ function (Node $node) use ($fileName, $lookForTrait, $phpDocNodeMap, &$traitFoun
516516
&& !$node instanceof Node\Stmt\Namespace_
517517
&& !$node instanceof Node\Stmt\Declare_
518518
&& !$node instanceof Node\Stmt\Use_
519-
&& !$node instanceof Node\Stmt\UseUse
520519
&& !$node instanceof Node\Stmt\GroupUse
521520
&& !$node instanceof Node\Stmt\TraitUse
522521
&& !$node instanceof Node\Stmt\TraitUseAdaptation

0 commit comments

Comments
 (0)