mirror of
https://github.com/nextcloud/server.git
synced 2026-03-21 18:11:02 -04:00
Merge pull request #49570 from nextcloud/debt/check-enums-for-experimental
This commit is contained in:
commit
7aba0300a8
3 changed files with 55 additions and 22 deletions
|
|
@ -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');
|
||||
}
|
||||
|
||||
foreach ($stmt->getConstants() as $constant) {
|
||||
self::checkMethodOrConstantComment($constant, $statementsSource, 'constant');
|
||||
if ($stmt instanceof ClassMethod) {
|
||||
self::checkStatementComment($stmt, $statementsSource, 'method');
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
||||
foreach ($stmt->getConstants() as $constant) {
|
||||
self::checkMethodOrConstantComment($constant, $statementsSource, 'constant');
|
||||
if ($stmt instanceof ClassMethod) {
|
||||
self::checkStatementComment($stmt, $statementsSource, 'method');
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -18,17 +18,35 @@ use UnhandledMatchError;
|
|||
* @since 31.0.0
|
||||
*/
|
||||
enum ValueType: int {
|
||||
/** @since 31.0.0 */
|
||||
/**
|
||||
* @experimental 31.0.0
|
||||
* @since 31.0.0
|
||||
*/
|
||||
case MIXED = 0;
|
||||
/** @since 31.0.0 */
|
||||
/**
|
||||
* @experimental 31.0.0
|
||||
* @since 31.0.0
|
||||
*/
|
||||
case STRING = 1;
|
||||
/** @since 31.0.0 */
|
||||
/**
|
||||
* @experimental 31.0.0
|
||||
* @since 31.0.0
|
||||
*/
|
||||
case INT = 2;
|
||||
/** @since 31.0.0 */
|
||||
/**
|
||||
* @experimental 31.0.0
|
||||
* @since 31.0.0
|
||||
*/
|
||||
case FLOAT = 3;
|
||||
/** @since 31.0.0 */
|
||||
/**
|
||||
* @experimental 31.0.0
|
||||
* @since 31.0.0
|
||||
*/
|
||||
case BOOL = 4;
|
||||
/** @since 31.0.0 */
|
||||
/**
|
||||
* @experimental 31.0.0
|
||||
* @since 31.0.0
|
||||
*/
|
||||
case ARRAY = 5;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue