Skip to content

Commit

Permalink
Do not use emulative lexing
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Aug 12, 2020
1 parent e2dfcf0 commit c7e0455
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Counter.php
Expand Up @@ -11,6 +11,7 @@

use function substr_count;
use PhpParser\Error;
use PhpParser\Lexer;
use PhpParser\Node;
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;
Expand All @@ -31,7 +32,11 @@ public function countInSourceFile(string $sourceFile): LinesOfCode
public function countInSourceString(string $source): LinesOfCode
{
$linesOfCode = substr_count($source, "\n");
$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);

$parser = (new ParserFactory)->create(
ParserFactory::PREFER_PHP7,
new Lexer
);

try {
$nodes = $parser->parse($source);
Expand Down

0 comments on commit c7e0455

Please sign in to comment.