1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #249 - get out of nested class

This commit is contained in:
Matt Brown 2017-10-19 14:40:38 -04:00
parent 2e00fb19ee
commit dbcec1be38
2 changed files with 18 additions and 2 deletions

View File

@ -408,7 +408,7 @@ class DependencyFinderVisitor extends PhpParser\NodeVisitorAbstract implements P
throw new \LogicException('$this->fq_classlike_names should not be empty');
}
$fq_classlike_name = $this->fq_classlike_names[count($this->fq_classlike_names) - 1];
$fq_classlike_name = array_pop($this->fq_classlike_names);
if (ClassLikeChecker::inPropertyMap($fq_classlike_name)) {
$public_mapped_properties = ClassLikeChecker::getPropertyMap()[strtolower($fq_classlike_name)];

View File

@ -135,11 +135,27 @@ class Php70Test extends TestCase
$x = g($class->f());',
],
'anonymousClassStatement' => [
'<?php
new class {};',
],
'anonymousClassTwoFunctions' => [
'<?php
interface I {}
class A
{
/** @var ?I */
protected $i;
public function foo(): void
{
$this->i = new class implements I {};
}
public function foo2() : void {} // commenting this line out fixes
}',
],
'returnAnonymousClass' => [
'<?php
/** @return object */