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] Implemented policies for treating unknown/missing options#10616

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

Closed
webmozart wants to merge5 commits intosymfony:masterfromwebmozart:issue9754

Conversation

@webmozart
Copy link
Contributor

QA
Bug fix?no
New feature?yes
BC breaks?yes
Deprecations?no
Tests pass?yes
Fixed tickets#7979, replaces#9754
LicenseMIT
Doc PRsymfony/symfony-docs#3731

replacement for#10574 which was closed by accident

iamlucand others added4 commitsMarch 28, 2014 18:51
@iamluc
Copy link
Contributor

Should be "BC breaks" because the OptionResolverInterface has changed, no ?

@webmozart
Copy link
ContributorAuthor

@iamluc You're right, thanks! Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is really needed (just as there is no IGNORE_INVALID) because people can just make all options optional. Btw, setRequired() followed by setOptional() does not seem to override an option to become optional.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

You can't really compare these two things. The code that callsresolve() is not necessarily the code that configures the resolver. That was the reason why these flags were needed in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I know. I'm just saying an alternative approach could be something like the following where getKnownOptions just returns all available options, which is not there currently.

$resolver->setOptional($resolver->getKnownOptions());$resolver->resolve(...)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@Tobion Do you think it would be better to add the variousget*Options() (known, required, optional, ..) methods and push this functionality into userland code? The PR currently adds overhead to every code that uses theresolve() method, regardless of whether they need the flags or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure. I think since the resolver defines the semantics like required/optional, it makes sense to also do the validation there. How much influence has the overhead? Or do you mean to also remove the validation that was already present?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

No, I'm just talking about this PR. We need to measure the influence with a moderately big form. Do you have time for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

No I don't.

@fabpot
Copy link
Member

@webmozart Can you squash your commits?

@wouterj
Copy link
Member

ping@webmozart

@stof
Copy link
Member

@wouterj given we reached the feature freeze 1 month and a half ago, it is too late for 2.5 anyway

@wouterj
Copy link
Member

Hmm, yeah indeed :) Maybe it's better to focus on stabilization now

@fabpot
Copy link
Member

@webmozart Can you finish this one?

@sstok
Copy link
Contributor

@webmozart ping

@webmozart
Copy link
ContributorAuthor

Replaced by#12156.

webmozart added a commit that referenced this pull requestOct 22, 2014
…r (webmozart)This PR was merged into the 2.6-dev branch.Discussion----------[OptionsResolver] Merged Options class into OptionsResolver| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | yes| Deprecations? | yes| Tests pass?   | yes| Fixed tickets |#4500,#9174,#10585,#10202,#11020, makes#7979+#10616 obsolete| License       | MIT| Doc PR        |symfony/symfony-docs#4159#11716 was reverted as preparation of this PR (453882c).The Options class was merged into OptionsResolver. This made it possible to fix several tickets, as indicated above.**Usage**See [the updated documentation](https://github.com/webmozart/symfony-docs/blob/issue11705/components/options_resolver.rst).**Bug Fixes**Previously, the options weren't validated before the normalizers were called. As a result, the normalizers had to perform validation again:```php$resolver->setAllowedTypes(array(    'choices' => 'array',));$resolver->setNormalizers(array(    'choices' => function (Options $options, $value) {         array_merge($options['choices'], ...);    },));// fatal error$resolver->resolve(array('choices' => 'foobar'));```This is fixed now.**BC Breaks**The `array` type hint was removed from `setRequired()`, `setAllowedValues()`, `addAllowedValues()`, `setAllowedTypes()` and `addAllowedTypes()`. If anybody implemented `OptionsResolverInterface`, they must adapt their code.The Options class was turned into an interface extending ArrayAccess and Countable. Anybody instantiating Options directly should instantiate OptionsResolver instead. Anybody using any of the methods available in Options (`get()`, `has()`) should use the ArrayAccess interface instead.Normalizers are not called anymore for undefined options (#9174). People need to set a default value if they want a normalizer to be executed independent of the options passed to `resolve()`.**Deprecations**OptionsResolverInterface was deprecated and will be removed in 3.0. OptionsResolver instances are not supposed to be shared between classes, hence an interface does not make sense.Several other methods were deprecated. See the CHANGELOG and UPGRADE-2.6 files for information.**Todo**- [x] Fix PHPDoc- [x] Adapt CHANGELOG/UPGRADE- [x] Adapt documentation- [x] Deprecate OptionsResolver[Interface]Commits-------642c119 [OptionsResolver] Merged Options class into OptionsResolver
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@webmozart@iamluc@fabpot@wouterj@stof@sstok@Tobion

[8]ページ先頭

©2009-2025 Movatter.jp