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

phpstan: added lib/Mage and lib/Magento #2780

Merged
merged 7 commits into from
Dec 6, 2022
Merged
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
4 changes: 2 additions & 2 deletions lib/Mage/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mage_Archive
/**
* Current archiver is used for compress.
*
* @var Mage_Archiver_Tar|Mage_Archiver_Gz|Mage_Archiver_Bz
* @var Mage_Archive_Tar|Mage_Archive_Gz|Mage_Archive_Bz
*/
protected $_archiver = null;

Expand Down Expand Up @@ -68,7 +68,7 @@ class Mage_Archive
* Create object of current archiver by $extension.
*
* @param string $extension
* @return Mage_Archiver_Tar|Mage_Archiver_Gz|Mage_Archiver_Bz
* @return Mage_Archive_Tar|Mage_Archive_Gz|Mage_Archive_Bz
*/
protected function _getArchiver($extension)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/Archive/Helper/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Mage_Archive_Helper_File
/**
* File handler
*
* @var pointer
* @var resource|false pointer
*/
protected $_fileHandler;

Expand Down
20 changes: 10 additions & 10 deletions lib/Mage/Archive/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Int
/**
* Tarball data writer
*
* @var Mage_Archive_Helper_File
* @var Mage_Archive_Helper_File|null
*/
protected $_writer;

/**
* Tarball data reader
*
* @var Mage_Archive_Helper_File
* @var Mage_Archive_Helper_File|null
*/
protected $_reader;

Expand Down Expand Up @@ -261,7 +261,7 @@ protected function _packToTar($skipRoot = false)
if (!$skipRoot) {
$header = $this->_composeHeader();
$data = $this->_readFile($file);
$data = str_pad($data, floor(((is_dir($file) ? 0 : filesize($file)) + 512 - 1) / 512) * 512, "\0");
$data = str_pad($data, intval(((is_dir($file) ? 0 : filesize($file)) + 512 - 1) / 512) * 512, "\0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this changing behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with ...

$sizes =[
	511,
	512,
	513,
	45464654,
	724966
];

foreach ($sizes as $file) {
	var_dump((floor(($file + 512 - 1) / 512) * 512) == (intval(($file + 512 - 1) / 512) * 512));
}

}
$sub = '';
if (is_dir($file)) {
Expand All @@ -276,7 +276,7 @@ protected function _packToTar($skipRoot = false)
}
}
$tarData = $header . $data . $sub;
$tarData = str_pad($tarData, floor((strlen($tarData) - 1) / 1536) * 1536, "\0");
$tarData = str_pad($tarData, intval((strlen($tarData) - 1) / 1536) * 1536, "\0");
return $tarData;
}

