From 74981a4e680e4586b25ac0a679add084112cd604 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 30 Aug 2023 13:02:49 +0200 Subject: [PATCH] apply PSR-12 constant visibility rule PSR-12 says constants need their visibility declared from PHP 7.1 onwards --- _test/phpcs_MigrationAdjustments.xml | 1 - _test/rector.php | 1 - inc/ActionRouter.php | 2 +- inc/Debug/DebugHelper.php | 2 +- inc/ErrorHandler.php | 2 +- inc/Extension/PluginController.php | 2 +- inc/Logger.php | 6 +++--- inc/Menu/Item/AbstractItem.php | 6 +++--- inc/Parsing/Handler/Lists.php | 2 +- inc/Remote/ApiCore.php | 2 +- inc/Utf8/Asian.php | 2 +- inc/parser/metadata.php | 4 ++-- 12 files changed, 15 insertions(+), 17 deletions(-) diff --git a/_test/phpcs_MigrationAdjustments.xml b/_test/phpcs_MigrationAdjustments.xml index b56ffc12b..c0c3688cd 100644 --- a/_test/phpcs_MigrationAdjustments.xml +++ b/_test/phpcs_MigrationAdjustments.xml @@ -77,7 +77,6 @@ - diff --git a/_test/rector.php b/_test/rector.php index fb5a2b7e2..3eb0de728 100644 --- a/_test/rector.php +++ b/_test/rector.php @@ -88,7 +88,6 @@ return static function (RectorConfig $rectorConfig): void { IssetOnPropertyObjectToPropertyExistsRector::class, // maybe? SymplifyQuoteEscapeRector::class, CatchExceptionNameMatchingTypeRector::class, - PublicConstantVisibilityRector::class, // open for discussion EncapsedStringsToSprintfRector::class, CallableThisArrayToAnonymousFunctionRector::class, StaticClosureRector::class, diff --git a/inc/ActionRouter.php b/inc/ActionRouter.php index f4a7ba842..8af8250fa 100644 --- a/inc/ActionRouter.php +++ b/inc/ActionRouter.php @@ -26,7 +26,7 @@ class ActionRouter { protected $transitions = 0; /** maximum loop */ - const MAX_TRANSITIONS = 5; + protected const MAX_TRANSITIONS = 5; /** @var string[] the actions disabled in the configuration */ protected $disabled; diff --git a/inc/Debug/DebugHelper.php b/inc/Debug/DebugHelper.php index c645e576a..e4d420c2a 100644 --- a/inc/Debug/DebugHelper.php +++ b/inc/Debug/DebugHelper.php @@ -9,7 +9,7 @@ use dokuwiki\Logger; class DebugHelper { - const INFO_DEPRECATION_LOG_EVENT = 'INFO_DEPRECATION_LOG'; + protected const INFO_DEPRECATION_LOG_EVENT = 'INFO_DEPRECATION_LOG'; /** * Check if deprecation messages shall be handled diff --git a/inc/ErrorHandler.php b/inc/ErrorHandler.php index ab3cdcac7..8e6862fc2 100644 --- a/inc/ErrorHandler.php +++ b/inc/ErrorHandler.php @@ -15,7 +15,7 @@ class ErrorHandler * Standard error codes used in PHP errors * @see https://www.php.net/manual/en/errorfunc.constants.php */ - const ERRORCODES = [ + protected const ERRORCODES = [ 1 => 'E_ERROR', 2 => 'E_WARNING', 4 => 'E_PARSE', diff --git a/inc/Extension/PluginController.php b/inc/Extension/PluginController.php index 3e94e1ce5..dd569461f 100644 --- a/inc/Extension/PluginController.php +++ b/inc/Extension/PluginController.php @@ -13,7 +13,7 @@ use dokuwiki\ErrorHandler; class PluginController { /** @var array the types of plugins DokuWiki supports */ - const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli']; + public const PLUGIN_TYPES = ['auth', 'admin', 'syntax', 'action', 'renderer', 'helper', 'remote', 'cli']; protected $listByType = []; /** @var array all installed plugins and their enabled state [plugin=>enabled] */ diff --git a/inc/Logger.php b/inc/Logger.php index 3c924c8f7..1affc0c14 100644 --- a/inc/Logger.php +++ b/inc/Logger.php @@ -9,9 +9,9 @@ use dokuwiki\Extension\Event; */ class Logger { - const LOG_ERROR = 'error'; - const LOG_DEPRECATED = 'deprecated'; - const LOG_DEBUG = 'debug'; + public const LOG_ERROR = 'error'; + public const LOG_DEPRECATED = 'deprecated'; + public const LOG_DEBUG = 'debug'; /** @var Logger[] */ static protected $instances; diff --git a/inc/Menu/Item/AbstractItem.php b/inc/Menu/Item/AbstractItem.php index 590b16326..e64b3f827 100644 --- a/inc/Menu/Item/AbstractItem.php +++ b/inc/Menu/Item/AbstractItem.php @@ -21,11 +21,11 @@ abstract class AbstractItem { /** menu item is to be shown on desktop screens only */ - const CTX_DESKTOP = 1; + public const CTX_DESKTOP = 1; /** menu item is to be shown on mobile screens only */ - const CTX_MOBILE = 2; + public const CTX_MOBILE = 2; /** menu item is to be shown in all contexts */ - const CTX_ALL = 3; + public const CTX_ALL = 3; /** @var string name of the action, usually the lowercase class name */ protected $type = ''; diff --git a/inc/Parsing/Handler/Lists.php b/inc/Parsing/Handler/Lists.php index faea6cfca..179340f25 100644 --- a/inc/Parsing/Handler/Lists.php +++ b/inc/Parsing/Handler/Lists.php @@ -9,7 +9,7 @@ class Lists extends AbstractRewriter protected $initialDepth = 0; - const NODE = 1; + public const NODE = 1; /** @inheritdoc */ public function finalise() diff --git a/inc/Remote/ApiCore.php b/inc/Remote/ApiCore.php index 9ba0c16a3..65882d02c 100644 --- a/inc/Remote/ApiCore.php +++ b/inc/Remote/ApiCore.php @@ -18,7 +18,7 @@ define('DOKU_API_VERSION', 11); class ApiCore { /** @var int Increased whenever the API is changed */ - const API_VERSION = 11; + public const API_VERSION = 11; /** @var Api */ diff --git a/inc/Utf8/Asian.php b/inc/Utf8/Asian.php index c7baa3029..ac7b723d6 100644 --- a/inc/Utf8/Asian.php +++ b/inc/Utf8/Asian.php @@ -17,7 +17,7 @@ class Asian * needs to be treated as a word. Uses the Unicode-Ranges for Asian characters taken from * http://en.wikipedia.org/wiki/Unicode_block */ - const REGEXP = + public const REGEXP = '(?:' . '[\x{0E00}-\x{0E7F}]' . // Thai diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 855f704a6..7c8de560c 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -18,10 +18,10 @@ use dokuwiki\Utf8\PhpString; class Doku_Renderer_metadata extends Doku_Renderer { /** the approximate byte lenght to capture for the abstract */ - const ABSTRACT_LEN = 250; + public const ABSTRACT_LEN = 250; /** the maximum UTF8 character length for the abstract */ - const ABSTRACT_MAX = 500; + public const ABSTRACT_MAX = 500; /** @var array transient meta data, will be reset on each rendering */ public $meta = []; -- 2.11.4.GIT