Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process Isolation does not work with phpunit.phar #3509

Closed
olemartinorg opened this issue Feb 3, 2019 · 2 comments
Closed

Process Isolation does not work with phpunit.phar #3509

olemartinorg opened this issue Feb 3, 2019 · 2 comments
Labels
type/bug Something is broken

Comments

@olemartinorg
Copy link

Q A
PHPUnit version 8.0.0
PHP version Both 7.3.1 and 7.2.14
Installation Method PHAR

Steps to reproduce:

  1. Install PHPUnit 8.0.0 via phar:
    wget https://phar.phpunit.de/phpunit-8.0.0.phar && chmod a+x phpunit-8.0.0.phar

  2. With any test file:

<?php
class Test extends PHPUnit\Framework\TestCase {
    public function testTrue(): void {
        $this->assertTrue(true);
    }
}
  1. Run it with process isolation:
    ./phpunit-8.0.0.phar --process-isolation test.php

Observe the failure:

PHPUnit 8.0.0 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 124 ms, Memory: 10.00MB

There was 1 error:

1) Test::testTrue
PHPUnit\Framework\Exception: PHP Fatal error:  strict_types declaration must be the very first statement in the script in /path/phpunit-8.0.0.phar on line 2
PHP Stack trace:
PHP   1. {main}() Standard input code:0

Fatal error: strict_types declaration must be the very first statement in the script in /path/phpunit-8.0.0.phar on line 2

Call Stack:
    0.0008     511120   1. {main}() Standard input code:0

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
@sebastianbergmann sebastianbergmann changed the title Process isolation not working in 8.0.0 Process Isolation does not work with phpunit.phar Feb 3, 2019
@sebastianbergmann sebastianbergmann added the type/bug Something is broken label Feb 3, 2019
@sebastianbergmann
Copy link
Owner

It seems that there is a bug in PHP that when a PHAR is include()d or require()d and the PHAR's bootstrap script has a shebang such as #!/usr/bin/env php on its first line followed by <?php declare(strict_types=1); on its second line then PHP wrongly triggers a

strict_types declaration must be the very first statement in the script

compiler error.

@sebastianbergmann
Copy link
Owner

The PHP bug is tracked in https://bugs.php.net/bug.php?id=77561.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants