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

Clean project ApiPlatform + PhpUnit 11 + PHP 8.3.x -> nikic/php-parser minimum version bump needed #1918

Closed
rkeet opened this issue Mar 17, 2024 · 3 comments · Fixed by #1909

Comments

@rkeet
Copy link

rkeet commented Mar 17, 2024

Problem:

Unable to install latest infection/infection due to non-yet upgraded support for latest nikic/php-parser dependency

Fix:

Out of scope of report

  • taking into consideration semver of this repo
  • taking needed work into consideration
  • trying to reproduce without ApiPlatform present (plain PhpUnit 11 + PHP8.3)

Because I didn't see an Issue for this I thought to create it. Unfortunately, I don't have time to fully flesh out/fix the issues or perform the upgrade and create a PR, otherwise I might look into it a bit.

General info

Question Answer
Infection version Latest - attempted installation fails
Test Framework version PhpUnit 11.0.6
PHP version 8.3.4
Platform Windows + WSL Ubuntu 22.04.4 LTS, but also php:8.3.4-cli-alpine3.19 Docker image
Github Repo Related: nikic/php-parser (infection dependency)

Reproduce

  • Have the above setup (PHP version + ApiPlatform + PhpUnit)
  • Run composer install for below composer.json
  • Run composer require --dev infection/infection
composer.json
{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "api-platform/core": "^3.2",
        "doctrine/dbal": "^3",
        "doctrine/doctrine-bundle": "^2.11",
        "doctrine/doctrine-migrations-bundle": "^3.3",
        "doctrine/orm": "^3.1",
        "nelmio/cors-bundle": "^2.4",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.26",
        "symfony/asset": "^7.0",
        "symfony/console": "^7.0",
        "symfony/dotenv": "^7.0",
        "symfony/expression-language": "^7.0",
        "symfony/flex": "^2",
        "symfony/framework-bundle": "^7.0",
        "symfony/property-access": "^7.0",
        "symfony/property-info": "^7.0",
        "symfony/runtime": "^7.0",
        "symfony/security-bundle": "^7.0",
        "symfony/serializer": "^7.0",
        "symfony/twig-bundle": "^7.0",
        "symfony/validator": "^7.0",
        "symfony/yaml": "^7.0",
        "webonyx/graphql-php": "^15.11"
    },
    "require-dev": {
        "phpunit/phpunit": "^11.0",
        "roave/security-advisories": "dev-latest",
        "squizlabs/php_codesniffer": "^3.9",
        "symfony/phpunit-bridge": "^7.0"
    },
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*",
        "symfony/polyfill-php82": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "^7.0"
        }
    }
}

PhpUnit config - defaults minus non-working config from default template

phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
        backupGlobals="false"
        colors="true"
        bootstrap="tests/bootstrap.php">
<!--         convertDeprecationsToExceptions="false"-->

   <php>
       <ini name="display_errors" value="1" />
       <ini name="error_reporting" value="-1" />
       <server name="APP_ENV" value="test" force="true" />
       <server name="SHELL_VERBOSITY" value="-1" />
       <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
       <server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
   </php>

   <testsuites>
       <testsuite name="Project Test Suite">
           <directory>tests</directory>
       </testsuite>
   </testsuites>

<!--    <coverage processUncoveredFiles="true">-->
<!--        <include>-->
<!--            <directory suffix=".php">src</directory>-->
<!--        </include>-->
<!--    </coverage>-->

<!--    <listeners>-->
<!--        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />-->
<!--    </listeners>-->

   <extensions>
   </extensions>
</phpunit>

Attempted infection installation (composer require --dev) output

Highlight line:

- infection/infection[0.26.17, ..., 0.27.10] require nikic/php-parser ^4.15.1 -> found nikic/php-parser[v4.15.1, ..., v4.19.1] but the package is fixed to v5.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Output with issue
me@my-pc: ~/api (main)$ composer require --dev infection/infection
./composer.json has been updated
Running composer update infection/infection
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "^7.0"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

 Problem 1
   - infection/infection[0.1.0, ..., 0.9.3] require php ^7.0 -> your php version (8.3.4) does not satisfy that requirement.
   - infection/infection[0.10.0, ..., 0.11.5] require php ^7.1 -> your php version (8.3.4) does not satisfy that requirement.
   - infection/infection[0.12.0, ..., 0.13.6] require php ^7.1.3 -> your php version (8.3.4) does not satisfy that requirement.
   - infection/infection[0.14.0, ..., 0.15.3] require php ^7.2.9 -> your php version (8.3.4) does not satisfy that requirement.
   - infection/infection[0.16.0, ..., 0.18.1] require php ^7.3 -> your php version (8.3.4) does not satisfy that requirement.
   - infection/infection[0.18.2, ..., 0.20.2] require nikic/php-parser ^4.10.2 -> found nikic/php-parser[v4.10.2, ..., v4.19.1] but the package is fixed to v5.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - infection/infection[0.21.0, ..., 0.25.3] require nikic/php-parser ^4.10.3 -> found nikic/php-parser[v4.10.3, ..., v4.19.1] but the package is fixed to v5.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - infection/infection[0.25.4, ..., 0.26.3] require nikic/php-parser ^4.13 -> found nikic/php-parser[v4.13.0, ..., v4.19.1] but the package is fixed to v5.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - infection/infection[0.26.4, ..., 0.26.16] require nikic/php-parser ^4.13.2 -> found nikic/php-parser[v4.13.2, ..., v4.19.1] but the package is fixed to v5.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - infection/infection[0.26.17, ..., 0.27.10] require nikic/php-parser ^4.15.1 -> found nikic/php-parser[v4.15.1, ..., v4.19.1] but the package is fixed to v5.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
   - Root composer.json requires infection/infection * -> satisfiable by infection/infection[0.1.0, ..., 0.27.10].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require infection/infection:*" to figure out if any version is installable, or "composer require infection/infection:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
@maks-rafalko
Copy link
Member

Hello, adding support for nikic/php-parser:^5 is in progress and can be tracked here: #1909

Meanwhile, you have 2 options:

  • use infection.phar, e.g. can be downloaded here: https://github.com/infection/infection/releases/tag/0.27.10. It's a prefixed PHAR distribution that doesn't conflict with project's dependencies
  • downgrade one of the depedency in your project that requires nikic/php-parser:^5. Can be found by composer why nikic/php-parser) or try other approaches like --with-all-dependecies

@rkeet
Copy link
Author

rkeet commented Mar 20, 2024

Ah, thank you! 😄
Have subscribed for updates! 👍

@maks-rafalko
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants