From 89753a1eed4442359ce291b8108b9f730959a94c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 30 Mar 2026 00:55:36 +0200 Subject: [PATCH] CS fixes/src: all methods/properties/constants should have a declared visibility To not break BC, all methods/properties/constants without declared visibility have now been declared as `public`. --- src/CallRerouting.php | 8 +-- src/CodeManipulation.php | 8 +-- .../Actions/RedefinitionOfNew.php | 2 +- src/CodeManipulation/Source.php | 54 +++++++++---------- src/CodeManipulation/Stream.php | 6 +-- src/Config.php | 14 ++--- src/Exceptions.php | 12 ++--- src/Stack.php | 2 +- src/Utils.php | 2 +- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/CallRerouting.php b/src/CallRerouting.php index d7f379f..7fc05fa 100644 --- a/src/CallRerouting.php +++ b/src/CallRerouting.php @@ -605,8 +605,8 @@ function getInstantiator($class, $calledClass) class State { - static $routes = []; - static $queue = []; - static $preprocessedFiles = []; - static $routeStack = []; + public static $routes = []; + public static $queue = []; + public static $preprocessedFiles = []; + public static $routeStack = []; } diff --git a/src/CodeManipulation.php b/src/CodeManipulation.php index 9a6af2a..8a8da0e 100644 --- a/src/CodeManipulation.php +++ b/src/CodeManipulation.php @@ -181,8 +181,8 @@ function onImport($listeners) class State { - static $actions = []; - static $importListeners = []; - static $cacheIndex = []; - static $cacheIndexFile; + public static $actions = []; + public static $importListeners = []; + public static $cacheIndex = []; + public static $cacheIndexFile; } diff --git a/src/CodeManipulation/Actions/RedefinitionOfNew.php b/src/CodeManipulation/Actions/RedefinitionOfNew.php index 3db0f89..304b98e 100644 --- a/src/CodeManipulation/Actions/RedefinitionOfNew.php +++ b/src/CodeManipulation/Actions/RedefinitionOfNew.php @@ -198,5 +198,5 @@ function suspendFor(callable $function) class State { - static $enabled = true; + public static $enabled = true; } diff --git a/src/CodeManipulation/Source.php b/src/CodeManipulation/Source.php index db5d8c2..bbb705f 100644 --- a/src/CodeManipulation/Source.php +++ b/src/CodeManipulation/Source.php @@ -14,14 +14,14 @@ class Source { - const TYPE_OFFSET = 0; - const STRING_OFFSET = 1; + public const TYPE_OFFSET = 0; + public const STRING_OFFSET = 1; - const PREPEND = 'PREPEND'; - const APPEND = 'APPEND'; - const OVERWRITE = 'OVERWRITE'; + public const PREPEND = 'PREPEND'; + public const APPEND = 'APPEND'; + public const OVERWRITE = 'OVERWRITE'; - const ANY = null; + public const ANY = null; public $tokens; public $tokensByType; @@ -37,13 +37,13 @@ class Source public $tokensByLevelAndType; public $cache; - function __construct($string) + public function __construct($string) { $this->code = $string; $this->initialize(); } - function initialize() + public function initialize() { $this->tokens = Utils\tokenize($this->code); $this->tokens[] = [T_WHITESPACE, ""]; @@ -55,7 +55,7 @@ function initialize() $this->cache = []; } - function indexTokensByType() + public function indexTokensByType() { $this->tokensByType = []; foreach ($this->tokens as $offset => $token) { @@ -63,7 +63,7 @@ function indexTokensByType() } } - function collectBracketMatchings() + public function collectBracketMatchings() { $this->matchingBrackets = []; $stack = []; @@ -89,7 +89,7 @@ function collectBracketMatchings() } } - function collectLevelInfo() + public function collectLevelInfo() { $level = 0; $this->levels = []; @@ -123,7 +123,7 @@ function collectLevelInfo() Utils\appendUnder($this->levelEndings, 0, count($this->tokens) - 1); } - function has($types) + public function has($types) { foreach ((array) $types as $type) { if ($this->all($type) !== []) { @@ -133,7 +133,7 @@ function has($types) return false; } - function is($types, $offset) + public function is($types, $offset) { foreach ((array) $types as $type) { if ($this->tokens[$offset][self::TYPE_OFFSET] === $type) { @@ -143,7 +143,7 @@ function is($types, $offset) return false; } - function skip($types, $offset, $direction = 1) + public function skip($types, $offset, $direction = 1) { $offset += $direction; $types = (array) $types; @@ -156,12 +156,12 @@ function skip($types, $offset, $direction = 1) return ($direction > 0) ? INF : -1; } - function skipBack($types, $offset) + public function skipBack($types, $offset) { return $this->skip($types, $offset, -1); } - function within($types, $low, $high) + public function within($types, $low, $high) { $result = []; foreach ((array) $types as $type) { @@ -171,7 +171,7 @@ function within($types, $low, $high) return $result; } - function read($offset, $count = 1) + public function read($offset, $count = 1) { $result = ''; $pos = $offset; @@ -186,7 +186,7 @@ function read($offset, $count = 1) return $result; } - function siblings($types, $offset) + public function siblings($types, $offset) { $level = $this->levels[$offset]; $begin = Utils\lastNotGreaterThan(Utils\access($this->levelBeginnings, $level, []), $offset); @@ -203,7 +203,7 @@ function siblings($types, $offset) } } - function next($types, $offset) + public function next($types, $offset) { if (!is_array($types)) { $candidates = Utils\access($this->tokensByType, $types, []); @@ -216,7 +216,7 @@ function next($types, $offset) return $result; } - function all($types) + public function all($types) { if (!is_array($types)) { return Utils\access($this->tokensByType, $types, []); @@ -229,13 +229,13 @@ function all($types) return $result; } - function match($offset) + public function match($offset) { $offset = (string) $offset; return isset($this->matchingBrackets[$offset]) ? $this->matchingBrackets[$offset] : INF; } - function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE) + public function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE) { if ($policy === self::OVERWRITE) { $this->splices[$offset] = $splice; @@ -256,7 +256,7 @@ function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE) $this->code = null; } - function createCodeFromTokens() + public function createCodeFromTokens() { $splices = $this->splices; $code = ""; @@ -274,12 +274,12 @@ function createCodeFromTokens() $this->code = $code; } - static function junk() + public static function junk() { return [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT]; } - function __toString() + public function __toString() { if ($this->code === null) { $this->createCodeFromTokens(); @@ -287,7 +287,7 @@ function __toString() return (string) $this->code; } - function flush() + public function flush() { $this->initialize(Utils\tokenize($this)); } @@ -295,7 +295,7 @@ function flush() /** * @since 2.1.0 */ - function cache(array $args, \Closure $function) + public function cache(array $args, \Closure $function) { $found = true; $trace = debug_backtrace()[1]; diff --git a/src/CodeManipulation/Stream.php b/src/CodeManipulation/Stream.php index de8e28d..12a575b 100644 --- a/src/CodeManipulation/Stream.php +++ b/src/CodeManipulation/Stream.php @@ -13,9 +13,9 @@ class Stream { - const STREAM_OPEN_FOR_INCLUDE = 128; - const STAT_MTIME_NUMERIC_OFFSET = 9; - const STAT_MTIME_ASSOC_OFFSET = 'mtime'; + public const STREAM_OPEN_FOR_INCLUDE = 128; + public const STAT_MTIME_NUMERIC_OFFSET = 9; + public const STAT_MTIME_ASSOC_OFFSET = 'mtime'; protected static $protocols = ['file', 'phar']; protected static $otherWrapperClass; diff --git a/src/Config.php b/src/Config.php index f626d0a..00aa836 100644 --- a/src/Config.php +++ b/src/Config.php @@ -224,11 +224,11 @@ function getTimestamp() class State { - static $blacklist = []; - static $whitelist = []; - static $cachePath; - static $redefinableInternals = []; - static $redefinableLanguageConstructs = []; - static $newKeywordRedefinable = false; - static $timestamp = 0; + public static $blacklist = []; + public static $whitelist = []; + public static $cachePath; + public static $redefinableInternals = []; + public static $redefinableLanguageConstructs = []; + public static $newKeywordRedefinable = false; + public static $timestamp = 0; } diff --git a/src/Exceptions.php b/src/Exceptions.php index 822f0d2..72bbd15 100644 --- a/src/Exceptions.php +++ b/src/Exceptions.php @@ -26,7 +26,7 @@ class StackEmpty extends Exception abstract class CallbackException extends Exception { - function __construct($callback) + public function __construct($callback) { parent::__construct(sprintf($this->message, Utils\callableToString($callback))); } @@ -39,7 +39,7 @@ class NotUserDefined extends CallbackException class DefinedTooEarly extends CallbackException { - function __construct($callback) + public function __construct($callback) { $this->message = "The file that defines %s() was included earlier than Patchwork. " . "Please reverse this order to be able to redefine the function in question."; @@ -62,7 +62,7 @@ class InternalsNotSupportedOnHHVM extends CallbackException class CachePathUnavailable extends Exception { - function __construct($location) + public function __construct($location) { parent::__construct(sprintf( "The specified cache path is nonexistent or read-only: %s", @@ -77,7 +77,7 @@ class ConfigException extends Exception class ConfigMalformed extends ConfigException { - function __construct($file, $message) + public function __construct($file, $message) { parent::__construct(sprintf( 'The configuration file %s is malformed: %s', @@ -89,7 +89,7 @@ function __construct($file, $message) class ConfigKeyNotRecognized extends ConfigException { - function __construct($key, $list, $file) + public function __construct($key, $list, $file) { parent::__construct(sprintf( "The key '%s' in the configuration file %s was not recognized. " . @@ -103,7 +103,7 @@ function __construct($key, $list, $file) class CachePathConflict extends ConfigException { - function __construct($first, $second) + public function __construct($first, $second) { parent::__construct(sprintf( "Detected configuration files provide conflicting cache paths: %s and %s", diff --git a/src/Stack.php b/src/Stack.php index 3c467fa..565f033 100644 --- a/src/Stack.php +++ b/src/Stack.php @@ -92,5 +92,5 @@ function allCalledClasses() class State { - static $items = []; + public static $items = []; } diff --git a/src/Utils.php b/src/Utils.php index c4c5480..5a06cb2 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -385,5 +385,5 @@ function tokenize($string) class State { - static $missedCallables = []; + public static $missedCallables = []; }