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

PHP Warning on startup when using Infection from PHAR #1770

Open
sebastianbergmann opened this issue Dec 6, 2022 · 4 comments · Fixed by #1771
Open

PHP Warning on startup when using Infection from PHAR #1770

sebastianbergmann opened this issue Dec 6, 2022 · 4 comments · Fixed by #1771
Labels

Comments

@sebastianbergmann
Copy link

I am using Infection in a project that has a composer.json file as well as a vendor/autoload.php file but no vendor/composer/InstalledVersions.php file since no dependencies are defined in composer.json:

$ ./tools/infection --version
PHP Warning:  include(/path/to/project/vendor/composer/../composer/InstalledVersions.php): Failed to open stream: No such file or directory in phar:///path/to/project/tools/infection/.box/vendor/composer/ClassLoader.php on line 571
PHP Warning:  include(): Failed opening '/path/to/project/vendor/composer/../composer/InstalledVersions.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php:/usr/share/pear:/usr/share/php') in phar:///path/to/project/tools/infection/.box/vendor/composer/ClassLoader.php on line 571
Infection - PHP Mutation Testing Framework version 0.26.16

It appears that Infection assumes that vendor/composer/InstalledVersions.php always exists and unconditionally tries to open it.

@sanmai
Copy link
Member

sanmai commented Dec 6, 2022

Did you purposefully remove vendor/composer/InstalledVersions.php?

I see that Composer autoloader will try to open this file if you remove it. Even a simple class_exists() triggers this.

@sebastianbergmann
Copy link
Author

No, I did/do not delete this file on purpose.

I use classmap-based autoloading (generated by Composer) and have no Composer-installed dependencies:

$ cat composer.json
{
    "name": "example/example",
    "description": "example",
    "license": "proprietary",

    "config": {
        "platform": {
            "php": "8.2.0"
        },
        "optimize-autoloader": true,
        "sort-packages": true
    },

    "autoload": {
        "classmap": [
            "src/"
        ]
    }
}
$ composer dump-autoload
Generating optimized autoload files
Generated optimized autoload files containing 16 classes
$ tree vendor 
vendor
├── autoload.php
└── composer
    ├── autoload_classmap.php
    ├── autoload_namespaces.php
    ├── autoload_psr4.php
    ├── autoload_real.php
    ├── autoload_static.php
    ├── ClassLoader.php
    └── LICENSE

1 directory, 8 files

@theofidry
Copy link
Member

Interesting... I'll have to double on PHP-Scoper/Box side that I do handle this scenario well too.

@sanmai
Copy link
Member

sanmai commented Dec 7, 2022

I don't think we fixed the issue with #1771, therefore I'm going to reopen this. If that's not the case, please feel free to close, or add any details as well.

@sanmai sanmai reopened this Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants