Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Psr16Cache not compatible with psr/simple-cache 3.0 in older Symfony versions #44738

Copy link
Copy link
Closed
@colinodell

Description

@colinodell
Issue body actions

Symfony version(s) affected

<6.0.0

Description

On older, supported versions of Symfony (4.4, 5.3, and 5.4) the Psr16Cache class is not compatible with psr/simple-cache:3.0.0. Trying to use those versions together results in this error:

PHP Fatal error: Declaration of Symfony\Component\Cache\Psr16Cache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed

Users must either upgrade to Symfony 6.0 or downgrade psr/simple-cache to 1.x or 2.x.

Composer does not currently prevent users from installing these conflicting versions. This causes application errors for users who aren't fixing transitive dependencies like psr/simple-cache to a specific version and use tools like composer update or Dependabot to upgrade those transitive dependencies.

How to reproduce

Create a composer.json file like this:

{
    "require": {
        "psr/simple-cache": "^3.0",
        "symfony/cache": "5.4.*"
    }
}

And then try running this simple PHP script:

<?php

use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Psr16Cache;

require_once 'vendor/autoload.php';

$cache = new Psr16Cache(new ArrayAdapter());

The issue also occurs with symfony/cache constraints of 5.3.* and 4.4.*.

Possible Solution

I see two possible solutions:

  1. Add psr/simple-cache as a non-dev dependency containing the supported version ranges; or
  2. Add psr/simple-cache to the conflict section for versions >=3.0.0

Either approach would ensure that users aren't able to install incompatible versions.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.