Closed localheinz closed 4 years ago
Do you have an exception backtrace, so it's possible to see which of the escapeString() calls is responsible?
I guess this is one of the traces you are asking for
- PHP File : /Users/am/Sites/clxmstaab/active-record-repro/lib/min/CSSmin.php
Analyzed Class: CSSmin
Exception(s) :
- Class : Roave\BetterReflection\SourceLocator\Ast\Exception\ParseToAstFailure
Message : AST failed to parse in located source (in /Users/am/Sites/clxmstaab/active-record-repro/lib/min/JSMin.php)
Thrown in : /Users/am/Sites/clxmstaab/active-record-repro/vendor-bin/clx-active-record-fixer/vendor/roave/better-reflection/src/SourceLocator/Ast/Exception/ParseToAstFailure.php::27
- Class : TypeError
Message : addcslashes() expects parameter 1 to be string, null given
Thrown in : /Users/am/Sites/clxmstaab/active-record-repro/vendor-bin/clx-active-record-fixer/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php::965
I ran the provided file through bin/php-parse -p
and didn't get an error, so this is likely specific to how BetterReflection uses PHP-Parser in some way.
Closing this per https://github.com/Roave/BetterReflection/pull/690. From what I gathered, JSON serialization with JSON_PARTIAL_OUTPUT_ON_ERROR was used, and the string contained invalid UTF-8, which cannot be represented using JSON.
Thank you, @nikic!
In a project using
nikic/php-parser:4.9.1
roave/better-reflection:4.9.0
when parsing the following file
we encounter a
TypeError
with the messageaddcslashes() expects parameter 1 to be string, null given
, thrown inPhpParser\PrettyPrinter\Standard::escapeString()
.Perhaps someone has encountered a similar problem? Not sure why the method does not have type declarations, or what should happen when either or both of the arguments are
null
.