Skip to content
Permalink
Browse files

Fix #2439 - fix templating of class-string<T>::returnsStatic

  • Loading branch information
muglug committed Dec 9, 2019
1 parent 69e6624 commit e3d108ebd9511ca625a556dcb579aa4b4fee5da3
@@ -891,7 +891,8 @@ function (PhpParser\Node\Arg $arg) {
$lhs_type_part->param_name,
$lhs_type_part->as_type
? new Type\Union([$lhs_type_part->as_type])
: Type::getObject()
: Type::getObject(),
$lhs_type_part->defining_class
);
} else {
$static_type = $fq_class_name;
@@ -2131,6 +2131,41 @@ function __construct(array $arr) {
*/
function copyMapUsingProperty(Map $map): Map {
return new Map($map->arr);
}',
],
'mapStaticClassTemplatedFromClassString' => [
'<?php
class Base {
/** @return static */
public static function factory(): self {
return new self();
}
}
/**
* @template T of Base
* @param class-string<T> $t
* @return T
*/
function f(string $t) {
return $t::factory();
}
/** @template T of Base */
class C {
/** @var class-string<T> */
private string $t;
/** @param class-string<T> $t */
public function __construct($t) {
$this->t = $t;
}
/** @return T */
public function f(): Base {
$t = $this->t;
return $t::factory();
}
}'
],
];

0 comments on commit e3d108e

Please sign in to comment.
You can’t perform that action at this time.