mrclay / Props

An IDE and static analysis friendly PHP DI container
MIT License
35 stars 9 forks source link

Fatal error on PHP 8.1 #12

Open habibimh opened 1 year ago

habibimh commented 1 year ago

Hi Elan, I tried to run Props project and faced this issue:

Fatal error: Declaration of Props\Container::has($name) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /var/www/html/vendor/mrclay/props-dic/src/Props/Container.php on line 105

Could you fix it or can I send you a pull request to fix this?

Be-Mann commented 1 year ago

+1

glensc commented 1 year ago
  1. why are you addressing one developer specifically? what change are you referring to? do point to it!
  2. your bug report lacks any reproducer, or information about your environment! or even version you were using.
habibimh commented 1 year ago
  1. Sorry I just knew there are more developers on this branch.
  2. I use the latest version of "mrclay/minify" 3.0.13 and PHP 8.1.17

This error is obvious from the description, type of $id in the ContainerInterface not defined. If you don't mind I will send a pull request for fix it.

habibimh commented 1 year ago

I need permission to create a PR, ERROR: Permission to mrclay/Props.git denied to habibimh, if somebody give me the permission I will send the PR.

glensc commented 1 year ago

this is not how this work. you create pr from your own fork, not push directly to upstream repo.

also, still unclear what are your other dependencies. create gist reproducer. last i checked you should be able to use proper psr package depending on your environment.

bwaters commented 1 year ago

Submitted fix in https://github.com/mrclay/Props/pull/13

glensc commented 1 year ago

Still, no reproducer or environment info, as I see you have to install compatible dependency:

habibimh commented 1 year ago

I made a pr for it: https://github.com/mrclay/Props/pull/14, for strict type in function we should use PHP > 7, so I change the php version to 7.

ethaniel commented 1 year ago

I experience this on PHP 7.3: My composer.json is:

{
    "config":
    {
        "platform":
        {
            "php": "7.3"

        }

    },
    "require": {
        "mrclay/minify": "^3.0",
        "stripe/stripe-php": "^10.16",
        "aws/aws-sdk-php": "^3.275"
    }
}

Somehow props contains:

    public function has($name)

But psr/container ContainerInterface contains:

    public function has(string $id): bool;
ethaniel commented 1 year ago

It turns out that props-dic 3.0.0 requires psr/container ^1.0. But props-dic 3.0.1 requires psr/container ^1.0|^2.0, and turns out that it's incompatible with the 2.0 version.

You need to update the packagist.

ethaniel commented 1 year ago

Here is my updated composer.json, which locks mrclay/props-dic to 3.0.0:

{
    "config":
    {
        "platform":
        {
            "php": "7.4"

        }

    },
    "require": {
        "mrclay/minify": "^3.0",
        "mrclay/props-dic": "3.0.0",
        "stripe/stripe-php": "^10.16",
        "aws/aws-sdk-php": "^3.275"
    }
}
Be-Mann commented 1 year ago

Please make it finally PHP8.1 and psr/container 2.0 compatible