PHP 8.5 deprecation in html_cva() when a recipe value is null
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from twigphp/Twig
-
The timezone argument is missing when instantiating from strings other than "now".Possibly taken @Amoifr claimed this 201 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
twigphp/Twig#4746 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 18/100
twigphp/Twig#4996 · 4 comments ·
Maintainers usually reply within 1 day
-
Add `block_data()` and `block_export()` functionsPossibly taken @seb-jean claimed this 49 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
twigphp/Twig#4868 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
twigphp/Twig#4788 · 5 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Add TuneIn-DirMon in the bot listPossibly taken @liviuconcioiu claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
matomo-org/device-detector#8424 ·
Maintainers usually reply within 1 day
-
affecting 5.2 only affecting 5.3 only bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
moodle-an-hochschulen/moodle-theme_boost_union#1463 ·
Maintainers usually reply within 1 day
-
Course help wanted Sensei
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
woocommerce/woocommerce-paypal-payments#4838 ·
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 2 days