diff --git a/src/Psalm/DocComment.php b/src/Psalm/DocComment.php index 6f5a648c0..03df65468 100644 --- a/src/Psalm/DocComment.php +++ b/src/Psalm/DocComment.php @@ -151,7 +151,7 @@ class DocComment 'generator-return', 'ignore-falsable-return', 'variadic', 'pure', 'ignore-variable-method', 'ignore-variable-property', 'internal', 'taint-sink', 'taint-source', 'assert-untainted', 'scope-this', - 'mutation-free', 'external-mutation-free', 'immutable', + 'mutation-free', 'external-mutation-free', 'immutable', 'readonly', ], true )) { @@ -274,7 +274,7 @@ class DocComment 'generator-return', 'ignore-falsable-return', 'variadic', 'pure', 'ignore-variable-method', 'ignore-variable-property', 'internal', 'taint-sink', 'taint-source', 'assert-untainted', 'scope-this', - 'mutation-free', 'external-mutation-free', 'immutable', + 'mutation-free', 'external-mutation-free', 'immutable', 'readonly', ], true )) { diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php index 8eac0ee54..7c3f696ca 100644 --- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php @@ -179,7 +179,8 @@ class CommentAnalyzer $var_comment->type_end = $type_end; $var_comment->deprecated = isset($parsed_docblock['specials']['deprecated']); $var_comment->internal = isset($parsed_docblock['specials']['internal']); - $var_comment->readonly = isset($parsed_docblock['specials']['readonly']); + $var_comment->readonly = isset($parsed_docblock['specials']['readonly']) + || isset($parsed_docblock['specials']['psalm-readonly']); if (isset($parsed_docblock['specials']['psalm-internal'])) { $psalm_internal = reset($parsed_docblock['specials']['psalm-internal']); if ($psalm_internal) { @@ -201,12 +202,14 @@ class CommentAnalyzer if (!$var_comments && (isset($parsed_docblock['specials']['deprecated']) || isset($parsed_docblock['specials']['internal']) - || isset($parsed_docblock['specials']['readonly'])) + || isset($parsed_docblock['specials']['readonly']) + || isset($parsed_docblock['specials']['psalm-readonly'])) ) { $var_comment = new VarDocblockComment(); $var_comment->deprecated = isset($parsed_docblock['specials']['deprecated']); $var_comment->internal = isset($parsed_docblock['specials']['internal']); - $var_comment->readonly = isset($parsed_docblock['specials']['readonly']); + $var_comment->readonly = isset($parsed_docblock['specials']['readonly']) + || isset($parsed_docblock['specials']['psalm-readonly']); $var_comments[] = $var_comment; }