1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge branch '4.x' into upstream-master

This commit is contained in:
Bruce Weirdan 2022-01-06 10:05:53 +02:00
commit 3fb3db3516
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D
3 changed files with 26 additions and 3 deletions

View File

@ -3558,7 +3558,7 @@ class AssertionFinder
// - 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 {

View File

@ -103,7 +103,7 @@ class ReflectionMethod implements Reflector
public function isStatic(): bool {}
}
class ReflectionClassConstant
class ReflectionClassConstant implements Reflector
{
/**
* @since 8.0
@ -117,7 +117,7 @@ class ReflectionClassConstant
/**
* @psalm-immutable
*/
class ReflectionParameter {
class ReflectionParameter implements Reflector {
/**
* @psalm-assert-if-true ReflectionType $this->getType()
*/

View File

@ -1898,6 +1898,29 @@ class AssertAnnotationTest extends TestCase
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
/**