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:
commit
3fb3db3516
@ -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 {
|
||||
|
@ -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()
|
||||
*/
|
||||
|
@ -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
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user