Skip to content

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Sep 26, 2025

Q A
Branch? 7.4
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

Continuing my journey on the config component, after #51273

That could be considered as a bugfix, but it's not worth fixing on lower branches because nobody is using this missing capability - by definition.

So: this allows doing eg ->lock(false) to disable locks, as expected when the node definition has ->treatFalseLike(['enabled' => false])

Note that I didn't turn ->treatNullLike(['enabled' => true]) into accepting null as I don't see the point of allowing ->lock(null) when one can use ->lock(true).

$allowedTypes = $this->allowedTypes ?? $this->normalization->declaredTypes;
foreach ([$this->trueEquivalent, $this->falseEquivalent] as $equivalent) {
if (\is_array($equivalent) && $equivalent) {
$allowedTypes[] = ExprBuilder::TYPE_BOOL;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the fix
the rest is code simplifications

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

->beforeNormalization()
->ifArray()
->then(static function ($v) {
$v += ['enabled' => true];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can rely on canBeEnabled/Disabled to set this default, but acceptAndWrap should then be moved earlier to have a proper ordering of beforeNormalization calls (adding [enabled => true] to wrapped strings)

$allowedTypes = $this->allowedTypes ?? $this->normalization->declaredTypes;
foreach ([$this->trueEquivalent, $this->falseEquivalent] as $equivalent) {
if (\is_array($equivalent) && $equivalent) {
$allowedTypes[] = ExprBuilder::TYPE_BOOL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add new tests to validate this new behavior?

@nicolas-grekas
Copy link
Member Author

no need for new tests, the existing updated one covers this

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the generated code has changed and this change is tested. Thank you for clarifying.

@fabpot
Copy link
Member

fabpot commented Sep 29, 2025

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 37029cc into symfony:7.4 Sep 29, 2025
10 of 12 checks passed
@nicolas-grekas nicolas-grekas deleted the config-pump branch September 29, 2025 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants