diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index aafb4b096..85f196d58 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -483,6 +483,18 @@ class ClassAnalyzer extends ClassLikeAnalyzer /** @var non-empty-array $mixins */ $mixins = array_merge($storage->templatedMixins, $storage->namedMixins); $union = new Type\Union($mixins); + + $static_self = new Type\Atomic\TNamedObject($storage->name); + $static_self->was_static = true; + + $union = \Psalm\Internal\Type\TypeExpander::expandUnion( + $codebase, + $union, + $storage->name, + $static_self, + null + ); + $union->check( $this, new CodeLocation( diff --git a/src/Psalm/Internal/TypeVisitor/TypeChecker.php b/src/Psalm/Internal/TypeVisitor/TypeChecker.php index a8442bd31..689043651 100644 --- a/src/Psalm/Internal/TypeVisitor/TypeChecker.php +++ b/src/Psalm/Internal/TypeVisitor/TypeChecker.php @@ -259,7 +259,7 @@ class TypeChecker extends NodeVisitor $codebase, $expected_type_param, $defining_class, - $defining_class, + null, null ); @@ -267,7 +267,7 @@ class TypeChecker extends NodeVisitor $codebase, $type_param, $defining_class, - $defining_class, + null, null ); diff --git a/tests/MixinAnnotationTest.php b/tests/MixinAnnotationTest.php index 7e24882ed..0872eb700 100644 --- a/tests/MixinAnnotationTest.php +++ b/tests/MixinAnnotationTest.php @@ -554,13 +554,40 @@ class MixinAnnotationTest extends TestCase */ class Bar { - + } $bar = new Bar(); $bar->foo();' ], + 'templatedMixinBindStatic' => [ + ' + */ + public function getInner() { + return []; + } + } + + /** + * @mixin QueryBuilder + */ + abstract class Model {} + + class FooModel extends Model {} + + $f = new FooModel(); + $g = $f->getInner();', + [ + '$g' => 'list', + ] + ], ]; }