Skip to content

Commit

Permalink
Fixed an issue when the very first content in a file was a phpcs: com…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
gsherwood committed Oct 31, 2017
1 parent b4501f6 commit a1db83c
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/Tokenizers/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,18 @@ private function createPositionMap()
// to ignore the following line. If the line contains other content
// then we are just ignoring this one single line.
$ownLine = false;
for ($prev = ($i - 1); $prev >= 0; $prev--) {
if ($this->tokens[$prev]['code'] === T_WHITESPACE) {
continue;
}
if ($i > 0) {
for ($prev = ($i - 1); $prev >= 0; $prev--) {
if ($this->tokens[$prev]['code'] === T_WHITESPACE) {
continue;
}

break;
}
break;
}

if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
$ownLine = true;
if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
$ownLine = true;
}
}

if ($ignoring === null
Expand Down Expand Up @@ -279,16 +281,18 @@ private function createPositionMap()
// to ignore the following line. If the line contains other content
// then we are just ignoring this one single line.
$ownLine = false;
for ($prev = ($i - 1); $prev >= 0; $prev--) {
if ($this->tokens[$prev]['code'] === T_WHITESPACE) {
continue;
}
if ($i > 0) {
for ($prev = ($i - 1); $prev >= 0; $prev--) {
if ($this->tokens[$prev]['code'] === T_WHITESPACE) {
continue;
}

break;
}
break;
}

if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
$ownLine = true;
if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
$ownLine = true;
}
}

if (substr($commentTextLower, 0, 9) === 'phpcs:set') {
Expand Down

0 comments on commit a1db83c

Please sign in to comment.