From 9f843178bc02d974ba983bc66b4b9827adcf568a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 29 Feb 2024 09:02:19 -0800 Subject: [PATCH] Fix issue where constructors aren't called MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation says that defining a constructor as a function with the same name as the class is deprecated as of PHP 8, but should still work. However it seems that this isn't true. Running on my machine these constructors didn't get called. Renaming them to ‘__construct’ fixed that. --- src/php-gettext/gettext.php | 2 +- src/php-gettext/streams.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/php-gettext/gettext.php b/src/php-gettext/gettext.php index a121f9c..5b3886e 100644 --- a/src/php-gettext/gettext.php +++ b/src/php-gettext/gettext.php @@ -98,7 +98,7 @@ class gettext_reader { * @param object Reader the StreamReader object * @param boolean enable_cache Enable or disable caching of strings (default on) */ - function gettext_reader($Reader, $enable_cache = true) { + function __construct($Reader, $enable_cache = true) { // If there isn't a StreamReader, turn on short circuit mode. if (! $Reader || isset($Reader->error) ) { $this->short_circuit = true; diff --git a/src/php-gettext/streams.php b/src/php-gettext/streams.php index 3cdc158..ab94719 100644 --- a/src/php-gettext/streams.php +++ b/src/php-gettext/streams.php @@ -49,7 +49,7 @@ class StringReader { var $_pos; var $_str; - function StringReader($str='') { + public function __construct($str='') { $this->_str = $str; $this->_pos = 0; } @@ -86,7 +86,7 @@ class FileReader { var $_fd; var $_length; - function FileReader($filename) { + public function __construct($filename) { if (file_exists($filename)) { $this->_length=filesize($filename); @@ -143,7 +143,7 @@ class FileReader { // Preloads entire file in memory first, then creates a StringReader // over it (it assumes knowledge of StringReader internals) class CachedFileReader extends StringReader { - function CachedFileReader($filename) { + public function __construct($filename) { if (file_exists($filename)) { $length=filesize($filename);