File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 66
77final class FeatureNotAllowedException extends SemanticException
88{
9+ /**
10+ * @param non-empty-string $name
11+ * @param int<0, max> $offset
12+ */
913 public static function fromFeature (string $ name , int $ offset = 0 ): self
1014 {
1115 $ message = \sprintf ('%s not allowed by parser configuration ' , $ name );
Original file line number Diff line number Diff line change @@ -120,6 +120,8 @@ private function createLexer(array $grammar): Lexer
120120 */
121121 public function parse (#[Language('PHP ' )] mixed $ source ): ?TypeStatement
122122 {
123+ $ this ->lastProcessedTokenOffset = 0 ;
124+
123125 /** @psalm-suppress PossiblyInvalidArgument */
124126 $ source = File::new ($ source );
125127
@@ -132,9 +134,12 @@ public function parse(#[Language('PHP')] mixed $source): ?TypeStatement
132134 foreach ($ this ->parser ->parse ($ source ) as $ stmt ) {
133135 if ($ stmt instanceof TypeStatement) {
134136 $ context = $ this ->parser ->getLastExecutionContext ();
135- $ token = $ context ->buffer ->current ();
136137
137- $ this ->lastProcessedTokenOffset = $ token ->getOffset ();
138+ if ($ context !== null ) {
139+ $ token = $ context ->buffer ->current ();
140+
141+ $ this ->lastProcessedTokenOffset = $ token ->getOffset ();
142+ }
138143
139144 return $ stmt ;
140145 }
You can’t perform that action at this time.
0 commit comments