diff --git a/src/Annotations/Annotation.php b/src/Annotations/Annotation.php index 91de5354..3eafa11b 100644 --- a/src/Annotations/Annotation.php +++ b/src/Annotations/Annotation.php @@ -22,6 +22,20 @@ */ class Annotation { + /** + * Type of an expression node that holds a value that PHP resolved + * already. The attributes reader makes these nodes, because + * ReflectionAttribute::getArguments() gives the values and not a parse + * tree. The value goes to the caller without a change. + * + * The parser types stop at 309 (PHANNOT_T_ARBITRARY_TEXT). The value is + * 1000 and not 310, so that a token added to the grammar later cannot + * make two case labels with one value in getExpression(). + * + * @var int + */ + const int T_RESOLVED = 1000; + /** * Annotation Arguments * diff --git a/src/Annotations/AttributesReader.php b/src/Annotations/AttributesReader.php new file mode 100644 index 00000000..2ae28a4a --- /dev/null +++ b/src/Annotations/AttributesReader.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use ReflectionClass; + +/** + * Parses PHP attributes returning an array with the found annotations + * + * The array has the same shape as the one of Phalcon\Annotations\Reader, so + * the adapters, Reflection, Collection and Annotation do not know which + * reader made it. + * + * PHP resolves the value of an attribute argument, so there is no parse tree + * to walk. Each value goes in a node of the type Annotation::T_RESOLVED, + * which Annotation::getExpression() gives back without a change. + * + * @phpstan-import-type annotations_arguments from AnnotationsTypes + * @phpstan-import-type annotations_node_list from AnnotationsTypes + * @phpstan-import-type annotations_reflection_data from AnnotationsTypes + */ +class AttributesReader implements \Phalcon\Annotations\ReaderInterface +{ + /** + * An attribute of this namespace gets the short name, so that `#[Column]` + * and `@Column` give the same name. Every other attribute keeps the full + * class name, so that an attribute of another library cannot take the + * place of a Phalcon one. + * + * @var string + */ + const string PHALCON_NAMESPACE = 'Phalcon\\\\Annotations\\\\'; + + + /** + * Reads attributes from the class, its constants, properties and methods + * + * @phpstan-param class-string $className + * + * @phpstan-return annotations_reflection_data + * @param string $className + * @return array + */ + public function parse(string $className): array + { + } + + /** + * Makes the argument list of one attribute. PHP resolved the values + * already, so each one goes in a node that Annotation::getExpression() + * gives back without a change. An integer key is a positional argument + * and a string key is a named one. + * + * @phpstan-param array $attributeArguments + * + * @phpstan-return annotations_arguments + * @param array $attributeArguments + * @return array + */ + protected function buildArguments(array $attributeArguments): array + { + } + + /** + * Makes the node list of one target from its attributes + * + * @phpstan-param array> $attributes + * + * @phpstan-return annotations_node_list + * @param array $attributes + * @param string $file + * @param int $line + * @return array + */ + protected function buildNodes(array $attributes, string $file, int $line): array + { + } + + /** + * Gives the name that the collection matches on. + * + * An attribute of the Phalcon\Annotations namespace gets the short name, + * so that `#[Column]` and `@Column` give the same name. Every other + * attribute keeps the full class name, so that an attribute of another + * library cannot take the place of a Phalcon one. + * + * Extend this reader and override this method to give the same short + * name to the attributes of your own namespace. + * + * @param string $name + * @return string + */ + protected function resolveName(string $name): string + { + } +} diff --git a/src/Annotations/Models/MetaData/Column.php b/src/Annotations/Models/MetaData/Column.php new file mode 100644 index 00000000..941a2cc5 --- /dev/null +++ b/src/Annotations/Models/MetaData/Column.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Models\MetaData; + +/** + * Describes a model column. It is the attribute form of `@Column`. + * + * The parameter names are camelCase, because PSR-12 does not allow + * snake_case. The metadata strategy reads the two spellings. The default + * value is `defaultValue` and not `default`, because `default` is a Zephir + * keyword. + */ +#[\Attribute(8)] +class Column +{ + /** + * @var bool + */ + public $allowEmptyString; + + /** + * @var string|null + */ + public $column; + + /** + * @var mixed + */ + public $defaultValue; + + /** + * @var int|null + */ + public $length; + + /** + * @var bool + */ + public $nullable; + + /** + * @var bool + */ + public $skipOnInsert; + + /** + * @var bool + */ + public $skipOnUpdate; + + /** + * @var string + */ + public $type; + + /** + * @param string|null $column + * @param string $type + * @param int|null $length + * @param bool $nullable + * @param bool $skipOnInsert + * @param bool $skipOnUpdate + * @param bool $allowEmptyString + * @param mixed $defaultValue + */ + public function __construct(?string $column = null, string $type = 'string', ?int $length = null, bool $nullable = false, bool $skipOnInsert = false, bool $skipOnUpdate = false, bool $allowEmptyString = false, $defaultValue = null) + { + } +} diff --git a/src/Annotations/Models/MetaData/Identity.php b/src/Annotations/Models/MetaData/Identity.php new file mode 100644 index 00000000..a545365c --- /dev/null +++ b/src/Annotations/Models/MetaData/Identity.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Models\MetaData; + +/** + * Marks a property as the identity column. It is the attribute form of `@Identity`. + */ +#[\Attribute(8)] +class Identity +{ +} diff --git a/src/Annotations/Models/MetaData/Primary.php b/src/Annotations/Models/MetaData/Primary.php new file mode 100644 index 00000000..39490030 --- /dev/null +++ b/src/Annotations/Models/MetaData/Primary.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Models\MetaData; + +/** + * Marks a property as part of the primary key. It is the attribute form of `@Primary`. + */ +#[\Attribute(8)] +class Primary +{ +} diff --git a/src/Annotations/Models/MetaData/Source.php b/src/Annotations/Models/MetaData/Source.php new file mode 100644 index 00000000..adea6e2c --- /dev/null +++ b/src/Annotations/Models/MetaData/Source.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Models\MetaData; + +/** + * Names the table of a model. No framework code reads it today. + */ +#[\Attribute(1)] +class Source +{ + /** + * @var string + */ + public $table; + + /** + * @param string $table + */ + public function __construct(string $table) + { + } +} diff --git a/src/Annotations/ReaderInterface.php b/src/Annotations/ReaderInterface.php index d02de1de..ce317edf 100644 --- a/src/Annotations/ReaderInterface.php +++ b/src/Annotations/ReaderInterface.php @@ -12,15 +12,18 @@ use Phalcon\Contracts\Annotations\AnnotationsTypes; /** - * Parses docblocks returning an array with the found annotations + * Reads the annotations of a class and returns them as an array + * + * Phalcon\Annotations\Reader reads the docblocks and Phalcon\Annotations\AttributesReader + * reads the PHP attributes. The two give the same array shape, so the adapter + * and the classes after it do not know which reader made it. * - * @phpstan-import-type annotations_node_list from AnnotationsTypes * @phpstan-import-type annotations_reflection_data from AnnotationsTypes */ interface ReaderInterface { /** - * Reads annotations from the class docblocks, its constants, properties and methods + * Reads annotations from the class, its constants, properties and methods * * @phpstan-param class-string $className * @@ -29,18 +32,4 @@ interface ReaderInterface * @return array */ public function parse(string $className): array; - - /** - * Parses a raw docblock returning the annotations found - * - * @phpstan-param string|null $file - * @phpstan-param int|null $line - * - * @phpstan-return annotations_node_list - * @param string $docBlock - * @param mixed $file - * @param mixed $line - * @return array - */ - public static function parseDocBlock(string $docBlock, $file = null, $line = null): array; } diff --git a/src/Annotations/Router/Connect.php b/src/Annotations/Router/Connect.php new file mode 100644 index 00000000..376eaf63 --- /dev/null +++ b/src/Annotations/Router/Connect.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a CONNECT route. It is the attribute form of `@Connect`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Connect extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Delete.php b/src/Annotations/Router/Delete.php new file mode 100644 index 00000000..8a7db2e4 --- /dev/null +++ b/src/Annotations/Router/Delete.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a DELETE route. It is the attribute form of `@Delete`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Delete extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Get.php b/src/Annotations/Router/Get.php new file mode 100644 index 00000000..910b1bc5 --- /dev/null +++ b/src/Annotations/Router/Get.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a GET route. It is the attribute form of `@Get`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Get extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Head.php b/src/Annotations/Router/Head.php new file mode 100644 index 00000000..7a3ac1b4 --- /dev/null +++ b/src/Annotations/Router/Head.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a HEAD route. It is the attribute form of `@Head`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Head extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Options.php b/src/Annotations/Router/Options.php new file mode 100644 index 00000000..e758c65b --- /dev/null +++ b/src/Annotations/Router/Options.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a OPTIONS route. It is the attribute form of `@Options`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Options extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Patch.php b/src/Annotations/Router/Patch.php new file mode 100644 index 00000000..8ba18b84 --- /dev/null +++ b/src/Annotations/Router/Patch.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a PATCH route. It is the attribute form of `@Patch`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Patch extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Post.php b/src/Annotations/Router/Post.php new file mode 100644 index 00000000..577efa11 --- /dev/null +++ b/src/Annotations/Router/Post.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a POST route. It is the attribute form of `@Post`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Post extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Purge.php b/src/Annotations/Router/Purge.php new file mode 100644 index 00000000..439f0d1f --- /dev/null +++ b/src/Annotations/Router/Purge.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a PURGE route. It is the attribute form of `@Purge`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Purge extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Put.php b/src/Annotations/Router/Put.php new file mode 100644 index 00000000..02bd07c9 --- /dev/null +++ b/src/Annotations/Router/Put.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a PUT route. It is the attribute form of `@Put`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Put extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/Route.php b/src/Annotations/Router/Route.php new file mode 100644 index 00000000..bb4c8023 --- /dev/null +++ b/src/Annotations/Router/Route.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; + +/** + * Marks a method as a route. It is the attribute form of `@Route`. + * + * The annotations service never makes an instance of this class. It reads the + * arguments with ReflectionAttribute::getArguments(). The class gives the + * name, the targets and the signature that an IDE and a static analyzer read. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_methods from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Route +{ + /** + * @var array|string|null + * + * @phpstan-var annotations_route_before_match + */ + public $beforeMatch; + + /** + * @var array + * + * @phpstan-var annotations_route_converters + */ + public $converters; + + /** + * @var array|string|null + * + * @phpstan-var annotations_route_methods + */ + public $methods; + + /** + * @var string|null + */ + public $name; + + /** + * @var array + * + * @phpstan-var annotations_route_paths + */ + public $paths; + + /** + * @var string + */ + public $route; + + /** + * @phpstan-param annotations_route_methods $methods + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param mixed $methods + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, $methods = null, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Annotations/Router/RoutePrefix.php b/src/Annotations/Router/RoutePrefix.php new file mode 100644 index 00000000..a6613821 --- /dev/null +++ b/src/Annotations/Router/RoutePrefix.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +/** + * Sets the prefix of every route of a controller. It is the attribute form of + * `@RoutePrefix`. + */ +#[\Attribute(1)] +class RoutePrefix +{ + /** + * @var string + */ + public $prefix; + + /** + * @param string $prefix + */ + public function __construct(string $prefix) + { + } +} diff --git a/src/Annotations/Router/Trace.php b/src/Annotations/Router/Trace.php new file mode 100644 index 00000000..d92caa55 --- /dev/null +++ b/src/Annotations/Router/Trace.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ +namespace Phalcon\Annotations\Router; + +use Phalcon\Contracts\Annotations\AnnotationsTypes; +use Phalcon\Http\Message\RequestMethodInterface; + +/** + * Marks a method as a TRACE route. It is the attribute form of `@Trace`. + * + * @phpstan-import-type annotations_route_before_match from AnnotationsTypes + * @phpstan-import-type annotations_route_converters from AnnotationsTypes + * @phpstan-import-type annotations_route_paths from AnnotationsTypes + */ +#[\Attribute(132)] +class Trace extends \Phalcon\Annotations\Router\Route +{ + /** + * @phpstan-param annotations_route_paths $paths + * @phpstan-param annotations_route_converters $converters + * @phpstan-param annotations_route_before_match $beforeMatch + * @param string $route + * @param string|null $name + * @param array $paths + * @param array $converters + * @param mixed $beforeMatch + */ + public function __construct(string $route, ?string $name = null, array $paths = [], array $converters = [], $beforeMatch = null) + { + } +} diff --git a/src/Contracts/Annotations/AnnotationsTypes.php b/src/Contracts/Annotations/AnnotationsTypes.php index acd851d5..0cb734b3 100644 --- a/src/Contracts/Annotations/AnnotationsTypes.php +++ b/src/Contracts/Annotations/AnnotationsTypes.php @@ -33,12 +33,6 @@ * invisible until the stubs are analyzed. `annotations_expression` is hoisted * for that reason. * - * These shapes are this project's own. The Annotations namespace is the one - * namespace whose implementation differs between cphalcon and phalcon: - * cphalcon parses docblocks with `phannot_parse_annotations()` and hands the - * raw parser nodes around, while phalcon reads native PHP attributes and hands - * `ReflectionAttribute` objects around. Do not mirror the two registries. - * * The node shapes below are what `ext/phalcon/annotations/parser.php.inc.h` * builds: `phannot_ret_annotation()`, `phannot_ret_named_item()`, * `phannot_ret_literal_zval()` and `phannot_ret_array()`. @@ -76,6 +70,10 @@ * properties?: annotations_node_map, * } * @phpstan-type annotations_resolved_arguments array + * @phpstan-type annotations_route_before_match array|string|null + * @phpstan-type annotations_route_converters array + * @phpstan-type annotations_route_methods array|string|null + * @phpstan-type annotations_route_paths array */ interface AnnotationsTypes { diff --git a/src/Mvc/Router/Annotations.php b/src/Mvc/Router/Annotations.php index a91e40d2..67409190 100644 --- a/src/Mvc/Router/Annotations.php +++ b/src/Mvc/Router/Annotations.php @@ -204,4 +204,20 @@ public function getActionPreformatCallback() public function setControllerSuffix(string $controllerSuffix): self { } + + /** + * Returns the argument at position 0, or the named one when position 0 + * is not there. + * + * A docblock puts the value at position 0. An attribute puts it at + * position 0 too, unless the developer writes the name as a named + * argument. + * + * @param \Phalcon\Annotations\Annotation $annotation + * @param string $name + * @return mixed + */ + protected function resolveArgument(\Phalcon\Annotations\Annotation $annotation, string $name): mixed + { + } }