Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[OptionsResolver] support array of instance validaion #15671

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 649 commits into from

Conversation

EVODelavega
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #15524
License MIT
Doc PR

A suggested approach to add support for typed-arrays as allowed types, using a simple recursive method

$type = isset(self::$typeAliases[$type]) ? self::$typeAliases[$type] : $type;

if (substr($type, -2) === '[]') {
if (is_array($value)) {
Copy link

Choose a reason for hiding this comment

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

It is very hard to read what happens when if (!is_array()).

I would omit the single return and add a if (!is_array()) {return false;}

@stof
Copy link
Member

stof commented Sep 2, 2015

I would like to see a profiling of the impact of this feature. Blackfire makes it easy by allowing to share a comparison graph of before vs after the change (and it is free).

@webmozart do you have a test project for forms somewhere ? You used such projects in the past when working on the component.

@OskarStark
Copy link
Contributor

this PR looks interesting 👍

@EVODelavega
Copy link
Contributor Author

Updated PR: exception message for complex types now format the complex value's type better (cf test case where allowed type is int[], but actual value's type is DateTime[]).

Oh, and @stof: I'll try to do some profiling if I can find the time. Do I compare the performance to 2.7 or current 2.8?

return is_object($value) ? get_class($value) : gettype($value);
}

/**
* Returns a string represnetation of the complex type of the value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo here ;) (Hi Elias!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo fixed, (reading through commits in your own time, or not enough work back at NG? ;-P)

Copy link
Contributor

Choose a reason for hiding this comment

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

Saw your name come by last week, kept an eye out. ;) Hope you are well!

@EVODelavega EVODelavega changed the title Suggested fix for issue #15524 [OptionsResolver] Suggested fix for issue #15524 Sep 9, 2015
@Tobion Tobion changed the title [OptionsResolver] Suggested fix for issue #15524 [OptionsResolver] support array of instance validaion Sep 9, 2015
fabpot and others added 18 commits September 28, 2015 13:17
This PR was merged into the 3.0-dev branch.

Discussion
----------

[Finder] removed obsolete code

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

be729e3 [Finder] removed obsolete code
This PR was merged into the 3.0-dev branch.

Discussion
----------

use try-finally when possible

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | I hope
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Found those with regex `catch \(\\Exception[^\}]+throw \$`

Commits
-------

49edef2 use try-finally when possible
…urce() which was deprecated in 2.8 (mpdude)

This PR was squashed before being merged into the 3.0-dev branch (closes symfony#15929).

Discussion
----------

[3.0][Config] Remove ResourceInterface::getResource() which was deprecated in 2.8

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Deprecated in symfony#15719.

Commits
-------

7cef180 [3.0][Config] Remove ResourceInterface::getResource() which was deprecated in 2.8
Conflicts:
	composer.json
	src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
	src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
	src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
	src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
	src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
	src/Symfony/Component/ClassLoader/DebugClassLoader.php
	src/Symfony/Component/ClassLoader/UniversalClassLoader.php
	src/Symfony/Component/Console/Input/StringInput.php
	src/Symfony/Component/Debug/DebugClassLoader.php
	src/Symfony/Component/DependencyInjection/Container.php
	src/Symfony/Component/DependencyInjection/ContainerBuilder.php
	src/Symfony/Component/DependencyInjection/ContainerInterface.php
	src/Symfony/Component/DependencyInjection/Definition.php
	src/Symfony/Component/DependencyInjection/DefinitionDecorator.php
	src/Symfony/Component/DependencyInjection/Scope.php
	src/Symfony/Component/DependencyInjection/ScopeInterface.php
	src/Symfony/Component/DomCrawler/composer.json
	src/Symfony/Component/EventDispatcher/Event.php
	src/Symfony/Component/HttpKernel/Kernel.php
	src/Symfony/Component/HttpKernel/KernelInterface.php
	src/Symfony/Component/HttpKernel/Log/LoggerInterface.php
	src/Symfony/Component/HttpKernel/Log/NullLogger.php
	src/Symfony/Component/Security/Core/composer.json
	src/Symfony/Component/Security/Resources/translations/security.tr.xlf
	src/Symfony/Component/Security/composer.json
	src/Symfony/Component/Translation/Translator.php
…(xabbuh)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[Ldap] update branch alias for the master branch

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

b4092a7 [Ldap] update branch alias for the master branch
* 2.8:
  Remove profiler storages
  deprecate finding deep items in request parameters
  [CssSelector] updated README
  [CssSelector] remove ConverterInterface
  [DependencyInjection] improved a comment for reading fluency
  [HttpKernel] change a class in tests to avoid depending on SQLite
  [FrameworkBundle] Fix tests
  [Bridge\Twig] Fix form lowest version
  [ci] Display fastest results first when running tests in parallel
  [Yaml] Improve newline handling in folded scalar blocks
* 2.8:
  fixed deprecation notices
  fixed typos
  [FrameworkBundle] Tag deprecated services
  [VarDumper] Dump PHP+Twig code excerpts in backtraces
  [Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors
* 2.8:
  add dependency required by a replaced package
  Add a way to group toolbar info pieces
  Added general sf-toolbar-block-right class
  Bind input before executing the COMMAND event
…terJ)

This PR was merged into the 3.0-dev branch.

Discussion
----------

[3.0][Security] Remove deprecated features

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c3c5989 Remove more tests
6f9e897 Remove AbstractVoter#isGranted() method
6b6de15 Removed supports{Attribute,Class}() methods
stof and others added 18 commits December 5, 2015 12:13
* 2.8:
  Set the redraw frequency at least to 1. Setting it to 0 would otherwise produce an error.
  [Process] Unset callback after stop to free memory
  Improve error message for undefined DIC aliases
  [VarDumper] fixed .sf-dump z-index
  [Validator] Updated Luxembourgish translations for 2.8
  Disallow http-kernel 3.x, fixes symfony#16837.
  [DependencyInjection] Validate class names and factory methods
  ampq → amqp
  Fix typo
  Refactoring EntityUserProvider::__construct() to not do work, cause cache warm error
  [Form] Add context to FormFactory deprecations
  CS: remove unneeded parentheses around control statements
  [TwigBridge] Clean deps now that 2.8.0 is tagged
* 3.0:
  Set the redraw frequency at least to 1. Setting it to 0 would otherwise produce an error.
  [Form] document changes to form type interfaces
  [Process] Unset callback after stop to free memory
  Improve error message for undefined DIC aliases
  [VarDumper] fixed .sf-dump z-index
  [Validator] Updated Luxembourgish translations for 2.8
  Disallow http-kernel 3.x, fixes symfony#16837.
  [Config] Throw an exception when using cannotBeEmpty() on numeric or boolean nodes
  [DependencyInjection] Validate class names and factory methods
  ampq → amqp
  Fix typo
  Refactoring EntityUserProvider::__construct() to not do work, cause cache warm error
  [Form] Add context to FormFactory deprecations
  Reapply the Yaml bugfix of symfony#16745
  CS: remove unneeded parentheses around control statements
  [DomCrawler] add upgrade hint on interface changes
  [TwigBridge] Clean deps now that 2.8.0 is tagged
* 2.8:
  [Process] Fix stopping a process on Windows
  [PhpUnitBridge] Add weak-verbose mode and match against message instead of test name
  Added a note about the new requirement iconv.
  Improved error messages for Yaml Deprecations
  Added a test case for the Logger class.
  [Form] Fix choices defined as Traversable
  CS: general fixes
  Suggested Process dependency
* 3.0:
  [Process] Fix stopping a process on Windows
  [PhpUnitBridge] Add weak-verbose mode and match against message instead of test name
  Added a note about the new requirement iconv.
  Improved error messages for Yaml Deprecations
  Added a test case for the Logger class.
  [Form] Fix choices defined as Traversable
  CS: general fixes
  Suggested Process dependency
* 2.8:
  Fix the exception message expectation
* 3.0:
  Fix the exception message expectation
* 2.8:
  Fix DeprecationErrorHandler on PHP 5.3
* 2.8:
  [Process] Enhance compatiblity with --enable-sigchild
  [Validator] removes unused variable in LengthValidator class.
  [FrameworkBundle] [Bug] Fixes new InputStyle bug symfony#16920
  fix short array syntax for php 5.3
  [Serializer] Fixed  on array of objects in .
  [Process] Always call proc_close
  [Form] Add missing tests for StringUtil::fqcnToBlockPrefix()
  [Security] Fix a Polyfill import statement in StringUtils
  [Validator] Updated Luxembourgish translations for 2.8
  Improved the code of the commands that use the new SymfonyStyle class
  disable server commands without Process component
  list all server command names in suggestion
  Suggested Process dependency
  disable server:run cmd without Process component
  Suggested Process dependency
  [FrameworkBundle] prevent cache:clear creating too long paths
  [FrameworkBundle] [Translation] Fixed translations not written when no translations directory in update command

Conflicts:
	.travis.yml
	src/Symfony/Bridge/Twig/Command/LintCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
	src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
	src/Symfony/Bundle/TwigBundle/Command/DebugCommand.php
	src/Symfony/Component/Security/Core/Util/StringUtils.php
* 3.0:
  [Process] Enhance compatiblity with --enable-sigchild
  [Validator] removes unused variable in LengthValidator class.
  [FrameworkBundle] [Bug] Fixes new InputStyle bug symfony#16920
  fix short array syntax for php 5.3
  [Serializer] Fixed  on array of objects in .
  [Process] Always call proc_close
  [Form] Add missing tests for StringUtil::fqcnToBlockPrefix()
  [Security] Fix a Polyfill import statement in StringUtils
  [Validator] Updated Luxembourgish translations for 2.8
  Improved the code of the commands that use the new SymfonyStyle class
  disable server commands without Process component
  list all server command names in suggestion
  Suggested Process dependency
  disable server:run cmd without Process component
  Suggested Process dependency
  Fix DeprecationErrorHandler on PHP 5.3
  [FrameworkBundle] prevent cache:clear creating too long paths
  [FrameworkBundle] [Translation] Fixed translations not written when no translations directory in update command
in symfony 3.0 there is no ajax collector declared. Because of that debug toolbar do not display ajac calls
This PR was merged into the 3.0 branch.

Discussion
----------

return ajax collector to collectors.php

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets | symfony#16880
| License       | MIT
| Doc PR        |

in symfony 3.0 there is no ajax collector declared. Because of that debug toolbar do not display ajax calls

Commits
-------

8a2c757 return ajax collector to collectors.php
…king (voronkovich)

This PR was merged into the 3.0 branch.

Discussion
----------

[HttpKernel] HttpCache: remove an ESI instance checking

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | no
| License       | MIT
| Doc PR        | no

This checking was added by this commit symfony@32d964b, but now it's not needed

Commits
-------

7528134 Removed ESI instance check
…riggerDeprecation flag (ogizanagi)

This PR was merged into the 3.0 branch.

Discussion
----------

[FrameworkBundle][HttpKernel] Remove remaining $triggerDeprecation flag

| Q             | A
| ------------- | ---
| Fixed tickets | n/a
| License       | MIT

Introduced in symfony#14665, this flag controlled the deprecation notice triggering when using the `ContainerAwareHttpKernel`, in order to avoid triggering it when using this class in the Symfony framework. This class no longer exists now, neither the flag.

Commits
-------

ac15454 [FrameworkBundle][HttpKernel] Remove remaining $triggerDeprecation flag
@EVODelavega
Copy link
Contributor Author

Status: Reviewed

I'm marking this PR as reviewed, seeing as there haven't been any comments in some time

@soullivaneuh
Copy link
Contributor

Travis is failing.

BTW, 2.8 and 3.0 are out now. I think this PR should target 3.1 now.

@EVODelavega
Copy link
Contributor Author

Created a new PR merging changes into 3.1 instead of 2.8

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.