twigphp / twigphp/Twig

Suggestion for Twig 4: Change the `|default()` filter to respect `false`

Open
#4,716 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

{{ false|default(true) }} gives true, since default() obviously treats false just like null or undefined.
It's documented at https://twig.symfony.com/doc/3.x/filters/default.html, but still weird ;-)

I just wanted to add this to the wishlist for Twig 4, but the thread at https://github.com/twigphp/Twig/issues/3951 is already closed.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

No implementation file or test is named. Start by reading the documented default() filter behavior and the closed issue #3951; clarify the intended Twig 4 semantics and acceptance criteria there before determining the affected code and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.