Skip to content

Commit 7f5c88a

Browse files
committed
PSR12/DeclareStatement - handle parse error
1 parent 2d90233 commit 7f5c88a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ public function process(File $phpcsFile, $stackPtr)
110110

111111
// There should be no space between equal sign and directive value.
112112
$value = $phpcsFile->findNext(T_WHITESPACE, ($equals + 1), null, true);
113+
114+
if ($value === false) {
115+
// Live coding / parse error.
116+
return;
117+
}
118+
113119
if ($equals !== false) {
114120
if ($tokens[($equals + 1)]['type'] !== 'T_LNUMBER') {
115121
$error = 'Expected no space between equal sign and the directive value in a declare statement';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
// Safeguard sniff handles parse error/live coding correctly.
3+
declare(strict_types=

0 commit comments

Comments
 (0)