File tree 4 files changed +68
-2
lines changed
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
32
32
33
33
## Supported Tags
34
34
35
- - [x] ` @abstract ` - Declare a class-like _ Symbol_ or method as abstract
35
+ - [x] ` @abstract ` - Declare any _ Symbol_ as abstract
36
36
- [ ] ` @api ` - TODO
37
37
- [ ] ` @author ` - TODO
38
38
- [ ] ` @category ` - TODO
@@ -41,7 +41,7 @@ composer require type-lang/phpdoc
41
41
- [ ] ` @example ` - TODO
42
42
- [x] ` @extends ` - Allows to extend templated classes and interfaces
43
43
- [ ] ` @filesource ` - TODO
44
- - [ ] ` @final ` - TODO
44
+ - [x ] ` @final ` - Declare any _ Symbol _ as final
45
45
- [ ] ` @global ` - TODO
46
46
- [ ] ` @ignore ` - TODO
47
47
- [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 7
7
use TypeLang \Parser \ParserInterface as TypesParserInterface ;
8
8
use TypeLang \PHPDoc \DocBlock \Tag \AbstractTag \AbstractTagFactory ;
9
9
use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
10
+ use TypeLang \PHPDoc \DocBlock \Tag \FinalTag \FinalTagFactory ;
10
11
use TypeLang \PHPDoc \DocBlock \Tag \LinkTag \LinkTagFactory ;
11
12
use TypeLang \PHPDoc \DocBlock \Tag \MethodTag \MethodTagFactory ;
12
13
use TypeLang \PHPDoc \DocBlock \Tag \ParamTag \ParamTagFactory ;
@@ -34,6 +35,7 @@ protected function load(TypesParserInterface $types): iterable
34
35
{
35
36
yield 'abstract ' => new AbstractTagFactory ();
36
37
yield 'extends ' => new TemplateExtendsTagFactory ($ types );
38
+ yield 'final ' => new FinalTagFactory ();
37
39
yield 'implements ' => new TemplateImplementsTagFactory ($ types );
38
40
yield 'link ' => new LinkTagFactory ();
39
41
yield 'method ' => new MethodTagFactory ($ types );
You can’t perform that action at this time.
0 commit comments