Skip to content

Commit 2478a72

Browse files
committed
Improve type nodes and add node tests
1 parent cf6e84b commit 2478a72

53 files changed

Lines changed: 584 additions & 452 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libs/parser/resources/grammar.php

Lines changed: 253 additions & 250 deletions
Large diffs are not rendered by default.

libs/parser/src/Exception/FeatureNotAllowedException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class FeatureNotAllowedException extends SemanticException
99
/**
1010
* @param non-empty-string $name
1111
* @param int<0, max> $offset
12-
*
1312
* @return static
1413
*/
1514
public static function fromFeature(string $name, int $offset = 0): self

libs/parser/src/Exception/Formatter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public static function source(string $statement): string
4141

4242
/**
4343
* @param int<0, max> $offset
44-
*
4544
* @return non-empty-string
4645
*/
4746
public static function suffix(string $statement, int $offset): string

libs/parser/src/Exception/ParseException.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ final public function __construct(string $message, int $code = 0, ?\Throwable $p
3131
* unexpected source location.
3232
*
3333
* @param int<0, max> $offset
34-
*
3534
* @throws SourceExceptionInterface
3635
*/
3736
public static function fromUnexpectedToken(string $token, string $statement, int $offset): static
@@ -49,7 +48,6 @@ public static function fromUnexpectedToken(string $token, string $statement, int
4948
* This error occurs when unable to recognize tokens in source code.
5049
*
5150
* @param int<0, max> $offset
52-
*
5351
* @throws SourceExceptionInterface
5452
*/
5553
public static function fromUnrecognizedToken(string $token, string $statement, int $offset): static
@@ -65,7 +63,6 @@ public static function fromUnrecognizedToken(string $token, string $statement, i
6563

6664
/**
6765
* @param int<0, max> $offset
68-
*
6966
* @throws SourceExceptionInterface
7067
*/
7168
public static function fromUnrecognizedSyntaxError(string $statement, int $offset): static

libs/parser/src/Exception/SemanticException.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function getOffset(): int
4141
/**
4242
* @param non-empty-string $key
4343
* @param int<0, max> $offset
44-
*
4544
* @return static
4645
*/
4746
public static function fromShapeFieldDuplication(string $key, int $offset = 0): self
@@ -53,7 +52,6 @@ public static function fromShapeFieldDuplication(string $key, int $offset = 0):
5352

5453
/**
5554
* @param int<0, max> $offset
56-
*
5755
* @return static
5856
*/
5957
public static function fromShapeMixedKeys(int $offset = 0): self
@@ -65,7 +63,6 @@ public static function fromShapeMixedKeys(int $offset = 0): self
6563

6664
/**
6765
* @param int<0, max> $offset
68-
*
6966
* @return static
7067
*/
7168
public static function fromVariadicWithDefault(int $offset = 0): self
@@ -77,7 +74,6 @@ public static function fromVariadicWithDefault(int $offset = 0): self
7774

7875
/**
7976
* @param int<0, max> $offset
80-
*
8177
* @return static
8278
*/
8379
public static function fromVariadicRedefinition(int $offset = 0): self
@@ -90,7 +86,6 @@ public static function fromVariadicRedefinition(int $offset = 0): self
9086
/**
9187
* @param non-empty-string $operator
9288
* @param int<0, max> $offset
93-
*
9489
* @return static
9590
*/
9691
public static function fromInvalidConditionalOperator(string $operator, int $offset = 0): self

libs/parser/src/Internal/ExecutionContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* reducers: array<int<0, max>|non-empty-string, callable(Context, mixed): mixed>,
3737
* transitions?: array<array-key, mixed>
3838
* }
39-
*
4039
* @phpstan-type ParserConfigArrayType array<ParserConfigsInterface::CONFIG_*, mixed>
4140
*
4241
* @internal this is an internal library class, please do not use it in your code
@@ -55,6 +54,7 @@
5554
* In-memory string literal pool.
5655
*
5756
* @api this property is accessible inside the grammar reducers
57+
*
5858
* @var \WeakMap<TokenInterface, StringLiteralNode>
5959
*/
6060
protected \WeakMap $stringPool;
@@ -63,6 +63,7 @@
6363
* In-memory integer literal pool.
6464
*
6565
* @api this property is accessible inside the grammar reducers
66+
*
6667
* @var \WeakMap<TokenInterface, IntLiteralNode>
6768
*/
6869
protected \WeakMap $integerPool;
@@ -97,7 +98,6 @@ private function createBuilder(array $reducers): BuilderInterface
9798

9899
/**
99100
* @param GrammarConfigArrayType $grammar
100-
*
101101
* @return ParserRuntime<TypeNode>
102102
*/
103103
private function createParser(LexerInterface $lexer, array $grammar): ParserRuntime

libs/parser/src/Traverser.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ public function __construct(iterable $visitors = [])
2626

2727
/**
2828
* @template TArgVisitor of VisitorInterface
29-
*
3029
* @param TArgVisitor $visitor
3130
* @param iterable<array-key, Node> $nodes
32-
*
3331
* @return TArgVisitor
3432
*/
3533
public static function through(VisitorInterface $visitor, iterable $nodes): VisitorInterface

libs/parser/src/TypeParserInterface.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ interface TypeParserInterface
2929
* // => ParseException
3030
* ```
3131
*
32-
* @param TSource $source Source code to parse.
33-
*
32+
* @param TSource $source source code to parse
3433
* @throws ParserExceptionInterface in case of parsing exception occurs
3534
* @throws \Throwable in case of internal error occurs
3635
*/
@@ -68,10 +67,9 @@ public function parse(#[Language('PHP')] mixed $source): TypeNode;
6867
* // => "This is an example"
6968
* ```
7069
*
71-
* @param TSource $source Source code to parse.
72-
*
73-
* @return ParsedResult Parsing result containing a partial AST, parser
74-
* state, and syntax diagnostics.
70+
* @param TSource $source source code to parse
71+
* @return ParsedResult parsing result containing a partial AST, parser
72+
* state, and syntax diagnostics
7573
* @throws ParserExceptionInterface in case of parsing exception occurs
7674
* @throws \Throwable in case of internal error occurs
7775
*/

libs/parser/src/TypeResolverInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ interface TypeResolverInterface
1616
* replacement.
1717
*
1818
* @template TArgType of TypeNode
19-
*
2019
* @param TArgType $type
2120
* @param callable(Name):(Name|null) $transform
22-
*
2321
* @return TArgType
2422
*/
2523
public function resolve(TypeNode $type, callable $transform): TypeNode;

libs/parser/tests/Syntax/AttributeTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*
1313
* Note: the AST dump renders the attribute structure (groups and names) but
1414
* not the attribute argument values.
15-
*
1615
*/
1716
#[Group('unit'), Group('type-lang/parser')]
1817
final class AttributeTest extends SyntaxTestCase

0 commit comments

Comments
 (0)