1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add extra trait test

This commit is contained in:
Matthew Brown 2018-01-21 00:32:45 -05:00
parent 92e43b8fa0
commit 67ef894ecc
2 changed files with 28 additions and 2 deletions

View File

@ -191,12 +191,12 @@ class CallChecker
$has_valid_function_call_type = true;
} elseif ($var_type_part instanceof TMixed) {
$has_valid_function_call_type = true;
// @todo maybe emit issue here
// @todo maybe emit issue here
} elseif (($var_type_part instanceof TNamedObject && $var_type_part->value === 'Closure') ||
$var_type_part instanceof TCallable
) {
$has_valid_function_call_type = true;
// this is fine
// this is fine
} elseif ($var_type_part instanceof TNull) {
// handled above
} elseif (!$var_type_part instanceof TNamedObject ||

View File

@ -366,6 +366,32 @@ class TraitTest extends TestCase
use T;
}',
],
'namespacedTraitLookup' => [
'<?php
namespace Classes {
use Traits\T;
class A {}
class B {
use T;
}
}
namespace Traits {
use Classes\A;
trait T {
public function getA() : A {
return new A;
}
}
}
namespace {
$a = (new Classes\B)->getA();
}',
],
];
}