mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #1269 - fill in object type
This commit is contained in:
parent
8b65acf15b
commit
533b92e15a
@ -873,7 +873,9 @@ class Union
|
||||
$input_atomic_type->param_name,
|
||||
$input_atomic_type->as_type
|
||||
? new Union([$input_atomic_type->as_type])
|
||||
: Type::getMixed()
|
||||
: ($input_atomic_type->as === 'object'
|
||||
? Type::getObject()
|
||||
: Type::getMixed())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1508,6 +1508,57 @@ class TemplateTest extends TestCase
|
||||
|
||||
echo Foo(DateTime::class)->format("c");',
|
||||
],
|
||||
'genericInterface' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T as object
|
||||
* @param class-string<T> $t
|
||||
* @return T
|
||||
*/
|
||||
function generic(string $t) {
|
||||
return f($t)->get();
|
||||
}
|
||||
|
||||
/** @template T as object */
|
||||
interface I {
|
||||
/** @return T */
|
||||
public function get() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T as object
|
||||
* @template-implements I<T>
|
||||
*/
|
||||
class C implements I {
|
||||
/**
|
||||
* @var T
|
||||
*/
|
||||
public $t;
|
||||
|
||||
/**
|
||||
* @param T $t
|
||||
*/
|
||||
public function __construct(object $t) {
|
||||
$this->t = $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
public function get() {
|
||||
return $this->t;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T as object
|
||||
* @param class-string<T> $t
|
||||
* @return I<T>
|
||||
*/
|
||||
function f(string $t) {
|
||||
return new C(new $t);
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user