mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Prevent @property annotations on class properties
This commit is contained in:
parent
2e7763c314
commit
1df5f3012a
@ -1282,6 +1282,13 @@ class ClassLikeNodeScanner
|
||||
$property_is_initialized = true;
|
||||
}
|
||||
|
||||
if (preg_match('/[ \t\*]+@property[ \t]+/', (string)$comment)) {
|
||||
$storage->docblock_issues[] = new InvalidDocblock(
|
||||
'@property is valid only in docblocks for class',
|
||||
new CodeLocation($this->file_scanner, $stmt, null, true)
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$var_comments = CommentAnalyzer::getTypeFromComment(
|
||||
$comment,
|
||||
|
@ -1146,6 +1146,14 @@ class MagicPropertyTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'UndefinedMagicPropertyAssignment',
|
||||
],
|
||||
'propertyDocblockOnProperty' => [
|
||||
'<?php
|
||||
class A {
|
||||
/** @property string[] */
|
||||
public array $arr;
|
||||
}',
|
||||
'error_message' => 'InvalidDocblock'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user