From b382a0d5922c2870dd37b05c04cfe05327a1a154 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 26 Jul 2024 16:29:14 +0200 Subject: [PATCH 1/9] Added basic config --- phpstan.dist.baseline.neon | 0 phpstan.dist.neon | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 phpstan.dist.baseline.neon create mode 100644 phpstan.dist.neon diff --git a/phpstan.dist.baseline.neon b/phpstan.dist.baseline.neon new file mode 100644 index 0000000000..e69de29bb2 diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000000..474bc08863 --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,10 @@ +includes: + - phpstan.dist.baseline.neon + - phar://phpstan.phar/conf/bleedingEdge.neon +parameters: + paths: + - library + level: 1 + checkFunctionNameCase: true + checkInternalClassCaseSensitivity: true + treatPhpDocTypesAsCertain: false From 7f139b776b4249ff070a2744ad286372292fcc2d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 26 Jul 2024 16:31:16 +0200 Subject: [PATCH 2/9] Removed Zend_Amf_Parse_Resource_MysqlResult Methods are not available in php7 --- .../Zend/Amf/Parse/Resource/MysqlResult.php | 70 ------------------- 1 file changed, 70 deletions(-) delete mode 100755 library/Zend/Amf/Parse/Resource/MysqlResult.php diff --git a/library/Zend/Amf/Parse/Resource/MysqlResult.php b/library/Zend/Amf/Parse/Resource/MysqlResult.php deleted file mode 100755 index 753b66e548..0000000000 --- a/library/Zend/Amf/Parse/Resource/MysqlResult.php +++ /dev/null @@ -1,70 +0,0 @@ - Value is Mysql type (exact string) => PHP type - */ - static public $fieldTypes = [ - "int" => "int", - "timestamp" => "int", - "year" => "int", - "real" => "float", - ]; - /** - * Parse resource into array - * - * @param resource $resource - * @return array - */ - public function parse($resource) { - $result = []; - $fieldcnt = mysql_num_fields($resource); - $fields_transform = []; - for($i=0;$i<$fieldcnt;$i++) { - $type = mysql_field_type($resource, $i); - if(isset(self::$fieldTypes[$type])) { - $fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type]; - } - } - - while($row = mysql_fetch_object($resource)) { - foreach($fields_transform as $fieldname => $fieldtype) { - settype($row->$fieldname, $fieldtype); - } - $result[] = $row; - } - return $result; - } -} From 64cfadb48bac6f52087cafdffe603abad2fde852 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 26 Jul 2024 16:37:32 +0200 Subject: [PATCH 3/9] Updated Zend_Amf --- library/Zend/Amf/Parse/Resource/MysqliResult.php | 2 -- library/Zend/Amf/Parse/TypeLoader.php | 4 ++-- library/Zend/Amf/Server.php | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/library/Zend/Amf/Parse/Resource/MysqliResult.php b/library/Zend/Amf/Parse/Resource/MysqliResult.php index 5b85ee7a22..cc77b603a8 100644 --- a/library/Zend/Amf/Parse/Resource/MysqliResult.php +++ b/library/Zend/Amf/Parse/Resource/MysqliResult.php @@ -31,7 +31,6 @@ */ class Zend_Amf_Parse_Resource_MysqliResult { - /** * mapping taken from http://forums.mysql.com/read.php?52,255868,255895#msg-255895 */ @@ -92,7 +91,6 @@ class Zend_Amf_Parse_Resource_MysqliResult "MYSQLI_TYPE_CHAR" => 'string', "MYSQLI_TYPE_VARCHAR" => 'string', "MYSQLI_TYPE_GEOMETRY" => 'object', - "MYSQLI_TYPE_BIT" => 'integer', ]; /** diff --git a/library/Zend/Amf/Parse/TypeLoader.php b/library/Zend/Amf/Parse/TypeLoader.php index b3294662f7..42ddfceecd 100644 --- a/library/Zend/Amf/Parse/TypeLoader.php +++ b/library/Zend/Amf/Parse/TypeLoader.php @@ -62,7 +62,7 @@ final class Zend_Amf_Parse_TypeLoader */ public static $classMap = [ 'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage', - 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage', + 'flex.messaging.messages.AsyncMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage', 'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage', 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage', 'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage', @@ -74,7 +74,7 @@ final class Zend_Amf_Parse_TypeLoader */ protected static $_defaultClassMap = [ 'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage', - 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage', + 'flex.messaging.messages.AsyncMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage', 'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage', 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage', 'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage', diff --git a/library/Zend/Amf/Server.php b/library/Zend/Amf/Server.php index 7e1f3067d9..30d7415f40 100644 --- a/library/Zend/Amf/Server.php +++ b/library/Zend/Amf/Server.php @@ -509,6 +509,7 @@ protected function _handle(Zend_Amf_Request $request) // create a response object to place the output from the services. $response = $this->getResponse(); + $responseType = Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH; // set response encoding $response->setObjectEncoding($objectEncoding); From c09edb0e88b23a008b8f16e1ae8c3669f6b16862 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 26 Jul 2024 16:50:48 +0200 Subject: [PATCH 4/9] Updated Zend_Auth --- library/Zend/Auth/Adapter/Digest.php | 2 ++ library/Zend/Auth/Adapter/OpenId.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Zend/Auth/Adapter/Digest.php b/library/Zend/Auth/Adapter/Digest.php index 6e115fb824..4b65a3d25e 100644 --- a/library/Zend/Auth/Adapter/Digest.php +++ b/library/Zend/Auth/Adapter/Digest.php @@ -71,6 +71,8 @@ class Zend_Auth_Adapter_Digest implements Zend_Auth_Adapter_Interface * @param mixed $realm * @param mixed $username * @param mixed $password + * + * @phpstan-ignore-next-line (constructor.unusedParameter) */ public function __construct($filename = null, $realm = null, $username = null, $password = null) { diff --git a/library/Zend/Auth/Adapter/OpenId.php b/library/Zend/Auth/Adapter/OpenId.php index 245184b94d..a2ca1ad1b2 100644 --- a/library/Zend/Auth/Adapter/OpenId.php +++ b/library/Zend/Auth/Adapter/OpenId.php @@ -227,7 +227,7 @@ public function setHttpClient($client) { * Defined by Zend_Auth_Adapter_Interface. * * @throws Zend_Auth_Adapter_Exception If answering the authentication query is impossible - * @return Zend_Auth_Result + * @return Zend_Auth_Result|void */ public function authenticate() { $id = $this->_id; @@ -279,5 +279,4 @@ public function authenticate() { } } } - } From 7ec2f76d3c159ba29fb29d30f031a67cf7284549 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 26 Jul 2024 17:05:43 +0200 Subject: [PATCH 5/9] Updated Zend_Barcode --- library/Zend/Barcode/Object/ObjectAbstract.php | 2 +- library/Zend/Barcode/Renderer/Image.php | 4 ++++ library/Zend/Barcode/Renderer/Pdf.php | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/library/Zend/Barcode/Object/ObjectAbstract.php b/library/Zend/Barcode/Object/ObjectAbstract.php index 56146ff6ef..9bd1602eb4 100644 --- a/library/Zend/Barcode/Object/ObjectAbstract.php +++ b/library/Zend/Barcode/Object/ObjectAbstract.php @@ -620,7 +620,7 @@ public function setText($value) public function getText() { $text = $this->_text; - if ($this->_withChecksum) { + if ($this->_withChecksum && method_exists($this, 'getChecksum')) { $text .= $this->getChecksum($this->_text); } return $this->_addLeadingZeros($text); diff --git a/library/Zend/Barcode/Renderer/Image.php b/library/Zend/Barcode/Renderer/Image.php index b7c51373f3..006c73025a 100644 --- a/library/Zend/Barcode/Renderer/Image.php +++ b/library/Zend/Barcode/Renderer/Image.php @@ -442,6 +442,8 @@ protected function _drawText($text, $size, $position, $font, $color, $alignment case 'right': $positionX = $position[0] - ($fontWidth * strlen($text)); break; + default: + $positionX = $position[0]; } imagestring($this->_resource, $font, $positionX, $positionY, $text, $color); } else { @@ -464,6 +466,8 @@ protected function _drawText($text, $size, $position, $font, $color, $alignment case 'right': $width = ($box[2] - $box[0]); break; + default: + $width = 0; } imagettftext( $this->_resource, diff --git a/library/Zend/Barcode/Renderer/Pdf.php b/library/Zend/Barcode/Renderer/Pdf.php index 567033b084..fe2da2b9db 100644 --- a/library/Zend/Barcode/Renderer/Pdf.php +++ b/library/Zend/Barcode/Renderer/Pdf.php @@ -137,6 +137,9 @@ protected function _drawPolygon($points, $color, $filled = true) { $page = $this->_resource->pages[$this->_page]; + $x = []; + $y = []; + foreach ($points as $point) { $x[] = $point[0] * $this->_moduleSize + $this->_leftOffset; $y[] = $page->getHeight() - $point[1] * $this->_moduleSize - $this->_topOffset; From 5edf61a5095ba2710c6499fafe83a96dfa5860cf Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 27 Jul 2024 15:02:07 +0200 Subject: [PATCH 6/9] Updated Zend_CodeGenerator --- library/Zend/CodeGenerator/Php/File.php | 4 ++-- library/Zend/CodeGenerator/Php/Method.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/library/Zend/CodeGenerator/Php/File.php b/library/Zend/CodeGenerator/Php/File.php index d43f89c497..5864089549 100644 --- a/library/Zend/CodeGenerator/Php/File.php +++ b/library/Zend/CodeGenerator/Php/File.php @@ -168,7 +168,7 @@ public static function fromReflection(Zend_Reflection_File $reflectionFile) unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine); } - if (($reflectionFile->getDocComment() != '')) { + if (isset($class) && $reflectionFile->getDocComment() != '') { $docblock = $reflectionFile->getDocblock(); $file->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($docblock)); @@ -183,7 +183,7 @@ public static function fromReflection(Zend_Reflection_File $reflectionFile) } } $body = implode("\n", $bodyReturn); - unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine); + unset($bodyLines, $bodyReturn); } $file->setBody($body); diff --git a/library/Zend/CodeGenerator/Php/Method.php b/library/Zend/CodeGenerator/Php/Method.php index bb3b0cd169..21696f0309 100644 --- a/library/Zend/CodeGenerator/Php/Method.php +++ b/library/Zend/CodeGenerator/Php/Method.php @@ -110,7 +110,8 @@ public static function fromReflection(Zend_Reflection_Method $reflectionMethod) */ public function setFinal($isFinal) { - $this->_isFinal = ($isFinal) ? true : false; + $this->_isFinal = (bool)$isFinal; + return $this; } /** From 78e6a04cb53760c0e4dc3e3164adc5aa410735a4 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 27 Jul 2024 15:05:02 +0200 Subject: [PATCH 7/9] Updated Zend_Config --- library/Zend/Config/Writer/Xml.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/Zend/Config/Writer/Xml.php b/library/Zend/Config/Writer/Xml.php index b26f8d465a..72a3a68e98 100644 --- a/library/Zend/Config/Writer/Xml.php +++ b/library/Zend/Config/Writer/Xml.php @@ -85,6 +85,7 @@ public function render() */ protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent) { + $branchName = null; $branchType = null; foreach ($config as $key => $value) { From 05df9cc7c27cf86136cb2c5a505639435dc06c3f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 27 Jul 2024 15:16:49 +0200 Subject: [PATCH 8/9] Updated Zend_Console --- library/Zend/Console/Getopt.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/Zend/Console/Getopt.php b/library/Zend/Console/Getopt.php index 7c38d38385..9050a39aed 100644 --- a/library/Zend/Console/Getopt.php +++ b/library/Zend/Console/Getopt.php @@ -260,9 +260,8 @@ public function __construct($rules, $argv = null, $getoptConfig = []) if (!is_array($argv)) { $argv = array_slice($_SERVER['argv'], 1); } - if (isset($argv)) { - $this->addArguments((array)$argv); - } + + $this->addArguments((array)$argv); } /** @@ -518,7 +517,7 @@ public function toJson() public function toXml() { $this->parse(); - $doc = new DomDocument('1.0', 'utf-8'); + $doc = new DOMDocument('1.0', 'utf-8'); $optionsNode = $doc->createElement('options'); $doc->appendChild($optionsNode); From d7b2439b1fc64f951eb15a44ecfb18793e2668f3 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sat, 27 Jul 2024 15:35:08 +0200 Subject: [PATCH 9/9] Updated Zend_Date - todo: check calcSun() --- library/Zend/Date/Cities.php | 1 - library/Zend/Date/DateObject.php | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/library/Zend/Date/Cities.php b/library/Zend/Date/Cities.php index 0955b0ce73..90d6566577 100644 --- a/library/Zend/Date/Cities.php +++ b/library/Zend/Date/Cities.php @@ -128,7 +128,6 @@ class Zend_Date_Cities 'Glasgow' => ['latitude' => 55.8333333, 'longitude' => -4.25], 'Guatemala la Nueva' => ['latitude' => 14.6211111, 'longitude' => -90.5269444], 'Hagatna' => ['latitude' => 13.47417, 'longitude' => 144.74778], - 'The Hague' => ['latitude' => 52.0833333, 'longitude' => 4.3], 'Hamilton' => ['latitude' => 32.2941667, 'longitude' => -64.7838889], 'Hanoi' => ['latitude' => 21.0333333, 'longitude' => 105.85], 'Harare' => ['latitude' => -17.8177778, 'longitude' => 31.0447222], diff --git a/library/Zend/Date/DateObject.php b/library/Zend/Date/DateObject.php index 206c341a0a..0a9084bc58 100644 --- a/library/Zend/Date/DateObject.php +++ b/library/Zend/Date/DateObject.php @@ -713,6 +713,8 @@ protected function getDateParts($timestamp = null, $fast = null) $otimestamp = $timestamp; $numday = 0; $month = 0; + $year = 0; + // gregorian correction if ($timestamp < -12219321600) { $timestamp -= 864000; @@ -988,7 +990,7 @@ protected function calcSun($location, $horizon, $rise = false) // adjust quadrant if ($solLongitude > $threeQuarterCircle) { $solAscension += $fullCircle; - } else if ($solLongitude > $quarterCircle) { + } elseif ($solLongitude > $quarterCircle) { $solAscension += $halfCircle; } @@ -1029,9 +1031,16 @@ protected function calcSun($location, $horizon, $rise = false) $universalTime = ($universalTime - $min) * 60; $sec = (int)$universalTime; - return $this->mktime($hour, $min, $sec, $this->date('m', $this->_unixTimestamp), - $this->date('j', $this->_unixTimestamp), $this->date('Y', $this->_unixTimestamp), - -1, true); + // @todo re-check removed arguement "-1" + return $this->mktime( + $hour, + $min, + $sec, + $this->date('m', $this->_unixTimestamp), + $this->date('j', $this->_unixTimestamp), + $this->date('Y', $this->_unixTimestamp), + true + ); } /** @@ -1094,6 +1103,7 @@ public function getTimezone() */ public function getGmtOffset() { + $offset = 0; $date = $this->getDateParts($this->getUnixTimestamp(), true); $zone = @date_default_timezone_get(); $result = @date_default_timezone_set($this->_timezone);