PHPUnit_Util_Type::export adds extra newlines in Windows #581

zeebinz opened this Issue Jun 3, 2012 · 2 comments


None yet
2 participants

zeebinz commented Jun 3, 2012

Specifically this line from the called PHPUnit_Util_Type::recursiveExport replaces any string concatenated with PHP_EOL in Windows with an extra newline, mangling the result somewhat:

str_replace(array("\n\r", "\r"), array("\n", "\n"), $value)


edorian commented Jun 5, 2012

And the fix would be

str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value)

? Or what are you getting at? Just making sure I understand the problem?

I'd also take a reproduce case if you want :)

zeebinz commented Jun 5, 2012

Yes, that works fine, thanks. I don't know the code well enough to understand why the substitution needs to be made, or indeed what "\n\r" is, but I'm guessing there's a good reason. :)

Just to add: I'm seeing the problem currently when capturing output that includes PHP_EOLs , and an assertRegExp fails - whole output is echoed with the extra lines. Not a big deal, really, but could be confusing for some as the input string doesn't match the error output.

edorian closed this in 6f60604 Sep 6, 2012

@greglamb greglamb pushed a commit to greglamb/phpunit that referenced this issue Apr 19, 2013

@edorian edorian Fixes #581: Windows diffs where polluted with extra newlines 8f17b6c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment