Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.6.0 breaks unterminated comment parsing. #688

Closed
bobthecow opened this issue Jul 22, 2020 · 2 comments
Closed

v4.6.0 breaks unterminated comment parsing. #688

bobthecow opened this issue Jul 22, 2020 · 2 comments

Comments

@bobthecow
Copy link

The changes in 4.6.0 to the trailing comment newlines broke unterminated comment parsing errors. Here's a failing build.

A minimal repro case for the issue:

<?php
require 'vendor/autoload.php';

use PhpParser\Error;
use PhpParser\ParserFactory;

$parser = (new ParserFactory)->create(ParserFactory::ONLY_PHP7);

// this one works (fails?) as expected
try {
  $parser->parse("<?php /* unterminated comment");
  echo "boo :(\n";
} catch (Error $error) {
  echo "yay! {$error->getMessage()}\n";
}

// this one parses as a valid comment
try {
  $parser->parse("<?php /* unterminated comment\n");
  echo "boo :(\n";
} catch (Error $error) {
  echo "yay! {$error->getMessage()}\n";
}
@nikic nikic closed this as completed in 739b4b4 Jul 22, 2020
@nikic
Copy link
Owner

nikic commented Jul 22, 2020

Thanks for catching this!

@bobthecow
Copy link
Author

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants