Problem/Motivation

Looks like a lot of dependency hell around these days...

Steps to reproduce

With Drupal 10.0.0, core requires twig/twig:^3.

drush en cl_components

PHP Fatal error: Declaration of Drupal\cl_components\Twig\TwigComponentLoader::isFresh($name, $time) must be compatible with Twig\Loader\LoaderInterface::isFresh(string $name, int $time): bool in cl_components/src/Twig/TwigComponentLoader.php on line 158

Proposed resolution

Let's think, covariance, contravariance, i suppose if we don't want to start a new major version, and don't want to break D9 installs that iirc use untyped twig/twig:^2, we must typehint parameters, but not return value. Nope, it's the other way round.

Remaining tasks

Code, MR, review, commit.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

geek-merlin created an issue. See original summary.

geek-merlin’s picture

Issue summary: View changes
geek-merlin’s picture

Version: 1.0.0-rc5 » 1.x-dev
Assigned: Unassigned » geek-merlin

geek-merlin’s picture

Assigned: geek-merlin » Unassigned
Status: Active » Needs review

Applied the MR with composer-patches, enabled, fixes the issue for me.

b_sharpe made their first commit to this issue’s fork.

b_sharpe’s picture

Rebased and removed unneeded space.

e0ipso’s picture

I have yet to port the tests in SDC to CL Components. Can anyone tests that this patch also works well with Drupal 9 and Twig 2?

arisen’s picture

Status: Needs review » Reviewed & tested by the community

Applied the patch from the MR on Drupal 10.0.0.

It applies cleanly:

Checking patch src/Twig/TwigComponentLoader.php...
Applied patch src/Twig/TwigComponentLoader.php cleanly.

The drush installation error is resolved after applying the patch.

Regarding Drupal 9:
The module installation works fine without the patch(tried on Drupal 9.5.4).
The function signature is matching as declared in the LoaderInterface.
public function isFresh($name, $time);
The module installation works fine on Drupal 9 even after applying the patch.

Moving this to RTBC.

e0ipso’s picture

Status: Reviewed & tested by the community » Fixed

This was merged. Thanks for the contribution.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.