Description
Description
the example in question is reproducible with phpunit on windows, but I was not able to reduce it further to the actual root cause.
its super weird.
The following code:
<?php
$input = 'C:\dvl\Workspace\PHP-Parallel-Lint\tests/fixtures/fixture-07/example.php';
foreach (explode(PHP_EOL, $input) as $file) {
$skip = false;
$f = @fopen($file, 'r');
if ($f) {
$firstLine = fgets($f);
var_dump($firstLine);
var_dump($firstLine[0]);
var_dump($firstLine[1]);
var_dump(strpos($firstLine, '#!'));
}
echo $file . ';' . ($skip ? '1' : '0') . PHP_EOL;
}
with example.php
:
#!/usr/bin/php
<?php // lint < 5.3
$myString = 'This is always skipped';
echo $myString;
Resulted in this output:
string(15) "#!/usr/bin/php
"
string(1) "#"
string(1) "!"
bool(false)
But I expected this output instead:
string(15) "#!/usr/bin/php
"
string(1) "#"
string(1) "!"
bool(0)
No problems with the same code on Ubuntu.
The above example is not reproducible as is when running in isolation.
its reproducible though when running as part of the test-suite of PHP-Parallel-Lint (see steps below).
I think its somehow related to that the code is invoked via
$this->process = proc_open($cmdLine, $descriptors, $pipes, null, null, array('bypass_shell' => true));
Steps to reproduce the problem on a Windows machine
git clone https://github.com/php-parallel-lint/PHP-Parallel-Lint
composer install
./vendor/bin/phpunit --no-coverage tests/Unit/ParallelLintLintTest.php --filter=testSkipShebang
-> results in a PHPUnit test-failure but should succeed
this test executes skip-linting.php which fails because of the strange logic happening I described earlier.
PHP Version
PHP 8.2.12 and others
Operating System
Windows