From 5748ea9148f9f5e0738931a4efb5c55643a70a22 Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Wed, 19 Apr 2023 11:25:28 +0300 Subject: [PATCH] =?UTF-8?q?new=20=D0=A1=D0=BE=D0=B2=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D1=8C=20=D1=81=20php8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Collection.php | 8 ++++---- src/Controller/Action.php | 2 +- src/Database.php | 4 ++-- src/Database/PDOStatement.php | 2 +- src/Database/StatementIterator.php | 10 +++++----- src/HttpRequest.php | 15 +-------------- src/Path.php | 6 +++--- 7 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index 4eea3d1..7e3b808 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -79,22 +79,22 @@ class Collection implements \ArrayAccess $this->data = array(); } - public function offsetSet($key, $value) + public function offsetSet($key, $value): void { $this->data[$key] = $value; } - public function offsetExists($key) + public function offsetExists($key): bool { return isset($this->data[$key]); } - public function offsetUnset($key) + public function offsetUnset($key): void { unset($this->data[$key]); } - public function offsetGet($key) + public function offsetGet($key): mixed { return isset($this->data[$key]) ? $this->data[$key] : null; } diff --git a/src/Controller/Action.php b/src/Controller/Action.php index b73b685..f3496e5 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -30,7 +30,7 @@ class Action public $modulePath = null; // Путь к модулю public $moduleTitle = ''; - public $viewPathPrefix = null; // Путь к шаблонам контроллера + public $viewPathPrefix = ''; // Путь к шаблонам контроллера /** * Соединение с базой данных diff --git a/src/Database.php b/src/Database.php index ad989d7..dc572d1 100644 --- a/src/Database.php +++ b/src/Database.php @@ -30,8 +30,8 @@ class Database/**/ extends PDO $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('ctiso\\Database\\PDOStatement', array())); } - function prepare($sql, $args = []) { - $result/*: PDOStatement*/ = parent::prepare($sql, $args); + function prepare(string $sql, array $options = []): PDOStatement|false { + $result/*: PDOStatement*/ = parent::prepare($sql, $options); return $result; } diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php index 1ae56df..b4c351b 100644 --- a/src/Database/PDOStatement.php +++ b/src/Database/PDOStatement.php @@ -103,7 +103,7 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate return count($this->cache); } - function execute($args = null) { + function execute($args = null): bool { $result = parent::execute($args); return $result; } diff --git a/src/Database/StatementIterator.php b/src/Database/StatementIterator.php index eebd752..41314a4 100644 --- a/src/Database/StatementIterator.php +++ b/src/Database/StatementIterator.php @@ -16,26 +16,26 @@ class StatementIterator implements \Iterator $this->row_count = $rs->getRecordCount(); } - function rewind() { + function rewind(): void{ $this->pos = 0; } - function valid() { + function valid(): bool { return ($this->pos < $this->row_count); } - function key() { + function key(): mixed { return $this->pos; } - function current() { + function current(): mixed{ if (!isset($this->result->cache[$this->pos])) { $this->result->cache[$this->pos] = $this->result->fetch(PDO::FETCH_ASSOC); } return $this->result->cache[$this->pos]; } - function next() { + function next(): void{ $this->pos++; } diff --git a/src/HttpRequest.php b/src/HttpRequest.php index 0a65a4c..048c33b 100644 --- a/src/HttpRequest.php +++ b/src/HttpRequest.php @@ -10,7 +10,7 @@ use Exception, ctiso\Session; // HTTPRequest = ArrayAccess -class HttpRequest extends Collection implements ArrayAccess +class HttpRequest extends Collection { public $_session; @@ -117,19 +117,6 @@ class HttpRequest extends Collection implements ArrayAccess exit(); } - - public function offsetSet($key, $value) { - } - - public function offsetExists($key) { - } - - public function offsetUnset($key) { - } - - public function offsetGet($key) { - } - static function getProtocol() { return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; } diff --git a/src/Path.php b/src/Path.php index bafed76..f2ca20a 100644 --- a/src/Path.php +++ b/src/Path.php @@ -16,10 +16,9 @@ class Path protected $url = array(); protected $absolute = false; - public function __construct($path) + public function __construct($path = '') { -// assert(is_string($path)); - + //assert(is_string($path)); $this->url = parse_url($path); if (isset($this->url['path'])) { @@ -289,6 +288,7 @@ class Path */ static function fromJoin($_rest) { $args = func_get_args(); + $result = array(); $parts0 = new Path(array_shift($args)); $result [] = $parts0->getParts();