enqueue-dev icon indicating copy to clipboard operation
enqueue-dev copied to clipboard

[BUG] Declaration of Enqueue\Container\Container::has

Open FuriosoJack opened this issue 3 years ago • 3 comments

Is the error with run command

PHP Fatal error: Declaration of Enqueue\Container\Container::has($id) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool in /var/www/html/wp-content/plugins/visualinmueble/vendor/enqueue/enqueue/Container/Container.php on line 28

FuriosoJack avatar Jan 06 '22 00:01 FuriosoJack

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 08:04 stale[bot]

I am experience this error too

jeffersoncardoso avatar Apr 19 '22 22:04 jeffersoncardoso

I just checked and every version of "psr/container" except "1.0.0" has parameter typehints and since "2.0.0" it also has return type hints.

So to solve the issue one of the following 4 options could be done:

  1. update composer.json to explicitly require "psr/container": "1.0.0" and no further changes are needed
  2. update composer.json to require "psr/container": "^1.1.0" and change Enqueue\Container\Container to include the parameter typehints and optionally return typehints
  3. update composer.json to require "psr/container": "^2.0.0" and change Enqueue\Container\Container to include the parameter and return typehints
  4. keep composer.json as is and change Enqueue\Container\Container to include the parameter and return typehints

Option 4 should be possible (and should also be preferred because it offers the best compatibility with other libraries/code bases) since (as far as I know) parameter typehints are required to follow the initial definition but if the original doesn't define a return typehint (as in the 1.* versions of psr/container) then adding it shouldn't cause exceptions in all of the current php versions.

chancezeus avatar Apr 26 '22 07:04 chancezeus