Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to pass phpStan level 1 #431

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions library/Zend/Amf/Parse/Resource/MysqlResult.php

This file was deleted.

2 changes: 0 additions & 2 deletions library/Zend/Amf/Parse/Resource/MysqliResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
*/
class Zend_Amf_Parse_Resource_MysqliResult
{

/**
* mapping taken from http://forums.mysql.com/read.php?52,255868,255895#msg-255895
*/
Expand Down Expand Up @@ -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',
];

/**
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Amf/Parse/TypeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Amf/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions library/Zend/Auth/Adapter/Digest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions library/Zend/Auth/Adapter/OpenId.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -279,5 +279,4 @@ public function authenticate() {
}
}
}

}
2 changes: 1 addition & 1 deletion library/Zend/Barcode/Object/ObjectAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions library/Zend/Barcode/Renderer/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions library/Zend/Barcode/Renderer/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/CodeGenerator/Php/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion library/Zend/CodeGenerator/Php/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Config/Writer/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions library/Zend/Console/Getopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion library/Zend/Date/Cities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
18 changes: 14 additions & 4 deletions library/Zend/Date/DateObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
);
}

/**
Expand Down Expand Up @@ -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);
Expand Down
Empty file added phpstan.dist.baseline.neon
Empty file.
10 changes: 10 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
@@ -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
Loading