Skip to content

Commit addd1da

Browse files
committed
Add test file for PSR12.Operators.OperatorSpacing
The sniff has specific logic to avoid an out-of-bounds array offset access. Before now, there were no tests which covered this logic. This commit adds such a test. The sniff already handles this, so there are no changes required there. This particular omission was detected by infection/infection. ```diff src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php:104 [M] FalseValue @@ @@ } } else { // Skip partial files. - $checkAfter = false; + $checkAfter = true; } if ($checkBefore === true && $tokens[$stackPtr - 1]['code'] !== T_WHITESPACE) { $error = 'Expected at least 1 space before "%s"; 0 found'; ```
1 parent 8581f0c commit addd1da

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
// There is logic in the sniff which protects itself from reading beyond the end
3+
// of a file when an inline-if (ternary) operator is detected. This test case
4+
// covers that scenario. This is an intentional parse error.
5+
// Note that there is (intentionally) no trailing newline at the end of this file.
6+
$var = true ?

0 commit comments

Comments
 (0)