krakjoe / pcov

PCOV - CodeCoverage compatible driver for PHP
Other
697 stars 29 forks source link

Undefined variable: argv when running #22

Closed muglug closed 5 years ago

muglug commented 5 years ago

Running PHPUnit on https://github.com/vimeo/psalm I get

> vendor/bin/phpunit
PHPUnit 8.1.6 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.3.5 with PCOV 1.0.5
Configuration: /xxx/psalm/phpunit.xml.dist

Undefined variable: argv

It works just fine without pcov enabled. Unsure how to proceed.

register_argc_argv = Off

in my php.ini (but setting it to On doesn't help either).

krakjoe commented 5 years ago
krakjoe@fiji:/opt/src/psalm$ php -n -d zend_extension=xdebug.so -d xdebug.coverage_enable=1 vendor/bin/phpunit --debug --verbose
PHPUnit 8.2.1 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.2.20-dev with Xdebug 2.7.0alpha2-dev
Configuration: /opt/src/psalm/phpunit.xml.dist

Test 'Psalm\Tests\AnnotationTest::testPhpStormGenericsWithValidArrayIteratorArgument' started
Undefined variable: argv

Not a bug in pcov, and I can't find out what is outputting that extremely useless warning ...

@sebastianbergmann what's going on ?

krakjoe commented 5 years ago

Note worthy, this is a bug that has been introduced since I first developed this code, I know this because psalm is one of the repositories I tested against when developing the code, I've seen it run these tests hundreds and hundreds of time ...

krakjoe commented 5 years ago

At src/psalm-refactor.php line 19 argv is actually null ...

krakjoe commented 5 years ago

Trace:

PHPUnit\Framework\Error\Notice: Undefined variable: argv in /opt/src/psalm/src/psalm-refactor.php on line 19
  #0 include_once in /opt/src/psalm/vendor/phpunit/php-code-coverage/src/CodeCoverage.php on line 959
  #1 SebastianBergmann\CodeCoverage\CodeCoverage->initializeData in /opt/src/psalm/vendor/phpunit/php-code-coverage/src/CodeCoverage.php on line 239
  #2 SebastianBergmann\CodeCoverage\CodeCoverage->start in /opt/src/psalm/vendor/phpunit/phpunit/src/Framework/TestResult.php on line 635
  #3 PHPUnit\Framework\TestResult->run in /opt/src/psalm/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 823
  #4 PHPUnit\Framework\TestCase->run in /opt/src/psalm/vendor/phpunit/phpunit/src/Framework/TestSuite.php on line 568
  #5 PHPUnit\Framework\TestSuite->run in /opt/src/psalm/vendor/phpunit/phpunit/src/Framework/TestSuite.php on line 568
  #6 PHPUnit\Framework\TestSuite->run in /opt/src/psalm/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 619
  #7 PHPUnit\TextUI\TestRunner->doRun in /opt/src/psalm/vendor/phpunit/phpunit/src/TextUI/Command.php on line 201
  #8 PHPUnit\TextUI\Command->run in /opt/src/psalm/vendor/phpunit/phpunit/src/TextUI/Command.php on line 160
  #9 PHPUnit\TextUI\Command::main in /opt/src/psalm/vendor/phpunit/phpunit/phpunit on line 61
krakjoe commented 5 years ago

This will have to be reported upstream, there's nothing I can do about it since it's not pcov causing the bug ...

muglug commented 5 years ago

Sorry for wasting your time - fixed in https://github.com/vimeo/psalm/commit/6fa8b986ccbe4a261321e800856f0a575b71ded7

krakjoe commented 5 years ago

Ah, I'm very glad you figured it out, I was still picking psalm apart ...

FWIW, I remember that sebastian had some issues surrounding $argv in phpunit, I can't remember the exact nature of it, but it was solved by using $_SERVER["argv"] in it's place, which doe not rely on ini settings ... if you dig through commit logs, you might find some useful information that applies to your use of argv, even though it works, it might be worth a look ...