Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

PHP 8.5 deprecation in html_cva() when a recipe value is null

Closed Beginner friendly
#5,013 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start by finding Cva::apply() and the test for html_cva() recipe values; inspect the variant lookup identified in the issue. Run the new test on PHP 8.5, where it should fail without the fix. Done means a null recipe value no longer triggers the deprecation, while matching no variant and leaving defaultVariants behavior unchanged.

Written by the indexing model from the issue text.

Description

When a recipe value passed to Cva::apply() (and so to html_cva()) is null, PHP 8.5 reports a deprecation:

Using null as an array offset is deprecated, use an empty string instead

This happens in the line that looks up the classes for a variant: $this->variants[$recipeName][$recipeValue].

Component templates often pass a prop straight through, and a prop that isn't set is null. Drupal core requires twig/html-extra, and Drupal themes such as Mercury use html_cva() in most of their component templates, so on PHP 8.5 this deprecation shows up on almost every page render.

The fix uses '' when the value is null. That's the key PHP already used for null, so the result doesn't change: a null value matches no variant, and defaultVariants still apply because isset() treats null as unset.

The new test fails on PHP 8.5 without the fix.

Found with Claude while working on porting Drupal CMS to Drupal 12 (requires PHP 8.5).

Dominant language
PHP
Stars
8.4k
Forks
1.3k
Avg merge
1d 9h
Merged PRs (30d)
40

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from twigphp/Twig

All issues in twigphp/Twig

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.