File tree Expand file tree Collapse file tree 4 files changed +68
-2
lines changed Expand file tree Collapse file tree 4 files changed +68
-2
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ composer require type-lang/phpdoc
3232
3333## Supported Tags
3434
35- - [x] ` @abstract ` - Declare a class-like _ Symbol_ or method as abstract
35+ - [x] ` @abstract ` - Declare any _ Symbol_ as abstract
3636- [ ] ` @api ` - TODO
3737- [ ] ` @author ` - TODO
3838- [ ] ` @category ` - TODO
@@ -41,7 +41,7 @@ composer require type-lang/phpdoc
4141- [ ] ` @example ` - TODO
4242- [x] ` @extends ` - Allows to extend templated classes and interfaces
4343- [ ] ` @filesource ` - TODO
44- - [ ] ` @final ` - TODO
44+ - [x ] ` @final ` - Declare any _ Symbol _ as final
4545- [ ] ` @global ` - TODO
4646- [ ] ` @ignore ` - TODO
4747- [x] ` @implements ` - Allows to extend templated interfaces
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace TypeLang \PHPDoc \DocBlock \Tag \FinalTag ;
6+
7+ use TypeLang \PHPDoc \DocBlock \Tag \Tag ;
8+
9+ /**
10+ * Used to denote that the associated _Symbol_ is final, are not allowed to
11+ * extend or override the _Symbol_ in a child element.
12+ *
13+ * In some situations the language construct final cannot be used by the
14+ * implementing library where the functionality of the library prevents
15+ * elements from being final. For example when proxy patterns are applied.
16+ * In these cases the "`@final`" tag can be used to indicate that the element
17+ * should be treated as final.
18+ *
19+ * The optional description is used to provide a more detailed explanation of
20+ * why the element is marked as final.
21+ *
22+ * IDE's and other tools can use this information to show an error when such
23+ * an element is extended or overridden.
24+ *
25+ * ```
26+ * "@final" [<description>]
27+ * ```
28+ */
29+ final class FinalTag extends Tag
30+ {
31+ public function __construct (
32+ string $ name ,
33+ \Stringable |string |null $ description = null ,
34+ ) {
35+ parent ::__construct ($ name , $ description );
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace TypeLang \PHPDoc \DocBlock \Tag \FinalTag ;
6+
7+ use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
8+ use TypeLang \PHPDoc \Parser \Content \Stream ;
9+ use TypeLang \PHPDoc \Parser \Description \DescriptionParserInterface ;
10+
11+ /**
12+ * This class is responsible for creating "`@final`" tags.
13+ *
14+ * See {@see FinalTag} for details about this tag.
15+ */
16+ final class FinalTagFactory implements TagFactoryInterface
17+ {
18+ public function create (string $ tag , string $ content , DescriptionParserInterface $ descriptions ): FinalTag
19+ {
20+ $ stream = new Stream ($ tag , $ content );
21+
22+ return new FinalTag (
23+ name: $ tag ,
24+ description: $ stream ->toOptionalDescription ($ descriptions ),
25+ );
26+ }
27+ }
Original file line number Diff line number Diff line change 77use TypeLang \Parser \ParserInterface as TypesParserInterface ;
88use TypeLang \PHPDoc \DocBlock \Tag \AbstractTag \AbstractTagFactory ;
99use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
10+ use TypeLang \PHPDoc \DocBlock \Tag \FinalTag \FinalTagFactory ;
1011use TypeLang \PHPDoc \DocBlock \Tag \LinkTag \LinkTagFactory ;
1112use TypeLang \PHPDoc \DocBlock \Tag \MethodTag \MethodTagFactory ;
1213use TypeLang \PHPDoc \DocBlock \Tag \ParamTag \ParamTagFactory ;
@@ -34,6 +35,7 @@ protected function load(TypesParserInterface $types): iterable
3435 {
3536 yield 'abstract ' => new AbstractTagFactory ();
3637 yield 'extends ' => new TemplateExtendsTagFactory ($ types );
38+ yield 'final ' => new FinalTagFactory ();
3739 yield 'implements ' => new TemplateImplementsTagFactory ($ types );
3840 yield 'link ' => new LinkTagFactory ();
3941 yield 'method ' => new MethodTagFactory ($ types );
You can’t perform that action at this time.
0 commit comments