1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix parsing of array keys with @

This commit is contained in:
Daniil Gentili 2023-11-29 13:32:45 +01:00
parent a3024adc46
commit e0778fcc11
2 changed files with 13 additions and 1 deletions

View File

@ -830,7 +830,11 @@ final class ParseTreeCreator
$nexter_token = $this->t + 1 < $this->type_token_count ? $this->type_tokens[$this->t + 1] : null;
if ($nexter_token && strpos($nexter_token[0], '@') !== false) {
if ($nexter_token
&& strpos($nexter_token[0], '@') !== false
&& $type_token[0] !== 'list'
&& $type_token[0] !== 'array'
) {
$this->t = $this->type_token_count;
if ($type_token[0] === '$this') {
$type_token[0] = 'static';

View File

@ -15,6 +15,14 @@ class TypeAnnotationTest extends TestCase
public function providerValidCodeParse(): iterable
{
return [
'atInArrayKey' => [
'code' => '<?php
/**
* @param list<array{"@a": "test"}> $v
*/
function a(array $v): void {}',
],
'typeAliasBeforeClass' => [
'code' => '<?php
namespace Barrr;