mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
parent
16fa208a60
commit
a93bf28532
@ -32,6 +32,7 @@ use Psalm\Type;
|
||||
use function is_string;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -342,6 +343,7 @@ class AssignmentAnalyzer
|
||||
if (!$assign_var instanceof PhpParser\Node\Expr\PropertyFetch
|
||||
&& !strpos($root_var_id ?? '', '->')
|
||||
&& !$comment_type
|
||||
&& substr($var_id ?? '', 0, 2) !== '$_'
|
||||
) {
|
||||
if (IssueBuffer::accepts(
|
||||
new MixedAssignment(
|
||||
|
@ -787,6 +787,17 @@ class ReturnTypeTest extends TestCase
|
||||
'$res' => 'iterable<mixed, string>',
|
||||
],
|
||||
],
|
||||
'mixedAssignmentWithUnderscore' => [
|
||||
'<?php
|
||||
$gen = (function (): Generator {
|
||||
yield 1 => \'a\';
|
||||
yield 2 => \'b\';
|
||||
})();
|
||||
|
||||
foreach ($gen as $k => $_) {
|
||||
echo "$k\n";
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -674,7 +674,6 @@ class UnusedCodeTest extends TestCase
|
||||
|
||||
$items = new IterableResult();
|
||||
|
||||
/** @psalm-suppress MixedAssignment */
|
||||
foreach ($items as $_item) {}'
|
||||
],
|
||||
'usedThroughNewClassStringOfBase' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user