mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #2181 - prevent class template types being wiped by anonymous class use
This commit is contained in:
parent
81464d8dbf
commit
9af8a9ac38
@ -632,7 +632,9 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
||||
$this->file_storage->has_docblock_issues = true;
|
||||
}
|
||||
|
||||
$this->class_template_types = [];
|
||||
if ($node->name) {
|
||||
$this->class_template_types = [];
|
||||
}
|
||||
|
||||
if ($this->after_classlike_check_plugins) {
|
||||
$file_manipulations = [];
|
||||
|
@ -1703,6 +1703,25 @@ class ClassTemplateTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'anonymousClassMustNotBreakParentTemplate' => [
|
||||
'<?php
|
||||
/** @template T */
|
||||
class Foo {
|
||||
/** @psalm-var ?T */
|
||||
private $value;
|
||||
|
||||
/** @psalm-param T $val */
|
||||
public function set($val) : void {
|
||||
$this->value = $val;
|
||||
new class extends Foo {};
|
||||
}
|
||||
|
||||
/** @psalm-return ?T */
|
||||
public function get() {
|
||||
return $this->value;
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user