Skip to content

Commit 9982a6e

Browse files
author
Kirill Nesmeyanov
committed
Fix psalm errors
1 parent fb467d5 commit 9982a6e

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/DocBlock/Tag/CommonTypedTagFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace TypeLang\PhpDocParser\DocBlock\Tag;
66

77
use TypeLang\Parser\Parser;
8-
use TypeLang\Parser\ParserInterface;
98
use TypeLang\PhpDocParser\DocBlock\DescriptionFactoryInterface;
109
use TypeLang\PhpDocParser\Exception\InvalidTagException;
1110

src/DocBlock/Tag/CommonTypedTagWithNameFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace TypeLang\PhpDocParser\DocBlock\Tag;
66

7-
use TypeLang\Parser\ParserInterface;
7+
use TypeLang\Parser\Parser;
88
use TypeLang\PhpDocParser\DocBlock\DescriptionFactoryInterface;
99
use TypeLang\PhpDocParser\DocBlock\Extractor\TagVariableExtractor;
1010
use TypeLang\PhpDocParser\Exception\InvalidTagException;
@@ -23,7 +23,7 @@ final class CommonTypedTagWithNameFactory extends TypedTagFactory
2323
*/
2424
public function __construct(
2525
private readonly string $class,
26-
ParserInterface $parser,
26+
private readonly Parser $parser,
2727
?DescriptionFactoryInterface $descriptions = null,
2828
) {
2929
$this->variables = new TagVariableExtractor();
@@ -38,7 +38,7 @@ public function create(string $tag): TypedTag
3838
try {
3939
[$variable, $description] = $this->variables->extractOrFail($description);
4040
} catch (InvalidTagVariableNameException $e) {
41-
$offset = $this->types->getTypeOffset($type);
41+
$offset = $this->parser->lastProcessedTokenOffset;
4242

4343
throw InvalidTagVariableNameException::fromTyped($type, $offset, $e);
4444
}

src/DocBlock/Tag/TypedTagFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace TypeLang\PhpDocParser\DocBlock\Tag;
66

77
use TypeLang\Parser\Parser;
8-
use TypeLang\Parser\ParserInterface;
98
use TypeLang\PhpDocParser\DocBlock\DescriptionFactoryInterface;
109
use TypeLang\PhpDocParser\DocBlock\Extractor\TagTypeExtractor;
1110

src/DocBlockFactory.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace TypeLang\PhpDocParser;
66

77
use TypeLang\Parser\Parser;
8-
use TypeLang\Parser\ParserInterface;
98
use TypeLang\PhpDocParser\DocBlock\Description;
109
use TypeLang\PhpDocParser\DocBlock\DescriptionFactory;
1110
use TypeLang\PhpDocParser\DocBlock\DescriptionFactoryInterface;
@@ -61,7 +60,7 @@ public function __construct(
6160
public readonly TagFactoryInterface $tags,
6261
) {}
6362

64-
public static function createInstance(?ParserInterface $parser = null): self
63+
public static function createInstance(?Parser $parser = null): self
6564
{
6665
$tags = new StandardTagFactory();
6766

@@ -98,10 +97,14 @@ public static function getStandardPrefixes(): iterable
9897
/**
9998
* @return iterable<non-empty-lowercase-string|list<non-empty-lowercase-string>, TagFactoryInterface>
10099
*/
101-
public static function getStandardTags(?ParserInterface $parser = null): iterable
100+
public static function getStandardTags(?Parser $parser = null): iterable
102101
{
103102
$parser ??= new Parser(true);
104103

104+
if (!$parser->tolerant) {
105+
throw new \InvalidArgumentException('Tolerant parser mode required');
106+
}
107+
105108
// Typed doc blocks
106109
yield 'var' => new CommonTypedTagFactory(VarTag::class, $parser);
107110
yield 'global' => new CommonTypedTagWithNameFactory(GlobalTag::class, $parser);

0 commit comments

Comments
 (0)