diff options
author | Joas Schilling <coding@schilljs.com> | 2024-02-14 17:28:38 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-02-14 20:50:07 +0100 |
commit | 887c061fc8de23848095d71b567a8ad413c7f9b3 (patch) | |
tree | 8714c326126b9d2af24563fabf2e832e647c70ab /build/psalm | |
parent | f14949218ce635840deb1e9a31569d97f4f85d6e (diff) | |
download | nextcloud-server-887c061fc8de23848095d71b567a8ad413c7f9b3.tar.gz nextcloud-server-887c061fc8de23848095d71b567a8ad413c7f9b3.zip |
fix(OCP): Check for typos in "deprecated"
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'build/psalm')
-rw-r--r-- | build/psalm/OcpSinceChecker.php | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/build/psalm/OcpSinceChecker.php b/build/psalm/OcpSinceChecker.php index 62b555284ac..92437a8f3ab 100644 --- a/build/psalm/OcpSinceChecker.php +++ b/build/psalm/OcpSinceChecker.php @@ -39,7 +39,11 @@ class OcpSinceChecker implements Psalm\Plugin\EventHandler\AfterClassLikeVisitIn self::checkClassComment($stmt, $statementsSource); foreach ($stmt->getMethods() as $method) { - self::checkMethodComment($method, $statementsSource); + self::checkMethodOrConstantComment($method, $statementsSource, 'method'); + } + + foreach ($stmt->getConstants() as $constant) { + self::checkMethodOrConstantComment($constant, $statementsSource, 'constant'); } } @@ -76,15 +80,24 @@ class OcpSinceChecker implements Psalm\Plugin\EventHandler\AfterClassLikeVisitIn ) ); } + + if (isset($parsedDocblock->tags['depreacted'])) { + IssueBuffer::maybeAdd( + new InvalidDocblock( + 'Typo in @deprecated for classes/interfaces in OCP.', + new CodeLocation($statementsSource, $stmt) + ) + ); + } } - private static function checkMethodComment(Stmt $stmt, FileSource $statementsSource): void { + private static function checkMethodOrConstantComment(Stmt $stmt, FileSource $statementsSource, string $type): void { $docblock = $stmt->getDocComment(); if ($docblock === null) { IssueBuffer::maybeAdd( new InvalidDocblock( - 'PHPDoc is required for methods in OCP.', + 'PHPDoc is required for ' . $type . 's in OCP.', new CodeLocation($statementsSource, $stmt) ), ); @@ -106,7 +119,16 @@ class OcpSinceChecker implements Psalm\Plugin\EventHandler\AfterClassLikeVisitIn if (!isset($parsedDocblock->tags['since'])) { IssueBuffer::maybeAdd( new InvalidDocblock( - '@since is required for methods in OCP.', + '@since is required for ' . $type . 's in OCP.', + new CodeLocation($statementsSource, $stmt) + ) + ); + } + + if (isset($parsedDocblock->tags['depreacted'])) { + IssueBuffer::maybeAdd( + new InvalidDocblock( + 'Typo in @deprecated for ' . $type . ' in OCP.', new CodeLocation($statementsSource, $stmt) ) ); |