From 2947e4aac39c201f5ddcba4b8f1e5f611ea531ff Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Wed, 24 Jan 2024 17:13:38 +0300 Subject: [PATCH] fix: phpstan level=5 --- src/Controller/Front.php | 12 +++++------- src/Database/StatementIterator.php | 1 - src/Excel/Table.php | 8 ++++---- src/Filter/Authorization.php | 3 +-- src/Path.php | 3 --- src/Primitive.php | 4 ++-- src/Validator/Rule/Date.php | 4 +--- src/View/Top.php | 10 ---------- 8 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/Controller/Front.php b/src/Controller/Front.php index ac9bfdc..396d659 100644 --- a/src/Controller/Front.php +++ b/src/Controller/Front.php @@ -6,14 +6,15 @@ */ namespace ctiso\Controller; use ctiso\Controller\Action, - ctiso\Settings, - ctiso\Database, + ctiso\Registry, + ctiso\Database, ctiso\Collection, ctiso\Filter\ActionAccess, ctiso\Filter\ActionLogger, ctiso\Path, ctiso\UserMessageException, - ctiso\HttpRequest; + ctiso\HttpRequest, + ctiso\Role\User; class Front extends Action { @@ -23,10 +24,7 @@ class Front extends Action protected $modules = array(); - /** - * @param Settings $config - */ - public function __construct($db, $config, $user, $default) { + public function __construct(Database $db, Registry $config, User $user, $default) { parent::__construct(); $this->config = $config; $this->db = $db; diff --git a/src/Database/StatementIterator.php b/src/Database/StatementIterator.php index 41314a4..f767408 100644 --- a/src/Database/StatementIterator.php +++ b/src/Database/StatementIterator.php @@ -8,7 +8,6 @@ class StatementIterator implements \Iterator private $result; private $pos = 0; - private $fetchmode; private $row_count; public function __construct($rs/*: PDOStatement*/) { diff --git a/src/Excel/Table.php b/src/Excel/Table.php index 7754aa1..96eaedf 100644 --- a/src/Excel/Table.php +++ b/src/Excel/Table.php @@ -252,8 +252,8 @@ class Table $rows = $this->getRows(); $doc->startElement('Table'); - $doc->writeAttribute('ss:ExpandedColumnCount', $columns); - $doc->writeAttribute('ss:ExpandedRowCount', $rows); + $doc->writeAttribute('ss:ExpandedColumnCount', (string)$columns); + $doc->writeAttribute('ss:ExpandedRowCount', (string)$rows); // Переписать цыкл !!!!!!! for ($i = 1; $i <= $rows; $i++) { @@ -306,9 +306,9 @@ class Table $doc->writeElement('TopRowBottomPane', $this->_splitHorizontal); } if ($this->_splitHorizontal && $this->_splitVertical) { - $doc->writeElement('ActivePane', 0); + $doc->writeElement('ActivePane', (string)0); } else if($this->_splitHorizontal) { - $doc->writeElement('ActivePane', 2); + $doc->writeElement('ActivePane', (string)2); } $doc->endElement(); } diff --git a/src/Filter/Authorization.php b/src/Filter/Authorization.php index 0df3e6f..ffe3282 100644 --- a/src/Filter/Authorization.php +++ b/src/Filter/Authorization.php @@ -42,8 +42,7 @@ class Authorization { static function getBrowserSign() { $rawSign = self::SESSION_BROWSER_SIGN_SECRET; -// $signParts = array('HTTP_USER_AGENT', 'HTTP_ACCEPT_ENCODING'); - $signParts = array(); + $signParts = ['HTTP_USER_AGENT']; foreach ($signParts as $signPart) { $rawSign .= '::' . (isset($_SERVER[$signPart]) ? $_SERVER[$signPart] : 'none'); diff --git a/src/Path.php b/src/Path.php index f285116..3b0bcdc 100644 --- a/src/Path.php +++ b/src/Path.php @@ -66,13 +66,10 @@ class Path * Возвращает расширение файла * * @param string $fileName Полное имя файла - * * @return string */ static function getExtension($fileName) { - assert(is_string($fileName) || is_null($fileName)); - return pathinfo($fileName, PATHINFO_EXTENSION); } diff --git a/src/Primitive.php b/src/Primitive.php index 13a5bb5..db3228e 100644 --- a/src/Primitive.php +++ b/src/Primitive.php @@ -73,8 +73,8 @@ class Primitive { $tmp = array(); if (preg_match('/(\d+)-(\d+)-(\d+)T(\d+):(\d+)Z/', $value, $tmp)) { - if (checkdate($tmp[2], $tmp[3], $tmp[1])) { - $result = mktime($tmp[4], $tmp[5], 0, $tmp[2], $tmp[3], $tmp[1]); + if (checkdate((int)$tmp[2], (int)$tmp[3], (int)$tmp[1])) { + $result = mktime((int)$tmp[4], (int)$tmp[5], 0, (int)$tmp[2], (int)$tmp[3], (int)$tmp[1]); } } return $result; diff --git a/src/Validator/Rule/Date.php b/src/Validator/Rule/Date.php index 1b416b0..fdfff71 100644 --- a/src/Validator/Rule/Date.php +++ b/src/Validator/Rule/Date.php @@ -9,8 +9,6 @@ use ctiso\Validator\Rule\AbstractRule, class Date extends AbstractRule { - private $split = "\\/"; - public function getErrorMsg() { return "Неверный формат даты"; @@ -21,7 +19,7 @@ class Date extends AbstractRule $pattern = "/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/"; $matches = []; return (preg_match($pattern, $container->get($this->field), $matches) - && checkdate($matches[2], $matches[1], $matches[3])); + && checkdate((int)$matches[2], (int)$matches[1], (int)$matches[3])); } } diff --git a/src/View/Top.php b/src/View/Top.php index 4779624..804ac0f 100644 --- a/src/View/Top.php +++ b/src/View/Top.php @@ -18,16 +18,6 @@ class Top extends Composite return implode(" - ", array_filter($this->doTree('_title', false), array($this, 'isNotNull'))); } - private function findGroup($groups, $file) - { - foreach ($groups as $key => $group) { - if (in_array($file, $group)) { - return $key; - } - } - return false; - } - function getId($pref) { $this->mid++;