Skip to content
Permalink
Browse files

Fix #2475 - allow iterable covariance

  • Loading branch information
muglug committed Dec 16, 2019
1 parent 529efaa commit bdbc758ddcd072898497263bd4f09c47daebada6
Showing with 30 additions and 0 deletions.
  1. +1 −0 src/Psalm/Type/Atomic/GenericTrait.php
  2. +29 −0 tests/Template/ClassTemplateCovarianceTest.php
@@ -311,6 +311,7 @@ public function checkGenericParams(
&& $source->getMethodName() !== '__construct'
&& empty($expected_param_covariants[$i])
&& !$this instanceof TArray
&& !$this instanceof TIterable
) === false) {
return false;
}
@@ -415,6 +415,35 @@ public function foo(): array {
}
}',
],
'allowIteratorCovariance' => [
'<?php
/**
* @template-covariant T
*/
interface ITraversable
{
/** @psalm-return Traversable<T> */
public function foo(): Traversable;
}
/**
* @template-covariant T
*/
interface IArray
{
/** @psalm-return array<T> */
public function foo(): array;
}
/**
* @template-covariant T
*/
interface IIterable
{
/** @psalm-return iterable<T> */
public function foo(): iterable;
}',
],
];
}

0 comments on commit bdbc758

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