Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Unexpected character in input #74

Closed
scottconnerly opened this issue Feb 15, 2018 · 2 comments
Closed

Unexpected character in input #74

scottconnerly opened this issue Feb 15, 2018 · 2 comments

Comments

@scottconnerly
Copy link

When running CodeCoverage::getLinesToBeIgnored(), PHP_Token_Stream::scan(), token_get_all() flips out because of the ASCII control characters in the file contents:
Warning: Unexpected character in input: '' (ASCII=30) state=0 in vendor/phpunit/php-token-stream/src/Token/Stream.php on line 162

All the ASCII characters it complained about: 1-8, 11, 12, 14-31. Or to put it another way, every non-printing (control) character except null, tab, new line and carriage return.
High level: http://www.asciitable.com/
For color commentary on each character: https://www.lammertbies.nl/comm/info/ascii-characters.html

I suggest adding this line into scan() just before token_get_all():
$sourceCode = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', '', $sourceCode);
h/t: https://stackoverflow.com/a/1497928/218967 plus allowing 09 (horiz tab) to stay

I was using this package successfully up until today. Today's also the first time I've run coverage reports on this codebase while in a Docker container. Could have something to do with the overlayfs file system this Debian (w/ coreutils 8.26) image?

Has something recently changed with the whitelisting feature in CodeCoverage? I used to be including /somefolder/* but noticed this was now scanning all files (png, ttf, txt, bmp, etc). This could also be why its even encountering these ASCII characters in the first place. I've updated my whitelist to /somefolder/*.php but don't think I should have had to.

@sebastianbergmann
Copy link
Owner

Thank you for your report.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.

Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.

@sebastianbergmann
Copy link
Owner

No feedback, closing.

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

No branches or pull requests

2 participants