You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PRISM drops a PHP heredoc's newlines: every function after one reports the wrong start_line #3555
PRISM's PHP code_stream collapses a heredoc or nowdoc (<<<EOD … EOD;) to ""and removes its newlines. So every line number after a heredoc is shifted, including start_line/end_line for every later function, SARIF locations, and anything that anchors on lines.
Minimal repro:
src="<?php\nfunction a() {\n $x = <<<EOD\nline1\nline2\nline3\nEOD;\n}\nfunction b() {}\n"code=Prism(LEXICAL_FAMILY_HEURISTICS, LANGUAGE_DEFINITIONS).split_streams(src, "php")["code_stream"]
# code == '<?php\nfunction a() {\n $x = ""\n}\nfunction b() {}\n' -- 9 newlines in, 5 out# splice(): b reported at line 4; it is on line 9
On the corpus, php/wordpress/functions.php has 9284 raw lines but only 9274 in its code stream. Every function after the heredoc at line 4238 (_xml_wp_die_handler) reports a start_line 10-11 lines early; _scalar_wp_die_handler is the first.
I checked 16 other languages' multi-line string forms: Ruby/Perl/shell heredocs, Python/Kotlin/Swift/Scala/Java triple-quoted strings, JS/TS template literals, Go raw strings, Rust raw strings, C# verbatim strings, C++ raw strings, Lua long brackets and Dart '''. None lose lines. This is PHP-only.
Impact
Wrong line numbers in the DB and SARIF for every PHP unit after a heredoc.
Make PRISM's PHP heredoc/nowdoc shield preserve the newline count: replace the body with "" followed by the same number of \n, or blank each body line as other languages' multi-line shields do. Check with raw.count("\n") == code_stream.count("\n") on wordpress/functions.php. Re-bless the golden masters; expect PHP start_line/end_line moves only, after heredocs.
Activity
fix(spans): functions start on their declaration line in TS/JS/PHP (#…