mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 22:01:48 +01:00
Merge pull request #9400 from edsrzf/psalter-possibly-undefined
This commit is contained in:
commit
6ac2b8d5a8
@ -321,11 +321,9 @@ class VariableFetchAnalyzer
|
||||
(bool) $statements_analyzer->getBranchPoint($var_name),
|
||||
);
|
||||
} else {
|
||||
if ($codebase->alter_code) {
|
||||
if (!isset($project_analyzer->getIssuesToFix()['PossiblyUndefinedVariable'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($codebase->alter_code
|
||||
&& isset($project_analyzer->getIssuesToFix()['PossiblyUndefinedVariable'])
|
||||
) {
|
||||
$branch_point = $statements_analyzer->getBranchPoint($var_name);
|
||||
|
||||
if ($branch_point) {
|
||||
|
@ -27,6 +27,27 @@ class UnusedVariableManipulationTest extends FileManipulationTestCase
|
||||
'issues_to_fix' => ['UnusedVariable'],
|
||||
'safe_types' => true,
|
||||
],
|
||||
'dontRemovePossiblyUndefined' => [
|
||||
'input' => '<?php
|
||||
function foo(bool $b): void {
|
||||
if ($b) {
|
||||
$v = "hi";
|
||||
}
|
||||
|
||||
echo $v;
|
||||
}',
|
||||
'output' => '<?php
|
||||
function foo(bool $b): void {
|
||||
if ($b) {
|
||||
$v = "hi";
|
||||
}
|
||||
|
||||
echo $v;
|
||||
}',
|
||||
'php_version' => '7.1',
|
||||
'issues_to_fix' => ['UnusedVariable'],
|
||||
'safe_types' => true,
|
||||
],
|
||||
'removeUnusedVariableFromTry' => [
|
||||
'input' => '<?php
|
||||
class A {
|
||||
|
Loading…
x
Reference in New Issue
Block a user