Skip to content

Commit

Permalink
Merge branch '4.x' into upstream-master
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Jan 6, 2022
2 parents f3bc55e + 513b263 commit 3fb3db3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3558,7 +3558,7 @@ private static function getInarrayAssertions(
// - The array may have one of the types but not the others.
//
// NOTE: the negation of the negation is the original assertion.
if ($value_type->getId() !== '' && !$value_type->isMixed()) {
if ($value_type->getId() !== '' && !$value_type->isMixed() && !$value_type->hasTemplate()) {
$assertions[] = 'in-array-' . $value_type->getId();
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions stubs/Reflection.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ReflectionMethod implements Reflector
public function isStatic(): bool {}
}

class ReflectionClassConstant
class ReflectionClassConstant implements Reflector
{
/**
* @since 8.0
Expand All @@ -117,7 +117,7 @@ class ReflectionClassConstant
/**
* @psalm-immutable
*/
class ReflectionParameter {
class ReflectionParameter implements Reflector {
/**
* @psalm-assert-if-true ReflectionType $this->getType()
*/
Expand Down
23 changes: 23 additions & 0 deletions tests/AssertAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,29 @@ function assertBarNotNull(Foo $foo): bool
function requiresString(string $_str): void {}
',
],
'assertInArrayWithTemplateDontCrash' => [
'<?php
class A{
/**
* @template T
* @param array<T> $objects
* @return array<T>
*/
private function uniquateObjects(array $objects) : array
{
$uniqueObjects = [];
foreach ($objects as $object) {
if (in_array($object, $uniqueObjects, true)) {
continue;
}
$uniqueObjects[] = $object;
}
return $uniqueObjects;
}
}
',
],
'assertionOnMagicProperty' => [
'<?php
/**
Expand Down

0 comments on commit 3fb3db3

Please sign in to comment.