Expand Down Expand Up @@ -364,7 +364,7 @@ protected function _composeHeader($long = false)
$longHeader = '';
if (!$long && strlen($nameFile) > 100) {
$longHeader = $this->_composeHeader(true);
$longHeader .= str_pad($nameFile, floor((strlen($nameFile) + 512 - 1) / 512) * 512, "\0");
$longHeader .= str_pad($nameFile, intval((strlen($nameFile) + 512 - 1) / 512) * 512, "\0");
}
$header = [];
$header['100-name'] = $long ? '././@LongLink' : substr($nameFile, 0, 100);
Expand Down Expand Up @@ -462,7 +462,7 @@ protected function _unpackCurrentTar($destination)
*
* @deprecated after 1.7.0.0
* @param resource $pointer
* @return string
* @return array|false
*/
protected function _parseHeader(&$pointer)
{
Expand Down Expand Up @@ -497,13 +497,13 @@ protected function _parseHeader(&$pointer)
$checksumOk = $header['checksum'] == $checksum;
if (isset($header['name']) && $checksumOk) {
if ($header['name'] == '././@LongLink' && $header['type'] == 'L') {
$realName = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
$realName = substr(fread($pointer, intval(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
$headerMain = $this->_parseHeader($pointer);
$headerMain['name'] = $realName;
return $headerMain;
} else {
if ($header['size'] > 0) {
$header['data'] = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
$header['data'] = substr(fread($pointer, intval(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
} else {
$header['data'] = '';
}
Expand Down Expand Up @@ -555,7 +555,7 @@ protected function _extractFileHeader()
return $header;
}

$realNameBlockSize = floor(($header['size'] + self::TAR_BLOCK_SIZE - 1) / self::TAR_BLOCK_SIZE)
$realNameBlockSize = intval(($header['size'] + self::TAR_BLOCK_SIZE - 1) / self::TAR_BLOCK_SIZE)
* self::TAR_BLOCK_SIZE;
$realNameBlock = $archiveReader->read($realNameBlockSize);
$realName = substr($realNameBlock, 0, $header['size']);
Expand Down Expand Up @@ -662,7 +662,7 @@ public function extract($file, $source, $destination)
}

if ($header['type'] != 5) {
$skipBytes = floor(($header['size'] + self::TAR_BLOCK_SIZE - 1) / self::TAR_BLOCK_SIZE)
$skipBytes = intval(($header['size'] + self::TAR_BLOCK_SIZE - 1) / self::TAR_BLOCK_SIZE)
* self::TAR_BLOCK_SIZE;
$archiveReader->read($skipBytes);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Mage_Backup
* get Backup Instance By File Name
*
* @param string $type
* @return Mage_Backup_Interface
* @return Mage_Backup_Db|Mage_Backup_Interface
*/
public static function getBackupInstance($type)
{
Expand Down
1 change: 0 additions & 1 deletion lib/Mage/Backup/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ public function getErrorMessage()
* Set error message
*
* @param string $errorMessage
* @return string
*/
public function setErrorMessage($errorMessage)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/Backup/Archive/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function _createTar($skipRoot = false, $finalize = false)
* Set files that shouldn't be added to tarball
*
* @param array $skipFiles
* @return Mage_Backup_Archive_Tar
* @return $this
*/
public function setSkipFiles(array $skipFiles)
{
Expand Down
1 change: 0 additions & 1 deletion lib/Mage/Backup/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Mage_Backup_Filesystem extends Mage_Backup_Abstract
* Implementation Rollback functionality for Filesystem
*
* @throws Mage_Exception
* @return bool
*/
public function rollback()
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/Backup/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function create();
/**
* Rollback Backup
*
* @return boolean
* @return bool
*/
public function rollback();

Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/Backup/Nomedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getType()
/**
* Add media folder to ignore list
*
* @return Mage_Backup_Media
* @return $this
*/
protected function _prepareIgnoreList()
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Mage/Backup/Snapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Mage_Backup_Snapshot extends Mage_Backup_Filesystem
/**
* Database backup manager
*
* @var Mage_Backup_Db
* @var Mage_Backup_Interface|Mage_Backup_Db|null
*/
protected $_dbBackupManager;

Expand Down Expand Up @@ -111,7 +111,7 @@ protected function _createDbBackupInstance()
/**
* Get database backup manager
*
* @return Mage_Backup_Db
* @return Mage_Backup_Interface
*/
protected function _getDbBackupManager()
{
Expand All @@ -125,7 +125,7 @@ protected function _getDbBackupManager()
/**
* Remove Db backup after added it to the snapshot
*
* @return Mage_Backup_Snapshot
* @return $this
*/
protected function _removeDbBackup()
{
Expand Down
8 changes: 4 additions & 4 deletions lib/Mage/DB/Mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Mage_DB_Mysqli

/**
* Value escaper
* @var unknown_type
* @var string
*/
public const VALUE_ESCAPER = '"';

Expand All @@ -53,7 +53,7 @@ class Mage_DB_Mysqli
protected $conn;
/**
* Fetch mode
* @var unknown_type
* @var int
*/
private $fetch_mode = MYSQLI_ASSOC;

Expand Down Expand Up @@ -117,7 +117,7 @@ public function escapeTableName($table)

/**
* Escape field name
* @param stirng $fld
* @param string $fld
* @return string
*/
public function escapeFieldName($fld)
Expand Down Expand Up @@ -312,7 +312,7 @@ protected function throwConnectException()

/**
* Query - perform with throwing exception on error
* @param sting $sql query
* @param string $sql query
* @throws Mage_DB_Exception
* @return mixed
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/Mage/HTTP/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private function __construct()

/**
* Factory for HTTP client
* @param string/false $frontend 'curl'/'socket' or false for auto-detect
* @param string|false $frontend 'curl'/'socket' or false for auto-detect
* @return Mage_HTTP_IClient
*/
public static function getInstance($frontend = false)
Expand All @@ -59,7 +59,7 @@ public static function getInstance($frontend = false)
* Detects frontend type.
* Priority is given to CURL
*
* @return string/bool
* @return string|false
*/
protected static function detectFrontend()
{
Expand Down
5 changes: 2 additions & 3 deletions lib/Mage/HTTP/Client/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public function getStatus()
* @param string $method
* @param string $uri
* @param array|string $params pass an array to form post, pass a json encoded string to directly post json
* @return null
*/
protected function makeRequest($method, $uri, $params = [])
{
Expand Down Expand Up @@ -465,8 +464,8 @@ protected function validateHttpVersion(array $line)
/**
* Set curl option directly
*
* @param string $name
* @param string $value
* @param int $name
* @param int|array|string $value
*/
protected function curlOption($name, $value)
{
Expand Down
3 changes: 1 addition & 2 deletions lib/Mage/HTTP/Client/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Mage_HTTP_Client_Socket implements Mage_HTTP_IClient

/**
* Stream resource
* @var object
* @var resource
*/
private $_sock = null;

Expand Down Expand Up @@ -437,7 +437,6 @@ public function getStatus()
* @param string $method
* @param string $uri
* @param array $params
* @return null
*/
protected function makeRequest($method, $uri, $params = [])
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/HTTP/IClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function removeCookies();

/**
* Make GET request
* @param string full uri
* @param string $uri full uri
*/
public function get($uri);

Expand Down
6 changes: 3 additions & 3 deletions lib/Mage/System/Args.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public function getFiltered()

/**
* Constructor
* @param array $argv, if false $GLOBALS['argv'] is taken
* @param array|false $argv, if false $GLOBALS['argv'] is taken
* @return void
*/
public function __construct($source = false)
public function __construct($argv = false)
{
$this->flags = [];
$this->filtered = [];

if (false === $source) {
if (false === $argv) {
$argv = $GLOBALS['argv'];
array_shift($argv);
}
Expand Down
18 changes: 9 additions & 9 deletions lib/Mage/System/Ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_System_Ftp
/**
* Connection object
*
* @var resource
* @var resource|false
*/
protected $_conn = false;

Expand All @@ -51,8 +51,8 @@ protected function checkConnected()
/**
* ftp_mkdir wrapper
*
* @param stin$name
* @return unknown_type
* @param string $name
* @return string
*/
public function mdkir($name)
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public function login($login = "anonymous", $password = "[email protected]")
*
* @param string $string
* @throws Exception
* @return string
* @return array
*/
public function validateConnectionString($string)
{
Expand Down Expand Up @@ -225,24 +225,24 @@ public function raw($cmd)
* Can be used for relative and absoulte remote paths
* Relative: use chdir before calling this
*
* @param srting $remote
* @param string $remote
* @param string $local
* @param int $dirMode
* @param int $ftpMode
* @return unknown_type
* @return bool
*/
public function upload($remote, $local, $dirMode = 0777, $ftpMode = FTP_BINARY)
{
$this->checkConnected();

if (!file_exists($local)) {
throw new Exception("Local file doesn't exist: {$localFile}");
throw new Exception("Local file doesn't exist: {$local}");
}
if (!is_readable($local)) {
throw new Exception("Local file is not readable: {$localFile}");
throw new Exception("Local file is not readable: {$local}");
}
if (is_dir($local)) {
throw new Exception("Directory given instead of file: {$localFile}");
throw new Exception("Directory given instead of file: {$local}");
}

$globalPathMode = substr($remote, 0, 1) == "/";
Expand Down
Loading