Permalink
Browse files
Fix #2326 - substitute static more responsibly in generic objects
- Loading branch information
|
@@ -1160,7 +1160,13 @@ private static function fleshOutAtomicType( |
|
|
if (is_string($static_class_type)) { |
|
|
$return_type->value = $static_class_type; |
|
|
} else { |
|
|
$return_type = clone $static_class_type; |
|
|
if ($return_type instanceof Type\Atomic\TGenericObject |
|
|
&& $static_class_type instanceof Type\Atomic\TNamedObject |
|
|
) { |
|
|
$return_type->value = $static_class_type->value; |
|
|
} else { |
|
|
$return_type = clone $static_class_type; |
|
|
} |
|
|
} |
|
|
} elseif ($return_type_lc === 'self') { |
|
|
if (!$self_class) { |
|
|
|
@@ -2102,6 +2102,37 @@ function withParams(Traversable $t) : array { |
|
|
return iterableToArray($t); |
|
|
}', |
|
|
], |
|
|
'templateStaticWithParam' => [ |
|
|
'<?php |
|
|
/** |
|
|
* @template T |
|
|
*/ |
|
|
class ArrayCollection { |
|
|
/** @var list<T> */ |
|
|
private $elements; |
|
|
|
|
|
/** |
|
|
* @param list<T> $elements |
|
|
*/ |
|
|
public function __construct(array $elements) { |
|
|
$this->elements = $elements; |
|
|
} |
|
|
|
|
|
/** |
|
|
* @template U |
|
|
* @param callable(T=):U $callback |
|
|
* @return static<U> |
|
|
*/ |
|
|
public function map(callable $callback) { |
|
|
return new static(array_values(array_map($callback, $this->elements))); |
|
|
} |
|
|
} |
|
|
|
|
|
/** @param ArrayCollection<int> $ints */ |
|
|
function takesInts(ArrayCollection $ints) :void {} |
|
|
|
|
|
takesInts((new ArrayCollection([ "a", "bc" ]))->map("strlen"));' |
|
|
], |
|
|
]; |
|
|
} |
|
|
|
|
|
0 comments on commit
7012bed