1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Merge pull request #6672 from orklah/phpstorm-generics

prevent phpstorm generics from touching to signature types
This commit is contained in:
orklah 2021-10-14 21:25:36 +02:00 committed by GitHub
commit b8a2ba251f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -981,6 +981,11 @@ class Populator
private function convertPhpStormGenericToPsalmGeneric(Type\Union $candidate, bool $is_property = false): void
{
if (!$candidate->from_docblock) {
//never convert a type that comes from a signature
return;
}
$atomic_types = $candidate->getAtomicTypes();
if (isset($atomic_types['array']) && count($atomic_types) > 1 && !isset($atomic_types['null'])) {

View File

@ -41,6 +41,19 @@ class AnnotationTest extends TestCase
$this->analyzeFile('somefile.php', new Context());
}
public function testPhpStormGenericsWithTypeInSignature(): void
{
Config::getInstance()->allow_phpstorm_generics = true;
$this->addFile(
'somefile.php',
'<?php
function a(array|\ArrayObject $_meta = []): void {}'
);
$this->analyzeFile('somefile.php', new Context());
}
public function testPhpStormGenericsWithValidTraversableArgument(): void
{
Config::getInstance()->allow_phpstorm_generics = true;