Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Fixer/PhpdocNoIncorrectVarAnnotationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
}

// remove ones not having type at the beginning
self::removeVarAnnotationNotMatchingPattern($tokens, $index, '/@var\\s+[\\?\\\\a-zA-Z_\\x7f-\\xff]/');
self::removeVarAnnotationNotMatchingPattern($tokens, $index, '/@var\\s+[\\?\\\\a-zA-Z_\\x7f-\\xff\'"]/');

$nextIndex = self::getIndexAfterPhpDoc($tokens, $index);

Expand Down
27 changes: 27 additions & 0 deletions tests/Fixer/PhpdocNoIncorrectVarAnnotationFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,33 @@ class Foo
}',
];

yield 'keep string literals' => [
<<<'PHP'
<?php class Foo
{
/**
* @var 'foo'
*/
public string $a;

/**
* @var 'foo'|'bar'|'baz'
*/
protected string $b;

/**
* @var 'foo'|'foo-with-dashes'|'bar'|'baz'|null
*/
private ?string $c;

/**
* @var "in-double-quotes"|null
*/
public ?string $d;
}
PHP,
];

yield 'remove PHPDoc for class properties' => [
'<?php
class Foo
Expand Down
Loading