Skip to content

Commit eb0162f

Browse files
committed
Rest of src/ changes
1 parent e7e3dfd commit eb0162f

20 files changed

+44
-43
lines changed

phpstan-baseline.neon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,3 +1835,19 @@ parameters:
18351835
message: "#^PHPDoc tag @var assumes the expression with type PHPStan\\\\Type\\\\Generic\\\\TemplateType is always PHPStan\\\\Type\\\\Generic\\\\TemplateMixedType but it's error\\-prone and dangerous\\.$#"
18361836
count: 1
18371837
path: tests/PHPStan/Type/IterableTypeTest.php
1838+
1839+
-
1840+
message: """
1841+
#^Instantiation of deprecated class PHPStan\\\\Rules\\\\Arrays\\\\EmptyArrayItemRule\\:
1842+
Since PHP\\-Parser 5\\.0 this is a parse error\\.$#
1843+
"""
1844+
count: 1
1845+
path: tests/PHPStan/Rules/Arrays/EmptyArrayItemRuleTest.php
1846+
1847+
-
1848+
message: """
1849+
#^Return type of method PHPStan\\\\Rules\\\\Arrays\\\\EmptyArrayItemRuleTest\\:\\:getRule\\(\\) has typehint with deprecated class PHPStan\\\\Rules\\\\Arrays\\\\EmptyArrayItemRule\\:
1850+
Since PHP\\-Parser 5\\.0 this is a parse error\\.$#
1851+
"""
1852+
count: 1
1853+
path: tests/PHPStan/Rules/Arrays/EmptyArrayItemRuleTest.php

src/Dependency/DependencyResolver.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,6 @@ private function considerArrayForCallableTest(Scope $scope, Array_ $arrayNode):
479479
return false;
480480
}
481481

482-
if ($items[0] === null) {
483-
return false;
484-
}
485-
486482
$itemType = $scope->getType($items[0]->value);
487483
return $itemType->isClassStringType()->yes();
488484
}

