Skip to content

Commit 749e915

Browse files
committed
Rest of src/ changes
1 parent 0c75b80 commit 749e915

20 files changed

+44
-43
lines changed

phpstan-baseline.neon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,3 +1783,19 @@ parameters:
17831783
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\\.$#"
17841784
count: 1
17851785
path: tests/PHPStan/Type/IterableTypeTest.php
1786+
1787+
-
1788+
message: """
1789+
#^Instantiation of deprecated class PHPStan\\\\Rules\\\\Arrays\\\\EmptyArrayItemRule\\:
1790+
Since PHP\\-Parser 5\\.0 this is a parse error\\.$#
1791+
"""
1792+
count: 1
1793+
path: tests/PHPStan/Rules/Arrays/EmptyArrayItemRuleTest.php
1794+
1795+
-
1796+
message: """
1797+
#^Return type of method PHPStan\\\\Rules\\\\Arrays\\\\EmptyArrayItemRuleTest\\:\\:getRule\\(\\) has typehint with deprecated class PHPStan\\\\Rules\\\\Arrays\\\\EmptyArrayItemRule\\:
1798+
Since PHP\\-Parser 5\\.0 this is a parse error\\.$#
1799+
"""
1800+
count: 1
1801+
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
@@ -456,10 +456,6 @@ private function considerArrayForCallableTest(Scope $scope, Array_ $arrayNode):
456456
return false;
457457
}
458458

459-
if ($items[0] === null) {
460-
return false;
461-
}
462-
463459
$itemType = $scope->getType($items[0]->value);
464460
return $itemType->isClassStringType()->yes();
465461
}

src/Node/ClassPropertiesNode.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@ private function collectUninitializedProperties(array $constructors, array $unin
267267
$statementResult = $executionEnd->getStatementResult();
268268
$endNode = $executionEnd->getNode();
269269
if ($statementResult->isAlwaysTerminating()) {
270-
if ($endNode instanceof Node\Stmt\Throw_) {
271-
continue;
272-
}
273270
if ($endNode instanceof Node\Stmt\Expression) {
274271
$exprType = $statementResult->getScope()->getType($endNode->expr);
275272
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;
@@ -72,28 +72,28 @@ public function getPhpDocType(): ?Type
7272

7373
public function isPublic(): bool
7474
{
75-
return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
76-
|| ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
75+
return ($this->flags & Modifiers::PUBLIC) !== 0
76+
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
7777
}
7878

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

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

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

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

9999
public function isReadOnlyByPhpDoc(): bool

src/Node/ClassStatementsGatherer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ private function gatherNodes(Node $node, Scope $scope): void
204204
$this->propertyUsages[] = new PropertyWrite($node->expr, $scope, false);
205205
return;
206206
}
207-
if ($node instanceof Node\Scalar\EncapsedStringPart) {
208-
return;
209-
}
210207
if ($node instanceof FunctionCallableNode) {
211208
$node = $node->getOriginalNode();
212209
} 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
/** @api */

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
@@ -495,10 +495,6 @@ public function getArrayType(Expr\Array_ $expr, callable $getTypeCallback): Type
495495
$arrayBuilder = ConstantArrayTypeBuilder::createEmpty();
496496
$isList = null;
497497
foreach ($expr->items as $arrayItem) {
498-
if ($arrayItem === null) {
499-
continue;
500-
}
501-
502498
$valueType = $getTypeCallback($arrayItem->value);
503499
if ($arrayItem->unpack) {
504500
if (count($valueType->getConstantArrays()) === 1) {

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)