Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Analyser/ExprHandler/AssignHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public function processAssignVar(
$throwPoints = array_merge($throwPoints, $keyResult->getThrowPoints());
$impurePoints = array_merge($impurePoints, $keyResult->getImpurePoints());
$isAlwaysTerminating = $isAlwaysTerminating || $keyResult->isAlwaysTerminating();
// no need for $keyResult->getScope()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol ;)

$scope = $keyResult->getScope();
}

if ($arrayItem->key === null) {
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-14019.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php declare(strict_types = 1);

namespace Bug14019;

use function PHPStan\Testing\assertType;

[($a = 'foo') => $b] = ['foo' => 1];

assertType("'foo'", $a);
assertType('1', $b);
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,16 @@ public function testBug6830(): void
$this->analyse([__DIR__ . '/data/bug-6830.php'], []);
}

public function testBug14019(): void
{
$this->cliArgumentsVariablesRegistered = true;
$this->polluteScopeWithLoopInitialAssignments = false;
$this->checkMaybeUndefinedVariables = true;
$this->polluteScopeWithAlwaysIterableForeach = true;

$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-14019.php'], []);
}

public function testBug14117(): void
{
$this->cliArgumentsVariablesRegistered = true;
Expand Down
Loading