From 8fde8c723a7ff56b92aff4f831898c4c7dbf1fce Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Mon, 20 May 2024 08:23:35 -0500 Subject: [PATCH] 5.7.0 stubs --- src/Cli/Router.php | 21 +++++++------ src/Cli/RouterInterface.php | 20 ++++++------ src/Db/Column.php | 4 +-- src/Filter/Filter.php | 44 +++++++++++++-------------- src/Mvc/Model.php | 8 +++-- src/Mvc/Model/Resultset.php | 6 +++- src/Mvc/Model/Resultset/Complex.php | 5 ++- src/Mvc/Model/Resultset/Simple.php | 5 ++- src/Mvc/ModelInterface.php | 9 ++++-- src/Mvc/Router.php | 3 +- src/Support/Helper/Str/Uncamelize.php | 3 +- src/Tag.php | 7 ++--- src/Translate/Adapter/Csv.php | 3 +- src/Translate/Adapter/NativeArray.php | 6 ++-- 14 files changed, 79 insertions(+), 65 deletions(-) diff --git a/src/Cli/Router.php b/src/Cli/Router.php index 1b27cc87..dc1f8aa3 100644 --- a/src/Cli/Router.php +++ b/src/Cli/Router.php @@ -14,6 +14,7 @@ use Phalcon\Cli\Router\Route; use Phalcon\Cli\Router\Exception; use Phalcon\Cli\Router\RouteInterface; +use Phalcon\Cli\RouterInterface; /** * Phalcon\Cli\Router is the standard framework router. Routing is the process @@ -35,7 +36,7 @@ * echo $router->getTaskName(); * ``` */ -class Router extends AbstractInjectionAware +class Router extends AbstractInjectionAware implements \Phalcon\Cli\RouterInterface { /** * @var string @@ -113,8 +114,8 @@ public function __construct(bool $defaultRoutes = true) * $router->add("/about", "About::main"); * ``` * - * @param string|array $paths - * @param string $pattern + * @param string $pattern + * @param mixed|null $paths * @return RouteInterface */ public function add(string $pattern, $paths = null): RouteInterface @@ -179,7 +180,7 @@ public function getParameters(): array /** * Returns a route object by its id * - * @param int $id + * @param mixed $id * @return bool|RouteInterface */ public function getRouteById($id): RouteInterface|bool @@ -227,9 +228,9 @@ public function handle($arguments = null) * Sets the default action name * * @param string $actionName - * @return Router + * @return RouterInterface */ - public function setDefaultAction(string $actionName): Router + public function setDefaultAction(string $actionName): RouterInterface { } @@ -237,9 +238,9 @@ public function setDefaultAction(string $actionName): Router * Sets the name of the default module * * @param string $moduleName - * @return Router + * @return RouterInterface */ - public function setDefaultModule(string $moduleName): Router + public function setDefaultModule(string $moduleName): RouterInterface { } @@ -258,9 +259,9 @@ public function setDefaultModule(string $moduleName): Router * ``` * * @param array $defaults - * @return Router + * @return RouterInterface */ - public function setDefaults(array $defaults): Router + public function setDefaults(array $defaults): RouterInterface { } diff --git a/src/Cli/RouterInterface.php b/src/Cli/RouterInterface.php index 66e4bfee..97ba6edc 100644 --- a/src/Cli/RouterInterface.php +++ b/src/Cli/RouterInterface.php @@ -72,17 +72,17 @@ public function getParameters(): array; * Returns a route object by its id * * @param mixed $id - * @return RouteInterface + * @return bool|RouteInterface */ - public function getRouteById($id): RouteInterface; + public function getRouteById($id): RouteInterface|bool; /** * Returns a route object by its name * * @param string $name - * @return RouteInterface + * @return bool|RouteInterface */ - public function getRouteByName(string $name): RouteInterface; + public function getRouteByName(string $name): RouteInterface|bool; /** * Return all the routes defined in the router @@ -109,25 +109,25 @@ public function handle($arguments = null); * Sets the default action name * * @param string $actionName - * @return void + * @return RouterInterface */ - public function setDefaultAction(string $actionName): void; + public function setDefaultAction(string $actionName): RouterInterface; /** * Sets the name of the default module * * @param string $moduleName - * @return void + * @return RouterInterface */ - public function setDefaultModule(string $moduleName): void; + public function setDefaultModule(string $moduleName): RouterInterface; /** * Sets an array of default paths * * @param array $defaults - * @return void + * @return RouterInterface */ - public function setDefaults(array $defaults): void; + public function setDefaults(array $defaults): RouterInterface; /** * Sets the default task name diff --git a/src/Db/Column.php b/src/Db/Column.php index a480b2bf..dd352d2d 100644 --- a/src/Db/Column.php +++ b/src/Db/Column.php @@ -83,7 +83,7 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Binary abstract data type */ - const TYPE_BINARY = 26; + const TYPE_BINARY = 27; /** * Blob abstract data type @@ -208,7 +208,7 @@ class Column implements \Phalcon\Db\ColumnInterface /** * Varbinary abstract data type */ - const TYPE_VARBINARY = 27; + const TYPE_VARBINARY = 28; /** * Varchar abstract data type diff --git a/src/Filter/Filter.php b/src/Filter/Filter.php index e6ba6da1..bb09a16a 100644 --- a/src/Filter/Filter.php +++ b/src/Filter/Filter.php @@ -12,28 +12,28 @@ /** * Lazy loads, stores and exposes sanitizer objects * - * @method absint(mixed $input): int - * @method alnum(mixed $input): string - * @method alpha(mixed $input): string - * @method bool(mixed $input): bool - * @method email(string $input): string - * @method float(mixed $input): float - * @method int(string $input): int - * @method lower(string $input): string - * @method lowerfirst(string $input): string - * @method regex(mixed $input, mixed $pattern, mixed $replace): mixed - * @method remove(mixed $input, mixed $replace): mixed - * @method replace(mixed $input, mixed $source, mixed $target): mixed - * @method special(string $input): string - * @method specialfull(string $input): string - * @method string(string $input): string - * @method stringlegacy(mixed $input): string - * @method striptags(string $input): string - * @method trim(string $input): string - * @method upper(string $input): string - * @method upperFirst(string $input): string - * @method upperWords(string $input): string|null - * @method url(string $input): string|null + * @method int absint(mixed $input) + * @method string alnum(mixed $input) + * @method string alpha(mixed $input) + * @method bool bool(mixed $input) + * @method string email(string $input) + * @method float float(mixed $input) + * @method int int(string $input) + * @method string lower(string $input) + * @method string lowerfirst(string $input) + * @method mixed regex(mixed $input, mixed $pattern, mixed $replace) + * @method mixed remove(mixed $input, mixed $replace) + * @method mixed replace(mixed $input, mixed $source, mixed $target) + * @method string special(string $input) + * @method string specialfull(string $input) + * @method string string(string $input) + * @method string stringlegacy(mixed $input) + * @method string striptags(string $input) + * @method string trim(string $input) + * @method string upper(string $input) + * @method string upperFirst(string $input) + * @method string|null upperWords(string $input) + * @method string|null url(string $input) * * @property array $mapper * @property array $services diff --git a/src/Mvc/Model.php b/src/Mvc/Model.php index 16c92d4a..b634fe05 100644 --- a/src/Mvc/Model.php +++ b/src/Mvc/Model.php @@ -80,6 +80,8 @@ * echo "Great, a new robot was saved successfully!"; * } * ``` + * + * @template T of static */ abstract class Model extends AbstractInjectionAware implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\ModelInterface, \Phalcon\Mvc\Model\ResultInterface, \Serializable, \JsonSerializable { @@ -760,9 +762,9 @@ public function dump(): array * ], * 'hydration' => null * ] - * @return ResultsetInterface + * @return T[]|\Phalcon\Mvc\Model\Resultset */ - public static function find($parameters = null): ResultsetInterface + public static function find($parameters = null) { } @@ -850,7 +852,7 @@ public static function find($parameters = null): ResultsetInterface * 'hydration' => null * ] * - * @return \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null + * @return T|\Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null */ public static function findFirst($parameters = null): mixed { diff --git a/src/Mvc/Model/Resultset.php b/src/Mvc/Model/Resultset.php index d6fb6416..c7395f9b 100644 --- a/src/Mvc/Model/Resultset.php +++ b/src/Mvc/Model/Resultset.php @@ -63,6 +63,10 @@ * $robots->next(); * } * ``` + * + * @template TKey + * @template TValue + * @implements Iterator */ abstract class Resultset implements \Phalcon\Mvc\Model\ResultsetInterface, \Iterator, \SeekableIterator, \Countable, \ArrayAccess, \Serializable, \JsonSerializable { @@ -279,7 +283,7 @@ public function jsonSerialize(): array /** * Gets pointer number of active row in the resultset * - * @return int|null + * @return TKey|null */ public function key(): int|null { diff --git a/src/Mvc/Model/Resultset/Complex.php b/src/Mvc/Model/Resultset/Complex.php index 711f8e7c..dd214e36 100644 --- a/src/Mvc/Model/Resultset/Complex.php +++ b/src/Mvc/Model/Resultset/Complex.php @@ -26,8 +26,11 @@ * * Complex resultsets may include complete objects and scalar values. * This class builds every complex row as it is required + * + * @template TKey of int + * @template TValue of mixed */ -class Complex extends Resultset implements \Phalcon\Mvc\Model\ResultsetInterface +class Complex extends Resultset { /** * @var array diff --git a/src/Mvc/Model/Resultset/Simple.php b/src/Mvc/Model/Resultset/Simple.php index 75183be4..07896a1f 100644 --- a/src/Mvc/Model/Resultset/Simple.php +++ b/src/Mvc/Model/Resultset/Simple.php @@ -23,6 +23,9 @@ * * Simple resultsets only contains a complete objects * This class builds every complete object as it is required + * + * @template TKey of int + * @template TValue of \Phalcon\Mvc\ModelInterface */ class Simple extends Resultset { @@ -57,7 +60,7 @@ public function __construct($columnMap, $model, $result, $cache = null, bool $ke /** * Returns current row in the resultset * - * @return ModelInterface|null + * @return TValue */ final public function current(): ModelInterface|null { diff --git a/src/Mvc/ModelInterface.php b/src/Mvc/ModelInterface.php index c7ad0b38..d434196d 100644 --- a/src/Mvc/ModelInterface.php +++ b/src/Mvc/ModelInterface.php @@ -14,6 +14,7 @@ use Phalcon\Messages\MessageInterface; use Phalcon\Mvc\Model\CriteriaInterface; use Phalcon\Mvc\Model\MetaDataInterface; +use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\TransactionInterface; @@ -21,6 +22,8 @@ * Phalcon\Mvc\ModelInterface * * Interface for Phalcon\Mvc\Model + * + * @template T */ interface ModelInterface { @@ -115,15 +118,15 @@ public function delete(): bool; * Allows to query a set of records that match the specified conditions * * @param array|string|int|null $parameters * - * @return ResultsetInterface + * @return T[]|\Phalcon\Mvc\Model\Resultset */ - public static function find($parameters = null): ResultsetInterface; + public static function find($parameters = null); /** * Allows to query the first record that match the specified conditions * * @param array $parameters - * @return \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null + * @return T|\Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row|null * * TODO: Current method signature must be reviewed in v5. As it must return only ?ModelInterface (it also returns Row). * @see https://github.com/phalcon/cphalcon/issues/15212 diff --git a/src/Mvc/Router.php b/src/Mvc/Router.php index ce73a120..11acc4d7 100644 --- a/src/Mvc/Router.php +++ b/src/Mvc/Router.php @@ -501,7 +501,8 @@ public function getParams(): array /** * Returns a route object by its id * - * @param mixed $id * + * @param mixed $id + * * @return RouteInterface|bool */ public function getRouteById($id): RouteInterface|bool diff --git a/src/Support/Helper/Str/Uncamelize.php b/src/Support/Helper/Str/Uncamelize.php index 73167702..52634372 100644 --- a/src/Support/Helper/Str/Uncamelize.php +++ b/src/Support/Helper/Str/Uncamelize.php @@ -16,10 +16,9 @@ class Uncamelize { /** * @param string $text - * @param string $delimiters + * @param string $delimiter * * @return string - * @param string $delimiter */ public function __invoke(string $text, string $delimiter = '_'): string { diff --git a/src/Tag.php b/src/Tag.php index 43f2819f..0f73d89b 100644 --- a/src/Tag.php +++ b/src/Tag.php @@ -423,7 +423,7 @@ public static function javascriptInclude($parameters = null, bool $local = true) /** * Builds a HTML A tag using framework conventions * - * @param parameters $array |string = [ + * @param array|string $parameters = [ * 'action' => '', * 'text' => '', * 'local' => false, @@ -433,9 +433,8 @@ public static function javascriptInclude($parameters = null, bool $local = true) * 'href' => '', * 'id' => '' * ] - * @param mixed $parameters - * @param mixed $text - * @param mixed $local + * @param string $text + * @param bool $local * @return string */ public static function linkTo($parameters, $text = null, $local = true): string diff --git a/src/Translate/Adapter/Csv.php b/src/Translate/Adapter/Csv.php index 00dbfed6..96e7eed6 100644 --- a/src/Translate/Adapter/Csv.php +++ b/src/Translate/Adapter/Csv.php @@ -79,11 +79,10 @@ public function query(string $translateKey, array $placeholders = []): string * * @param string $file * @param int $length - * @param string $separator + * @param string $delimiter * @param string $enclosure * * @throws Exception - * @param string $delimiter * @return void */ private function load(string $file, int $length, string $delimiter, string $enclosure): void diff --git a/src/Translate/Adapter/NativeArray.php b/src/Translate/Adapter/NativeArray.php index 3e70aeb0..fd871b22 100644 --- a/src/Translate/Adapter/NativeArray.php +++ b/src/Translate/Adapter/NativeArray.php @@ -10,6 +10,7 @@ namespace Phalcon\Translate\Adapter; use ArrayAccess; +use Phalcon\Translate\Adapter\AbstractAdapter; use Phalcon\Translate\Exception; use Phalcon\Translate\InterpolatorFactory; @@ -23,7 +24,7 @@ * @property array $translate * @property bool $triggerError */ -class NativeArray extends \Phalcon\Translate\Adapter\AbstractAdapter implements \ArrayAccess +class NativeArray extends AbstractAdapter implements \ArrayAccess { /** * @var array @@ -88,12 +89,11 @@ public function notFound(string $index): string /** * Returns the translation related to the given key * - * @param string $index + * @param string $translateKey * @param array $placeholders * * @return string * @throws Exception - * @param string $translateKey */ public function query(string $translateKey, array $placeholders = []): string {