From f0927ae7855a2f34c9f0010878c57b421b3aab91 Mon Sep 17 00:00:00 2001 From: lacatoire Date: Tue, 11 Nov 2025 20:47:42 +0100 Subject: [PATCH] refactor: replace dynamic calls to static methods with proper static syntax --- phpdotnet/phd/Format.php | 2 +- phpdotnet/phd/IndexRepository.php | 40 ++++++++++++++--------------- phpdotnet/phd/Package/IDE/Base.php | 2 +- phpdotnet/phd/Package/PHP/Web.php | 2 +- phpdotnet/phd/Package/PHP/XHTML.php | 6 ++--- phpdotnet/phd/TestRender.php | 4 +-- render.php | 4 +-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/phpdotnet/phd/Format.php b/phpdotnet/phd/Format.php index 2ac1d99d..a84f8edb 100644 --- a/phpdotnet/phd/Format.php +++ b/phpdotnet/phd/Format.php @@ -317,7 +317,7 @@ final public function parse($xml) { $reader = new Reader($this->outputHandler); $render = new Render(); - $reader->XML("" . $xml . ""); + $reader::XML("" . $xml . ""); $this->appendToBuffer = true; $render->attach($this); diff --git a/phpdotnet/phd/IndexRepository.php b/phpdotnet/phd/IndexRepository.php index 0ecf5dd1..a9ca5f0c 100644 --- a/phpdotnet/phd/IndexRepository.php +++ b/phpdotnet/phd/IndexRepository.php @@ -62,26 +62,26 @@ public function commit( } foreach ($postReplacementValues as $key => $postReplacementValue) { - $postReplacementValues[$key] = $this->db->escapeString($postReplacementValue); + $postReplacementValues[$key] = $this->db::escapeString($postReplacementValue); } foreach ($commitList as $key => $commit) { $commitList[$key] = sprintf( "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next, chunk) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d);\n", - $this->db->escapeString($commit["docbook_id"]), - $this->db->escapeString($commit["filename"]), - $this->db->escapeString($commit["parent_id"]), - $this->db->escapeString($commit["sdesc"]), - $this->db->escapeString($commit["ldesc"]), - $this->db->escapeString($commit["element"]), - $this->db->escapeString($commit["previous"]), - $this->db->escapeString($commit["next"]), - $this->db->escapeString($commit["chunk"]) + $this->db::escapeString($commit["docbook_id"]), + $this->db::escapeString($commit["filename"]), + $this->db::escapeString($commit["parent_id"]), + $this->db::escapeString($commit["sdesc"]), + $this->db::escapeString($commit["ldesc"]), + $this->db::escapeString($commit["element"]), + $this->db::escapeString($commit["previous"]), + $this->db::escapeString($commit["next"]), + $this->db::escapeString($commit["chunk"]) ); } - $search = $this->db->escapeString("POST-REPLACEMENT"); - $none = $this->db->escapeString(""); + $search = $this->db::escapeString("POST-REPLACEMENT"); + $none = $this->db::escapeString(""); foreach($postReplacementIndexes as $a) { if (isset($postReplacementValues[$a["docbook_id"]])) { @@ -106,11 +106,11 @@ private function saveChangelogs(array $changelog): void { foreach(preg_split('/,\s+/', $entry[2]) as $version) { $log .= sprintf( "INSERT INTO changelogs (membership, docbook_id, parent_id, version, description) VALUES('%s', '%s', '%s', '%s', '%s');\n", - $this->db->escapeString($entry[0] ?? ''), - $this->db->escapeString($id), - $this->db->escapeString($entry[1]), - $this->db->escapeString($version), - $this->db->escapeString($entry[3]) + $this->db::escapeString($entry[0] ?? ''), + $this->db::escapeString($id), + $this->db::escapeString($entry[1]), + $this->db::escapeString($version), + $this->db::escapeString($entry[3]) ); } } @@ -245,7 +245,7 @@ public function getRootIndex(): array|false { public function getChangelogsForChildrenOf($bookids): array { $ids = []; foreach((array)$bookids as $bookid) { - $ids[] = "'" . $this->db->escapeString($bookid) . "'"; + $ids[] = "'" . $this->db::escapeString($bookid) . "'"; } $results = $this->db->query("SELECT * FROM changelogs WHERE parent_id IN (" . join(", ", $ids) . ")"); return $this->_returnChangelog($results); @@ -254,7 +254,7 @@ public function getChangelogsForChildrenOf($bookids): array { public function getChangelogsForMembershipOf($memberships): array { $ids = []; foreach((array)$memberships as $membership) { - $ids[] = "'" . $this->db->escapeString($membership) . "'"; + $ids[] = "'" . $this->db::escapeString($membership) . "'"; } $results = $this->db->query("SELECT * FROM changelogs WHERE membership IN (" . join(", ", $ids) . ")"); return $this->_returnChangelog($results); @@ -276,7 +276,7 @@ public function getParents(array $renderIds): array { $parents = []; foreach($renderIds as $p => $v) { do { - $id = $this->db->escapeString($p); + $id = $this->db::escapeString($p); $row = $this->db->query("SELECT parent_id FROM ids WHERE docbook_id = '$id'")->fetchArray(\SQLITE3_ASSOC); if ($row["parent_id"]) { $parents[] = $p = $row["parent_id"]; diff --git a/phpdotnet/phd/Package/IDE/Base.php b/phpdotnet/phd/Package/IDE/Base.php index f1992040..baf463f4 100644 --- a/phpdotnet/phd/Package/IDE/Base.php +++ b/phpdotnet/phd/Package/IDE/Base.php @@ -176,7 +176,7 @@ public static function generateVersionInfo($filename) { return $info; } $r = new \XMLReader; - if (!$r->open($filename)) { + if (!$r::open($filename)) { throw new \Exception; } $versions = array(); diff --git a/phpdotnet/phd/Package/PHP/Web.php b/phpdotnet/phd/Package/PHP/Web.php index ad36b7cf..511cf5d6 100644 --- a/phpdotnet/phd/Package/PHP/Web.php +++ b/phpdotnet/phd/Package/PHP/Web.php @@ -410,7 +410,7 @@ public static function generateSourcesInfo($filename) { } $r = new \XMLReader; - if (!$r->open($filename)) { + if (!$r::open($filename)) { trigger_error(vsprintf("Can't open the sources file (%s)", [$filename]), E_USER_ERROR); return array(); } diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 1109038e..4ea8edd3 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -262,7 +262,7 @@ public static function generateVersionInfo($filename) { } $r = new \XMLReader; - if (!$r->open($filename)) { + if (!$r::open($filename)) { trigger_error(vsprintf("Can't open the version info file (%s)", [$filename]), E_USER_ERROR); } $versions = array(); @@ -299,7 +299,7 @@ protected static function generateDeprecatedInfo($filename) { } $r = new \XMLReader; - if (!$r->open($filename)) { + if (!$r::open($filename)) { trigger_error(vsprintf("Can't open the version info file (%s)", [$filename]), E_USER_ERROR); } $deprecated = array(); @@ -333,7 +333,7 @@ public static function generateAcronymInfo($filename) { } $r = new \XMLReader; - if (!$r->open($filename)) { + if (!$r::open($filename)) { trigger_error(vsprintf("Could not open file for accessing acronym information (%s)", [$filename]), E_USER_ERROR); } diff --git a/phpdotnet/phd/TestRender.php b/phpdotnet/phd/TestRender.php index a0f82f21..e5357fdf 100644 --- a/phpdotnet/phd/TestRender.php +++ b/phpdotnet/phd/TestRender.php @@ -15,7 +15,7 @@ public function run() { mkdir($this->config->outputDir, 0755); } $this->attach($this->index); - $this->reader->open($this->config->xmlFile); + $this->reader::open($this->config->xmlFile); $this->execute($this->reader); $this->detach($this->index); } @@ -25,7 +25,7 @@ public function run() { } if (count($this) > 0) { - $this->reader->open($this->config->xmlFile); + $this->reader::open($this->config->xmlFile); $this->execute($this->reader); } } diff --git a/render.php b/render.php index f7b3e3e3..e965c34f 100644 --- a/render.php +++ b/render.php @@ -136,7 +136,7 @@ function make_reader(Config $config, OutputHandler $outputHandler): Reader { $render->attach($format); $reader = make_reader($config, $outputHandler); - $reader->open($config->xmlFile, NULL, $readerOpts); + $reader::open($config->xmlFile, NULL, $readerOpts); $render->execute($reader); $render->detach($format); @@ -162,7 +162,7 @@ function make_reader(Config $config, OutputHandler $outputHandler): Reader { // Render formats $reader = make_reader($config, $outputHandler); -$reader->open($config->xmlFile, NULL, $readerOpts); +$reader::open($config->xmlFile, NULL, $readerOpts); foreach($render as $format) { $format->notify(Render::VERBOSE, true); }