aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2024-11-29 23:45:56 +0100
committerDaniel Kesselberg <mail@danielkesselberg.de>2024-12-02 14:30:18 +0100
commitdd3fa88b360ffbb7e60304d9aafe94e103427d95 (patch)
tree3e47e199d3576d1f037e0a50b5a3cabe960b6e62 /build
parent9fcf5a56009e069533ed16131c139bb917b80f72 (diff)
downloadnextcloud-server-dd3fa88b360ffbb7e60304d9aafe94e103427d95.tar.gz
nextcloud-server-dd3fa88b360ffbb7e60304d9aafe94e103427d95.zip
chore: check enums for since and experimental comments
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'build')
-rw-r--r--build/psalm/NcuExperimentalChecker.php25
-rw-r--r--build/psalm/OcpSinceChecker.php22
2 files changed, 31 insertions, 16 deletions
diff --git a/build/psalm/NcuExperimentalChecker.php b/build/psalm/NcuExperimentalChecker.php
index d5c24333d9e..eaa70480ccc 100644
--- a/build/psalm/NcuExperimentalChecker.php
+++ b/build/psalm/NcuExperimentalChecker.php
@@ -7,7 +7,10 @@ declare(strict_types=1);
*/
use PhpParser\Node\Stmt;
+use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\ClassLike;
+use PhpParser\Node\Stmt\ClassMethod;
+use PhpParser\Node\Stmt\EnumCase;
use Psalm\CodeLocation;
use Psalm\DocComment;
use Psalm\Exception\DocblockParseException;
@@ -18,17 +21,23 @@ use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
class NcuExperimentalChecker implements Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface {
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void {
- $stmt = $event->getStmt();
+ $classLike = $event->getStmt();
$statementsSource = $event->getStatementsSource();
- self::checkClassComment($stmt, $statementsSource);
+ self::checkClassComment($classLike, $statementsSource);
- foreach ($stmt->getMethods() as $method) {
- self::checkMethodOrConstantComment($method, $statementsSource, 'method');
- }
+ foreach ($classLike->stmts as $stmt) {
+ if ($stmt instanceof ClassConst) {
+ self::checkStatementComment($stmt, $statementsSource, 'constant');
+ }
+
+ if ($stmt instanceof ClassMethod) {
+ self::checkStatementComment($stmt, $statementsSource, 'method');
+ }
- foreach ($stmt->getConstants() as $constant) {
- self::checkMethodOrConstantComment($constant, $statementsSource, 'constant');
+ if ($stmt instanceof EnumCase) {
+ self::checkStatementComment($stmt, $statementsSource, 'enum');
+ }
}
}
@@ -76,7 +85,7 @@ class NcuExperimentalChecker implements Psalm\Plugin\EventHandler\AfterClassLike
}
}
- private static function checkMethodOrConstantComment(Stmt $stmt, FileSource $statementsSource, string $type): void {
+ private static function checkStatementComment(Stmt $stmt, FileSource $statementsSource, string $type): void {
$docblock = $stmt->getDocComment();
if ($docblock === null) {
diff --git a/build/psalm/OcpSinceChecker.php b/build/psalm/OcpSinceChecker.php
index c030678aee1..959e70e0c4c 100644
--- a/build/psalm/OcpSinceChecker.php
+++ b/build/psalm/OcpSinceChecker.php
@@ -17,17 +17,23 @@ use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
class OcpSinceChecker implements Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface {
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void {
- $stmt = $event->getStmt();
+ $classLike = $event->getStmt();
$statementsSource = $event->getStatementsSource();
- self::checkClassComment($stmt, $statementsSource);
+ self::checkClassComment($classLike, $statementsSource);
- foreach ($stmt->getMethods() as $method) {
- self::checkMethodOrConstantComment($method, $statementsSource, 'method');
- }
+ foreach ($classLike->stmts as $stmt) {
+ if ($stmt instanceof ClassConst) {
+ self::checkStatementComment($stmt, $statementsSource, 'constant');
+ }
+
+ if ($stmt instanceof ClassMethod) {
+ self::checkStatementComment($stmt, $statementsSource, 'method');
+ }
- foreach ($stmt->getConstants() as $constant) {
- self::checkMethodOrConstantComment($constant, $statementsSource, 'constant');
+ if ($stmt instanceof EnumCase) {
+ self::checkStatementComment($stmt, $statementsSource, 'enum');
+ }
}
}
@@ -75,7 +81,7 @@ class OcpSinceChecker implements Psalm\Plugin\EventHandler\AfterClassLikeVisitIn
}
}
- private static function checkMethodOrConstantComment(Stmt $stmt, FileSource $statementsSource, string $type): void {
+ private static function checkStatementComment(Stmt $stmt, FileSource $statementsSource, string $type): void {
$docblock = $stmt->getDocComment();
if ($docblock === null) {