File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ public function process(
6262 BlockContext $ blockContext ,
6363 Directive $ directive ,
6464 ): Node |null {
65+ if ($ blockContext ->getDocumentIterator ()->isEmpty ()) {
66+ $ this ->logger ->warning ('The code-block has no content. Did you properly indent the code? ' , $ blockContext ->getLoggerInformation ());
67+
68+ return null ;
69+ }
70+
6571 $ node = new CodeNode (
6672 $ blockContext ->getDocumentIterator ()->toArray (),
6773 );
Original file line number Diff line number Diff line change 1717use OutOfBoundsException ;
1818
1919use function chr ;
20+ use function count ;
2021use function explode ;
2122use function max ;
2223use function mb_strpos ;
@@ -133,6 +134,11 @@ public function toArray(): array
133134 return $ this ->lines ;
134135 }
135136
137+ public function isEmpty (): bool
138+ {
139+ return count ($ this ->lines ) === 0 || (count ($ this ->lines ) === 1 && trim ($ this ->lines [0 ]) === '' );
140+ }
141+
136142 /** @psalm-assert-if-false non-empty-string $line */
137143 public static function isEmptyLine (string |null $ line ): bool
138144 {
You can’t perform that action at this time.
0 commit comments