Skip to content
Permalink
Browse files

Fix #1676 - don’t modify original param types with templated by-refer…

…ence
  • Loading branch information...
muglug committed May 24, 2019
1 parent 62dacaf commit 9fb96793cdc209c8d8622f75980fefbfea695e7b
@@ -1455,7 +1455,7 @@ private static function handlePossiblyMatchingByRefParam(
$generic_params = [];
}
$original_by_ref_type = $by_ref_type;
$original_by_ref_type = clone $by_ref_type;
$by_ref_type = clone $by_ref_type;
@@ -2538,6 +2538,40 @@ public function getMe() {
'$a' => 'C&I<C>'
]
],
'dontModifyByRefTemplatedArray' => [
'<?php
class A {}
class B {}
/**
* @template T of object
* @param class-string<T> $className
* @param array<T> $map
* @param-out array<T> $map
* @param int $id
* @return T
*/
function get(string $className, array &$map, int $id) {
if(!array_key_exists($id, $map)) {
$map[$id] = new $className();
}
return $map[$id];
}
/**
* @param array<A> $mapA
*/
function getA(int $id, array $mapA): A {
return get(A::class, $mapA, $id);
}
/**
* @param array<B> $mapB
*/
function getB(int $id, array $mapB): B {
return get(B::class, $mapB, $id);
}'
],
];
}

0 comments on commit 9fb9679

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