From ed63cb079cd44f2d128ec3206a861446325a1911 Mon Sep 17 00:00:00 2001 From: Ruud Boon Date: Thu, 12 Nov 2020 20:29:10 +0100 Subject: [PATCH] Fix psalm errors --- src/Phalcon/Application/AbstractApplication.php | 3 ++- .../DataMapper/Pdo/Connection/AbstractConnection.php | 7 ++++--- .../Pdo/Connection/ConnectionInterface.php | 4 ++-- src/Phalcon/DataMapper/Pdo/Connection/Decorated.php | 4 +--- src/Phalcon/DataMapper/Query/Delete.php | 4 ++-- src/Phalcon/DataMapper/Query/Insert.php | 10 +++++----- src/Phalcon/DataMapper/Query/Update.php | 10 +++++----- src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php | 12 +----------- src/Phalcon/Db/Result/Pdo.php | 3 ++- src/Phalcon/Db/ResultInterface.php | 2 +- src/Phalcon/Dispatcher/AbstractDispatcher.php | 4 +--- src/Phalcon/Dispatcher/DispatcherInterface.php | 2 +- src/Phalcon/Helper/Json.php | 3 ++- src/Phalcon/Html/Helper/AbstractHelper.php | 2 +- src/Phalcon/Http/Message/Uri.php | 2 +- src/Phalcon/Mvc/Model/Binder.php | 3 ++- src/Phalcon/Text.php | 3 ++- 17 files changed, 35 insertions(+), 43 deletions(-) diff --git a/src/Phalcon/Application/AbstractApplication.php b/src/Phalcon/Application/AbstractApplication.php index 9b1a733f..1c1ccdd1 100644 --- a/src/Phalcon/Application/AbstractApplication.php +++ b/src/Phalcon/Application/AbstractApplication.php @@ -70,7 +70,8 @@ public function getEventsManager(): ManagerInterface * Gets the module definition registered in the application via module name * * @param string $name - * @return array|object + * + * @return array */ public function getModule(string $name): array { diff --git a/src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php b/src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php index 332014ae..49779664 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php +++ b/src/Phalcon/DataMapper/Pdo/Connection/AbstractConnection.php @@ -265,7 +265,7 @@ public function fetchValue(string $statement, array $values = array()) /** * Return the inner PDO (if any) * - * @return PDO + * @return \PDO */ public function getAdapter(): \PDO { @@ -361,7 +361,7 @@ public function lastInsertId(string $name = null): string * @param string $statement * @param array $values * - * @return PDOStatement + * @return \PDOStatement */ public function perform(string $statement, array $values = array()): \PDOStatement { @@ -440,9 +440,10 @@ public function setProfiler(\Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface $ /** * Bind a value using the proper PDO::PARAM_ type. * - * @param PDOStatement $statement + * @param \PDOStatement $statement * @param mixed $name * @param mixed $arguments + * * @return void */ protected function performBind(\PDOStatement $statement, $name, $arguments) diff --git a/src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php b/src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php index 4d9dc59d..9eb95478 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php +++ b/src/Phalcon/DataMapper/Pdo/Connection/ConnectionInterface.php @@ -173,7 +173,7 @@ public function fetchValue(string $statement, array $values = array()); /** * Return the inner PDO (if any) * - * @return PDO + * @return \PDO */ public function getAdapter(): \PDO; @@ -200,7 +200,7 @@ public function isConnected(): bool; * @param string $statement * @param array $values * - * @return PDOStatement + * @return \PDOStatement */ public function perform(string $statement, array $values = array()): \PDOStatement; diff --git a/src/Phalcon/DataMapper/Pdo/Connection/Decorated.php b/src/Phalcon/DataMapper/Pdo/Connection/Decorated.php index 2943a08a..80a2fb1d 100644 --- a/src/Phalcon/DataMapper/Pdo/Connection/Decorated.php +++ b/src/Phalcon/DataMapper/Pdo/Connection/Decorated.php @@ -19,15 +19,13 @@ class Decorated extends \Phalcon\DataMapper\Pdo\Connection\AbstractConnection { /** - * * Constructor. * * This overrides the parent so that it can take an existing PDO instance * and decorate it with the extended methods. * - * @param PDO $pdo + * @param \PDO $pdo * @param ProfilerInterface|null $profiler - * */ public function __construct(\PDO $pdo, \Phalcon\DataMapper\Pdo\Profiler\ProfilerInterface $profiler = null) { diff --git a/src/Phalcon/DataMapper/Query/Delete.php b/src/Phalcon/DataMapper/Query/Delete.php index f2cc65d9..eac8b3a2 100644 --- a/src/Phalcon/DataMapper/Query/Delete.php +++ b/src/Phalcon/DataMapper/Query/Delete.php @@ -42,9 +42,9 @@ public function __construct(\Phalcon\DataMapper\Pdo\Connection $connection, Bind * * @param string $table * - * @return AbstractConditions + * @return self */ - public function from(string $table): Delete + public function from(string $table): self { } diff --git a/src/Phalcon/DataMapper/Query/Insert.php b/src/Phalcon/DataMapper/Query/Insert.php index 0d5796b2..79fbfc79 100644 --- a/src/Phalcon/DataMapper/Query/Insert.php +++ b/src/Phalcon/DataMapper/Query/Insert.php @@ -31,12 +31,12 @@ public function __construct(\Phalcon\DataMapper\Pdo\Connection $connection, Bind * Sets a column for the `INSERT` query * * @param string $column - * - * @return this * @param mixed $value * @param int $type + * + * @return self */ - public function column(string $column, $value = null, int $type = -1): Insert + public function column(string $column, $value = null, int $type = -1): self { } @@ -45,9 +45,9 @@ public function column(string $column, $value = null, int $type = -1): Insert * * @param array $columns * - * @return this + * @return self */ - public function columns(array $columns): Insert + public function columns(array $columns): self { } diff --git a/src/Phalcon/DataMapper/Query/Update.php b/src/Phalcon/DataMapper/Query/Update.php index b4b27fef..da93ea5f 100644 --- a/src/Phalcon/DataMapper/Query/Update.php +++ b/src/Phalcon/DataMapper/Query/Update.php @@ -31,12 +31,12 @@ public function __construct(\Phalcon\DataMapper\Pdo\Connection $connection, Bind * Sets a column for the `UPDATE` query * * @param string $column - * - * @return this * @param mixed $value * @param int $type + * + * @return self */ - public function column(string $column, $value = null, int $type = -1): Update + public function column(string $column, $value = null, int $type = -1): self { } @@ -45,9 +45,9 @@ public function column(string $column, $value = null, int $type = -1): Update * * @param array $columns * - * @return this + * @return self */ - public function columns(array $columns): Update + public function columns(array $columns): self { } diff --git a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php index c6a817ed..bdcee566 100644 --- a/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php +++ b/src/Phalcon/Db/Adapter/Pdo/AbstractPdo.php @@ -47,17 +47,7 @@ abstract class AbstractPdo extends AbstractAdapter /** * Constructor for Phalcon\Db\Adapter\Pdo * - * @param array|\Phalcon\Config $descriptor = [ - * 'host' => 'localhost', - * 'port' => '3306', - * 'dbname' => 'blog', - * 'username' => 'sigma' - * 'password' => 'secret' - * 'dialectClass' => null, - * 'options' => [], - * 'dsn' => null, - * 'charset' => 'utf8mb4' - * ] + * @param array $descriptor */ public function __construct(array $descriptor) { diff --git a/src/Phalcon/Db/Result/Pdo.php b/src/Phalcon/Db/Result/Pdo.php index f8efc724..c4c95ecb 100644 --- a/src/Phalcon/Db/Result/Pdo.php +++ b/src/Phalcon/Db/Result/Pdo.php @@ -88,7 +88,8 @@ public function __construct(\Phalcon\Db\Adapter\AdapterInterface $connection, \P * $row = $result->fetch(); * ``` * - * @param long $number + * @param int $number + * * @return void */ public function dataSeek(int $number) diff --git a/src/Phalcon/Db/ResultInterface.php b/src/Phalcon/Db/ResultInterface.php index 77662071..f9aa480a 100644 --- a/src/Phalcon/Db/ResultInterface.php +++ b/src/Phalcon/Db/ResultInterface.php @@ -19,7 +19,7 @@ interface ResultInterface * Moves internal resultset cursor to another position letting us to fetch a * certain row * - * @param long $number + * @param int $number */ public function dataSeek(int $number); diff --git a/src/Phalcon/Dispatcher/AbstractDispatcher.php b/src/Phalcon/Dispatcher/AbstractDispatcher.php index fbc48c61..9e150933 100644 --- a/src/Phalcon/Dispatcher/AbstractDispatcher.php +++ b/src/Phalcon/Dispatcher/AbstractDispatcher.php @@ -131,9 +131,7 @@ public function callActionMethod($handler, string $actionMethod, array $params = * Process the results of the router by calling into the appropriate * controller action(s) including any routing data or injected parameters. * - * @return object|false Returns the dispatched handler class (the Controller for Mvc dispatching or a Task - * for CLI dispatching) or false if an exception occurred and the operation was - * stopped by returning false in the exception handler. + * @return bool * * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. */ diff --git a/src/Phalcon/Dispatcher/DispatcherInterface.php b/src/Phalcon/Dispatcher/DispatcherInterface.php index ca3c0918..9014950b 100644 --- a/src/Phalcon/Dispatcher/DispatcherInterface.php +++ b/src/Phalcon/Dispatcher/DispatcherInterface.php @@ -18,7 +18,7 @@ interface DispatcherInterface /** * Dispatches a handle action taking into account the routing parameters * - * @return object|false + * @return bool */ public function dispatch(): bool; diff --git a/src/Phalcon/Helper/Json.php b/src/Phalcon/Helper/Json.php index caab0ece..ae0a6bc8 100644 --- a/src/Phalcon/Helper/Json.php +++ b/src/Phalcon/Helper/Json.php @@ -67,9 +67,10 @@ final public static function decode(string $data, bool $associative = false, int * @param int $options Bitmask of JSON decode options. * @param int $depth Recursion depth. * - * @return mixed + * @return string * * @throws \InvalidArgumentException if the JSON cannot be encoded. + * * @link http://www.php.net/manual/en/function.json-encode.php */ final public static function encode($data, int $options = 0, int $depth = 512): string diff --git a/src/Phalcon/Html/Helper/AbstractHelper.php b/src/Phalcon/Html/Helper/AbstractHelper.php index a4d3fa59..9a2ed4c9 100644 --- a/src/Phalcon/Html/Helper/AbstractHelper.php +++ b/src/Phalcon/Html/Helper/AbstractHelper.php @@ -46,7 +46,7 @@ abstract class AbstractHelper /** * AbstractHelper constructor. * - * @param Escaper $escaper + * @param EscaperInterface $escaper */ public function __construct(\Phalcon\Escaper\EscaperInterface $escaper) { diff --git a/src/Phalcon/Http/Message/Uri.php b/src/Phalcon/Http/Message/Uri.php index 988c98e1..d6154af1 100644 --- a/src/Phalcon/Http/Message/Uri.php +++ b/src/Phalcon/Http/Message/Uri.php @@ -424,7 +424,7 @@ private function filterPath(string $path): string * * @param int|null $port * - * @return int|null + * @return int */ private function filterPort($port): int { diff --git a/src/Phalcon/Mvc/Model/Binder.php b/src/Phalcon/Mvc/Model/Binder.php index 2c02aae2..c5e25187 100644 --- a/src/Phalcon/Mvc/Model/Binder.php +++ b/src/Phalcon/Mvc/Model/Binder.php @@ -82,7 +82,8 @@ public function bindToHandler($handler, array $params, string $cacheKey, string /** * Find the model by param value. * - * @return object|false + * @return bool + * * @param mixed $paramValue * @param string $className */ diff --git a/src/Phalcon/Text.php b/src/Phalcon/Text.php index 78975e85..9b174342 100644 --- a/src/Phalcon/Text.php +++ b/src/Phalcon/Text.php @@ -207,7 +207,8 @@ public static function startsWith(string $text, string $start, bool $ignoreCase * ``` * * @param int $type - * @param long $length + * @param int $length + * * @return string */ public static function random(int $type = 0, int $length = 8): string