Skip to content

Commit 4521bde

Browse files
committed
Add "@no-named-arguments" tag support
1 parent ffb8649 commit 4521bde

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ composer require type-lang/phpdoc
5454
and a website, which is identified by an absolute URI
5555
- [x] `@method` - Allows a class to know which "_magic_" methods are callable
5656
- [ ] `@mixin` - TODO
57-
- [ ] `@no-named-arguments` - TODO
57+
- [x] `@no-named-arguments` - Indicates that argument names may be
58+
changed in the future.
5859
- [ ] `@package` - TODO
5960
- [ ] `@override` - TODO
6061
- [x] `@param` - Used to document a single argument of a function or method
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TypeLang\PHPDoc\DocBlock\Tag\NoNamedArgumentsTag;
6+
7+
use TypeLang\PHPDoc\DocBlock\Tag\Tag;
8+
9+
/**
10+
* Indicates that argument names may be changed in the future, and an update
11+
* may break backwards compatibility with unction calls using named arguments.
12+
*
13+
* ```
14+
* "@no-named-arguments" [<description>]
15+
* ```
16+
*/
17+
final class NoNamedArgumentsTag extends Tag
18+
{
19+
public function __construct(
20+
string $name,
21+
\Stringable|string|null $description = null,
22+
) {
23+
parent::__construct($name, $description);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TypeLang\PHPDoc\DocBlock\Tag\NoNamedArgumentsTag;
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 "`@no-named-arguments`" tags.
13+
*
14+
* See {@see NoNamedArgumentsTag} for details about this tag.
15+
*/
16+
final class NoNamedArgumentsTagFactory implements TagFactoryInterface
17+
{
18+
public function create(string $tag, string $content, DescriptionParserInterface $descriptions): NoNamedArgumentsTag
19+
{
20+
$stream = new Stream($tag, $content);
21+
22+
return new NoNamedArgumentsTag(
23+
name: $tag,
24+
description: $stream->toOptionalDescription($descriptions),
25+
);
26+
}
27+
}

Diff for: src/Platform/StandardPlatform.php

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use TypeLang\PHPDoc\DocBlock\Tag\IgnoreTag\IgnoreTagFactory;
1212
use TypeLang\PHPDoc\DocBlock\Tag\LinkTag\LinkTagFactory;
1313
use TypeLang\PHPDoc\DocBlock\Tag\MethodTag\MethodTagFactory;
14+
use TypeLang\PHPDoc\DocBlock\Tag\NoNamedArgumentsTag\NoNamedArgumentsTagFactory;
1415
use TypeLang\PHPDoc\DocBlock\Tag\ParamTag\ParamTagFactory;
1516
use TypeLang\PHPDoc\DocBlock\Tag\PropertyTag\PropertyReadTagFactory;
1617
use TypeLang\PHPDoc\DocBlock\Tag\PropertyTag\PropertyTagFactory;
@@ -41,6 +42,7 @@ protected function load(TypesParserInterface $types): iterable
4142
yield 'ignore' => new IgnoreTagFactory();
4243
yield 'link' => new LinkTagFactory();
4344
yield 'method' => new MethodTagFactory($types);
45+
yield 'no-named-arguments' => new NoNamedArgumentsTagFactory();
4446
yield 'param' => new ParamTagFactory($types);
4547
yield 'property' => new PropertyTagFactory($types);
4648
yield 'property-read' => new PropertyReadTagFactory($types);

0 commit comments

Comments
 (0)