From 09ff7e4e445250c48f262a26a5ef5dee734bf9a2 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Tue, 11 Nov 2025 20:44:08 +0100 Subject: [PATCH] refactor: add explicit type declarations to class constants (PHP 8.3+) --- phpdotnet/phd/Config.php | 2 +- phpdotnet/phd/ErrorHandler.php | 2 +- phpdotnet/phd/Format.php | 4 ++-- phpdotnet/phd/OutputHandler.php | 2 +- phpdotnet/phd/Package/Generic/Manpage.php | 4 ++-- phpdotnet/phd/Package/IDE/API.php | 4 ++-- phpdotnet/phd/Package/PEAR/CHM.php | 4 ++-- phpdotnet/phd/Package/PHP/CHM.php | 4 ++-- phpdotnet/phd/Package/PHP/KDevelop.php | 2 +- phpdotnet/phd/Reader.php | 8 ++++---- phpdotnet/phd/Render.php | 14 +++++++------- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php index 8c561c63..e23a8376 100644 --- a/phpdotnet/phd/Config.php +++ b/phpdotnet/phd/Config.php @@ -3,7 +3,7 @@ class Config { - public const VERSION = '@phd_version@'; + public const string VERSION = '@phd_version@'; public readonly string $copyright; /** @var array */ diff --git a/phpdotnet/phd/ErrorHandler.php b/phpdotnet/phd/ErrorHandler.php index 202f4cf4..766eda6a 100644 --- a/phpdotnet/phd/ErrorHandler.php +++ b/phpdotnet/phd/ErrorHandler.php @@ -3,7 +3,7 @@ class ErrorHandler { - private const ERROR_MAP = [ + private const array ERROR_MAP = [ // PHP Triggered Errors E_DEPRECATED => 'E_DEPRECATED ', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR ', diff --git a/phpdotnet/phd/Format.php b/phpdotnet/phd/Format.php index 2ac1d99d..53e5f211 100644 --- a/phpdotnet/phd/Format.php +++ b/phpdotnet/phd/Format.php @@ -10,7 +10,7 @@ abstract class Format extends ObjectStorage * @var integer * @usedby createLink() */ - const SDESC = 1; + const int SDESC = 1; /** * Represents a long description. @@ -19,7 +19,7 @@ abstract class Format extends ObjectStorage * @var integer * @usedby createLink() */ - const LDESC = 2; + const int LDESC = 2; protected Config $config; protected OutputHandler $outputHandler; diff --git a/phpdotnet/phd/OutputHandler.php b/phpdotnet/phd/OutputHandler.php index 96da4c3e..0a878dfc 100644 --- a/phpdotnet/phd/OutputHandler.php +++ b/phpdotnet/phd/OutputHandler.php @@ -4,7 +4,7 @@ class OutputHandler { /** @var array */ - private const CONSTANT_TO_MESSAGE_CATEGORY_MAP = [ + private const array CONSTANT_TO_MESSAGE_CATEGORY_MAP = [ // PhD informationals VERBOSE_INDEXING => 'Indexing ', VERBOSE_FORMAT_RENDERING => 'Rendering Format ', diff --git a/phpdotnet/phd/Package/Generic/Manpage.php b/phpdotnet/phd/Package/Generic/Manpage.php index 7357f802..7e45b0c8 100644 --- a/phpdotnet/phd/Package/Generic/Manpage.php +++ b/phpdotnet/phd/Package/Generic/Manpage.php @@ -2,8 +2,8 @@ namespace phpdotnet\phd; class Package_Generic_Manpage extends Format_Abstract_Manpage { - const OPEN_CHUNK = 0x01; - const CLOSE_CHUNK = 0x02; + const int OPEN_CHUNK = 0x01; + const int CLOSE_CHUNK = 0x02; private $elementmap = array( /* {{{ */ 'acronym' => 'format_suppressed_tags', diff --git a/phpdotnet/phd/Package/IDE/API.php b/phpdotnet/phd/Package/IDE/API.php index 97f6543f..32c0ef94 100644 --- a/phpdotnet/phd/Package/IDE/API.php +++ b/phpdotnet/phd/Package/IDE/API.php @@ -35,14 +35,14 @@ class Package_IDE_API * * @var string */ - const FUNCTIONS_DIR = 'ide-xml'; + const string FUNCTIONS_DIR = 'ide-xml'; /** * Output file of the funclist format in the IDE Package. * * @var string */ - const FUNCLIST_FILE = 'ide-funclist.txt'; + const string FUNCLIST_FILE = 'ide-funclist.txt'; /** * PhD output directory. diff --git a/phpdotnet/phd/Package/PEAR/CHM.php b/phpdotnet/phd/Package/PEAR/CHM.php index d016be5b..c116264b 100755 --- a/phpdotnet/phd/Package/PEAR/CHM.php +++ b/phpdotnet/phd/Package/PEAR/CHM.php @@ -2,8 +2,8 @@ namespace phpdotnet\phd; class Package_PEAR_CHM extends Package_PEAR_ChunkedXHTML { - const DEFAULT_FONT = "Arial,10,0"; - const DEFAULT_TITLE = "PEAR Manual"; + const string DEFAULT_FONT = "Arial,10,0"; + const string DEFAULT_TITLE = "PEAR Manual"; // Array to manual code -> HTML Help Code conversion // Code list: http://www.helpware.net/htmlhelp/hh_info.htm diff --git a/phpdotnet/phd/Package/PHP/CHM.php b/phpdotnet/phd/Package/PHP/CHM.php index 86d9c445..7da2be4a 100644 --- a/phpdotnet/phd/Package/PHP/CHM.php +++ b/phpdotnet/phd/Package/PHP/CHM.php @@ -3,8 +3,8 @@ class Package_PHP_CHM extends Package_PHP_ChunkedXHTML { - const DEFAULT_FONT = "Arial,10,0"; - const DEFAULT_TITLE = "PHP Manual"; + const string DEFAULT_FONT = "Arial,10,0"; + const string DEFAULT_TITLE = "PHP Manual"; // Array to manual code -> HTML Help Code conversion // Code list: http://www.helpware.net/htmlhelp/hh_info.htm diff --git a/phpdotnet/phd/Package/PHP/KDevelop.php b/phpdotnet/phd/Package/PHP/KDevelop.php index 5783e898..168658d1 100644 --- a/phpdotnet/phd/Package/PHP/KDevelop.php +++ b/phpdotnet/phd/Package/PHP/KDevelop.php @@ -2,7 +2,7 @@ namespace phpdotnet\phd; class Package_PHP_KDevelop extends Format { - const DEFAULT_HREF = "http://www.php.net/manual/en/"; + const string DEFAULT_HREF = "http://www.php.net/manual/en/"; protected $elementmap = array( 'book' => 'format_tocsect1', diff --git a/phpdotnet/phd/Reader.php b/phpdotnet/phd/Reader.php index 796a2d71..6584ee65 100644 --- a/phpdotnet/phd/Reader.php +++ b/phpdotnet/phd/Reader.php @@ -3,10 +3,10 @@ class Reader extends \XMLReader { - const XMLNS_XML = "http://www.w3.org/XML/1998/namespace"; - const XMLNS_XLINK = "http://www.w3.org/1999/xlink"; - const XMLNS_PHD = "http://www.php.net/ns/phd"; - const XMLNS_DOCBOOK = "http://docbook.org/ns/docbook"; + const string XMLNS_XML = "http://www.w3.org/XML/1998/namespace"; + const string XMLNS_XLINK = "http://www.w3.org/1999/xlink"; + const string XMLNS_PHD = "http://www.php.net/ns/phd"; + const string XMLNS_DOCBOOK = "http://docbook.org/ns/docbook"; protected OutputHandler $outputHandler; diff --git a/phpdotnet/phd/Render.php b/phpdotnet/phd/Render.php index 5e4201cd..f54e3c2f 100644 --- a/phpdotnet/phd/Render.php +++ b/phpdotnet/phd/Render.php @@ -3,13 +3,13 @@ class Render extends ObjectStorage { - const CHUNK = 0x001; - const OPEN = 0x002; - const CLOSE = 0x004; - const STANDALONE = 0x008; - const INIT = 0x010; - const FINALIZE = 0x020; - const VERBOSE = 0x040; + const int CHUNK = 0x001; + const int OPEN = 0x002; + const int CLOSE = 0x004; + const int STANDALONE = 0x008; + const int INIT = 0x010; + const int FINALIZE = 0x020; + const int VERBOSE = 0x040; private $STACK = array();