src/Node/ClassPropertiesNode.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,6 @@ private function collectUninitializedProperties(array $constructors, array $unin
271271
$statementResult = $executionEnd->getStatementResult();
272272
$endNode = $executionEnd->getNode();
273273
if ($statementResult->isAlwaysTerminating()) {
274-
if ($endNode instanceof Node\Stmt\Throw_) {
275-
continue;
276-
}
277274
if ($endNode instanceof Node\Stmt\Expression) {
278275
$exprType = $statementResult->getScope()->getType($endNode->expr);
279276
if ($exprType instanceof NeverType && $exprType->isExplicit()) {

src/Node/ClassPropertyNode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace PHPStan\Node;
44

5+
use PhpParser\Modifiers;
56
use PhpParser\Node;
67
use PhpParser\Node\Expr;
78
use PhpParser\Node\Identifier;
89
use PhpParser\Node\Name;
9-
use PhpParser\Node\Stmt\Class_;
1010
use PhpParser\NodeAbstract;
1111
use PHPStan\Reflection\ClassReflection;
1212
use PHPStan\Type\Type;
@@ -75,28 +75,28 @@ public function getPhpDocType(): ?Type
7575

7676
public function isPublic(): bool
7777
{
78-
return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
79-
|| ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
78+
return ($this->flags & Modifiers::PUBLIC) !== 0
79+
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
8080
}
8181

8282
public function isProtected(): bool
8383
{
84-
return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
84+
return (bool) ($this->flags & Modifiers::PROTECTED);
8585
}
8686

8787
public function isPrivate(): bool
8888
{
89-
return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
89+
return (bool) ($this->flags & Modifiers::PRIVATE);
9090
}
9191

9292
public function isStatic(): bool
9393
{
94-
return (bool) ($this->flags & Class_::MODIFIER_STATIC);
94+
return (bool) ($this->flags & Modifiers::STATIC);
9595
}
9696

9797
public function isReadOnly(): bool
9898
{
99-
return (bool) ($this->flags & Class_::MODIFIER_READONLY) || $this->isReadonlyClass;
99+
return (bool) ($this->flags & Modifiers::READONLY) || $this->isReadonlyClass;
100100
}
101101

102102
public function isReadOnlyByPhpDoc(): bool

src/Node/ClassStatementsGatherer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ private function gatherNodes(Node $node, Scope $scope): void
221221
$this->propertyUsages[] = new PropertyWrite($node->expr, $scope, false);
222222
return;
223223
}
224-
if ($node instanceof Node\Scalar\EncapsedStringPart) {
225-
return;
226-
}
227224
if ($node instanceof FunctionCallableNode) {
228225
$node = $node->getOriginalNode();
229226
} elseif ($node instanceof InstantiationCallableNode) {

src/Node/LiteralArrayItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPStan\Node;
44

5-
use PhpParser\Node\Expr\ArrayItem;
5+
use PhpParser\Node\ArrayItem;
66
use PHPStan\Analyser\Scope;
77

88
/**

src/Parser/LastConditionVisitor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public function enterNode(Node $node): ?Node
1818
$lastElseIf = count($node->elseifs) - 1;
1919

2020
$elseIsMissingOrThrowing = $node->else === null
21-
|| (count($node->else->stmts) === 1 && $node->else->stmts[0] instanceof Node\Stmt\Throw_);
21+
|| (
22+
count($node->else->stmts) === 1
23+
&& $node->else->stmts[0] instanceof Node\Stmt\Expression
24+
&& $node->else->stmts[0]->expr instanceof Node\Expr\Throw_
25+
);
2226

2327
foreach ($node->elseifs as $i => $elseif) {
2428
$isLast = $i === $lastElseIf && $elseIsMissingOrThrowing;

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,6 @@ public function getArrayType(Expr\Array_ $expr, callable $getTypeCallback): Type
525525
$arrayBuilder = ConstantArrayTypeBuilder::createEmpty();
526526
$isList = null;
527527
foreach ($expr->items as $arrayItem) {
528-
if ($arrayItem === null) {
529-
continue;
530-
}
531-
532528
$valueType = $getTypeCallback($arrayItem->value);
533529
if ($arrayItem->unpack) {
534530
$constantArrays = $valueType->getConstantArrays();

src/Rules/Arrays/ArrayDestructuringRule.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getNodeType(): string
4040

4141
public function processNode(Node $node, Scope $scope): array
4242
{
43-
if (!$node->var instanceof Node\Expr\List_ && !$node->var instanceof Node\Expr\Array_) {
43+
if (!$node->var instanceof Node\Expr\List_) {
4444
return [];
4545
}
4646

@@ -52,10 +52,9 @@ public function processNode(Node $node, Scope $scope): array
5252
}
5353

5454
/**
55-
* @param Node\Expr\List_|Node\Expr\Array_ $var
5655
* @return list<IdentifierRuleError>
5756
*/
58-
private function getErrors(Scope $scope, Expr $var, Expr $expr): array
57+
private function getErrors(Scope $scope, Node\Expr\List_ $var, Expr $expr): array
5958
{
6059
$exprTypeResult = $this->ruleLevelHelper->findTypeToCheck(
6160
$scope,
@@ -100,7 +99,7 @@ private function getErrors(Scope $scope, Expr $var, Expr $expr): array
10099
);
101100
$errors = array_merge($errors, $itemErrors);
102101

103-
if (!$item->value instanceof Node\Expr\List_ && !$item->value instanceof Node\Expr\Array_) {
102+
if (!$item->value instanceof Node\Expr\List_) {
104103
$i++;
105104
continue;
106105
}

src/Rules/Arrays/ArrayUnpackingRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace PHPStan\Rules\Arrays;
44

55
use PhpParser\Node;
6-
use PhpParser\Node\Expr\ArrayItem;
6+
use PhpParser\Node\ArrayItem;
77
use PHPStan\Analyser\Scope;
88
use PHPStan\Node\Expr\GetIterableKeyTypeExpr;
99
use PHPStan\Php\PhpVersion;

0 commit comments

Comments
 (0)