Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[OptionsResolver] Allow deprecations to be overridden with an empty s…#62345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@yoeunes
Copy link
Contributor

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

This PR fixes a bug that prevented a previously set deprecation from being cancelled. IfsetDeprecated() was called with an empty string, it would returnvoid without removing the existing deprecation entry.

This made it impossible for child classes or subsequent configurations to override and disable a deprecation set by a parent configuration.

The fix ensures that callingsetDeprecated('...', '') activelyunset()s the deprecation from the internal array, restoring the expected override behavior.

Example:

Given a base configuration (e.g., a parent class) that deprecates thehostname option, based on the documentation's example:

// In parent class:$resolver    ->setDefined(['hostname','host'])    ->setDeprecated('hostname','acme/package','1.2','The option "%name%" is deprecated, use "host" instead.'    );

A child configuration attempts toannul this deprecation:

// In child class:$resolver    ->setDeprecated('hostname','acme/package','1.3','');

Before (The Bug):
TheisDeprecated('hostname') method still returnedtrue, and resolving['hostname' => '...'] would incorrectly trigger anE_USER_DEPRECATED error.

After (The Fix):
The deprecation is correctly removed.isDeprecated('hostname') now returnsfalse, and no deprecation error is triggered when resolving the option.

@yceruto
Copy link
Member

I'm not sold by this change. Could you elaborate a bit more on when this would be useful?

@yceruto
Copy link
Member

It looks to me like a new feature intended to remove a deprecation notice.

@yoeunes
Copy link
ContributorAuthor

Hi@yceruto, thanks for the feedback. You are absolutely right, thischanges an existing behaviour. My apologies for misclassifying it.

The use case I had in mind is to allow child classes to override a deprecation set by a parent class. Without this change, it's impossible for a child class to cancel a deprecation.

Imagine a baseFormType in a third-party bundle deprecates an option like 'hostname' in favor of 'host':

// In MyBundle/Form/BaseType.phppublicfunctionconfigureOptions(OptionsResolver$resolver){$resolver       ->setDefined(['hostname','host'])       ->setDeprecated('hostname','my/bundle','1.0','The option "%name%" is deprecated, use "host" instead.'       );}

Now, in a child class extending it, you might want to re-enable 'hostname' without deprecation (maybe for backward compatibility in a specific context):

// In src/Form/AppType.phppublicfunctionconfigureOptions(OptionsResolver$resolver){parent::configureOptions($resolver);// This call is the new behavior$resolver->setDeprecated('hostname','my/bundle','1.1','');// Should disable the prior deprecation}

Do you think this capability is a valuable addition? If so, I am happy toclose this PR and re-open it against the8.0 branch. Or, if you think this behavior is not desirable, I will close this PR entirely.

Please let me know what you think.

@yceruto
Copy link
Member

Hi, thanks for clarifying the use case. I don't think that change is needed though, you can already redefine the same option even if it's marked as deprecated. The resolver will apply your new definition, and you can simply ignore the deprecation triggered by the parent class. Once the deprecated option is eventually removed upstream, your redefinition will seamlessly take over without issues.

@yceruto
Copy link
Member

I'm still considering whether this is a valid use case, and why you can't use thehost option instead, since the deprecated option is handled entirely upstream.

@yceruto
Copy link
Member

Another alternative is to remove the option before redefining it, clearing any parent definition.

$resolver->remove('hostname');$resolver->define('hostname');

I just checked the remove method, and it seems we missed unsetting the deprecated option, if any. PR welcome!

@nicolas-grekas
Copy link
Member

I'm like Yonel. There need to be a real world use case and I'm not sure there's one at the moment. We might actually consider that an empty deprecation message should throw. If we did so, would any use case be impossible? I don't see when.

@yoeunes
Copy link
ContributorAuthor

Hi@yceruto and@nicolas-grekas, thank you both for your feedback. You are right, my original use case was flawed. Using$resolver->remove('hostname') first is a much cleaner and more explicit way to override a parent's definition.

@nicolas-grekas To answer your question: I agree. After this discussion, and assumingremove() works correctly (which the new PR fixes), I don't see a real-world use case that becomes impossible.

I have just created the new PR to fixremove() as@yceruto suggested. You can find it here#62347

As this PR is not the correct approach, I am closing it.

yceruto reacted with thumbs up emoji

@yoeunesyoeunes closed thisNov 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ycerutoycerutoAwaiting requested review from ycerutoyceruto is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

4 participants

@yoeunes@yceruto@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp