Skip to content
Permalink
Browse files

Support @psalm-readonly too

  • Loading branch information...
muglug committed Sep 8, 2019
1 parent 662f094 commit 78175c9765187d596da008ab196c1eeb41f0fa2e
Showing with 8 additions and 5 deletions.
  1. +2 −2 src/Psalm/DocComment.php
  2. +6 −3 src/Psalm/Internal/Analyzer/CommentAnalyzer.php
@@ -151,7 +151,7 @@ public static function parse($docblock, $line_number = null, $preserve_format =
'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 @@ public static function parsePreservingLength(\PhpParser\Comment\Doc $docblock)
'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
)) {
@@ -179,7 +179,8 @@ public static function arrayToDocblocks(
$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 @@ public static function arrayToDocblocks(
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;
}

0 comments on commit 78175c9

Please sign in to comment.
You can’t perform that action at this time.