There I go through everything with full commands and a minimal test database (which I also describe how I created).
I don't see how I could possibly create a smaller or clearer example of the issue.
A psql script for setup would increase the self-contained nature of the test. In Linux I'd also use something like grep to test the output file and/or script outputs. More generally the test script should probably include pg_restore and then various psql commands to check that the resulting restored database contains the expected data.
That said, If I was setup for experimenting in Windows, probably including compiling, the provided information is enough to put together a complete test case to experiment with.
Whatever "strange things" cmd.exe does clearly doesn't show up for my cross-platform PHP CLI script. (I guess it's theoretically possible that PHP for Windows does some sort of "processing" automatically which pg_dump lacks, but I doubt it.)
The PHP script you show is a pure client-only script. The observed behavior is occurring in a client-server architecture, specifically in the communication interface between the two. It's also, quite probably, not restricted to pg_dump (a more useful test script would include trying to demonstrate the problem using just psql, probably using the -v option).