Skip to content

Commit da1a231

Browse files
committed
refactor(Comment): split inStringOrCommentEnd()
1 parent e702bde commit da1a231

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Comment.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,26 @@ protected function getSegments($json)
7777
}
7878

7979
protected function inStringOrCommentEnd($prev, $char, $charnext)
80+
{
81+
return $this->inString($char, $prev) || $this->inCommentEnd($charnext);
82+
}
83+
84+
protected function inString($char, $prev)
8085
{
8186
if (0 === $this->comment && $char === '"' && $prev !== '\\') {
8287
$this->inStr = !$this->inStr;
8388
}
8489

90+
return $this->inStr;
91+
}
92+
93+
protected function inCommentEnd($charnext)
94+
{
8595
if (!$this->inStr && 0 === $this->comment) {
8696
$this->comment = $charnext === '//' ? 1 : ($charnext === '/*' ? 2 : 0);
8797
}
8898

89-
return $this->inStr || 0 === $this->comment;
99+
return 0 === $this->comment;
90100
}
91101

92102
protected function hasCommentEnded($char, $charnext)

0 commit comments

Comments
 (0)