Skip to content
Permalink
Browse files

Fix #2326 - substitute static more responsibly in generic objects

  • Loading branch information
muglug committed Nov 12, 2019
1 parent b1aae0d commit 7012bedf4e2d2cad676ce9191ab31408a82619c2
@@ -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

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