Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+4 -18
View File
@@ -23,24 +23,10 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
*/
const CACHE_KEY_VAR = 'cache_key';
/**
* @var array
*/
protected $defaultThemes;
/**
* @var array
*/
protected $themes = array();
/**
* @var array
*/
protected $resources = array();
/**
* @var array
*/
private $resourceHierarchyLevels = array();
/**
@@ -140,13 +126,13 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface
* @see getResourceForBlockHierarchy()
*
* @param string $cacheKey The cache key used for storing the
* resource.
* resource
* @param FormView $view The form view for finding the applying
* themes.
* themes
* @param array $blockNameHierarchy The block hierarchy, with the most
* specific block name at the end.
* specific block name at the end
* @param int $hierarchyLevel The level in the block hierarchy that
* should be loaded.
* should be loaded
*
* @return bool True if the resource could be loaded, false otherwise
*/
+5 -3
View File
@@ -106,6 +106,10 @@ class Button implements \IteratorAggregate, FormInterface
*/
public function setParent(FormInterface $parent = null)
{
if ($this->submitted) {
throw new AlreadySubmittedException('You cannot set the parent of a submitted button');
}
$this->parent = $parent;
}
@@ -273,8 +277,6 @@ class Button implements \IteratorAggregate, FormInterface
/**
* Unsupported method.
*
* @param FormError $error
*
* @throws BadMethodCallException
*/
public function addError(FormError $error)
@@ -371,7 +373,7 @@ class Button implements \IteratorAggregate, FormInterface
*
* @return $this
*
* @throws Exception\AlreadySubmittedException If the button has already been submitted.
* @throws Exception\AlreadySubmittedException if the button has already been submitted
*/
public function submit($submittedData, $clearMissing = true)
{
+1 -11
View File
@@ -58,7 +58,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
* @param string $name The name of the button
* @param array $options The button's options
*
* @throws InvalidArgumentException If the name is empty.
* @throws InvalidArgumentException if the name is empty
*/
public function __construct($name, array $options = array())
{
@@ -184,8 +184,6 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
*
* This method should not be invoked.
*
* @param EventSubscriberInterface $subscriber
*
* @throws BadMethodCallException
*/
public function addEventSubscriber(EventSubscriberInterface $subscriber)
@@ -272,8 +270,6 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
*
* This method should not be invoked.
*
* @param DataMapperInterface $dataMapper
*
* @throws BadMethodCallException
*/
public function setDataMapper(DataMapperInterface $dataMapper = null)
@@ -396,8 +392,6 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Sets the type of the button.
*
* @param ResolvedFormTypeInterface $type The type of the button
*
* @return $this
*/
public function setType(ResolvedFormTypeInterface $type)
@@ -440,8 +434,6 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
*
* This method should not be invoked.
*
* @param FormFactoryInterface $formFactory
*
* @throws BadMethodCallException
*/
public function setFormFactory(FormFactoryInterface $formFactory)
@@ -476,8 +468,6 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @param RequestHandlerInterface $requestHandler
*
* @throws BadMethodCallException
*/
public function setRequestHandler(RequestHandlerInterface $requestHandler)
+5
View File
@@ -48,6 +48,11 @@ CHANGELOG
* moved data trimming logic of TrimListener into StringUtil
* [BC BREAK] When registering a type extension through the DI extension, the tag alias has to match the actual extended type.
2.7.38
------
* [BC BREAK] the `isFileUpload()` method was added to the `RequestHandlerInterface`
2.7.0
-----
-13
View File
@@ -16,23 +16,10 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
class CallbackTransformer implements DataTransformerInterface
{
/**
* The callback used for forward transform.
*
* @var callable
*/
private $transform;
/**
* The callback used for reverse transform.
*
* @var callable
*/
private $reverseTransform;
/**
* Constructor.
*
* @param callable $transform The forward transform callback
* @param callable $reverseTransform The reverse transform callback
*/
+7 -7
View File
@@ -56,11 +56,11 @@ class ArrayChoiceList implements ChoiceListInterface
*
* The given choice array must have the same array keys as the value array.
*
* @param array|\Traversable $choices The selectable choices
* @param callable|null $value The callable for creating the value
* for a choice. If `null` is passed,
* incrementing integers are used as
* values
* @param iterable $choices The selectable choices
* @param callable|null $value The callable for creating the value
* for a choice. If `null` is passed,
* incrementing integers are used as
* values
*/
public function __construct($choices, callable $value = null)
{
@@ -216,8 +216,8 @@ class ArrayChoiceList implements ChoiceListInterface
* @param array $choices The choices
* @param array|null $cache The cache for previously checked entries. Internal
*
* @return bool Returns true if the choices can be cast to strings and
* false otherwise.
* @return bool returns true if the choices can be cast to strings and
* false otherwise
*/
private function castableToString(array $choices, array &$cache = array())
{
@@ -22,9 +22,6 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
*/
class CachingFactoryDecorator implements ChoiceListFactoryInterface
{
/**
* @var ChoiceListFactoryInterface
*/
private $decoratedFactory;
/**
@@ -48,7 +45,7 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface
*
* @return string The SHA-256 hash
*
* @internal Should not be used by user-land code.
* @internal should not be used by user-land code
*/
public static function generateHash($value, $namespace = '')
{
@@ -89,11 +86,6 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface
}
}
/**
* Decorates the given factory.
*
* @param ChoiceListFactoryInterface $decoratedFactory The decorated factory
*/
public function __construct(ChoiceListFactoryInterface $decoratedFactory)
{
$this->decoratedFactory = $decoratedFactory;
@@ -31,9 +31,9 @@ interface ChoiceListFactoryInterface
* The callable receives the choice as first and the array key as the second
* argument.
*
* @param array|\Traversable $choices The choices
* @param null|callable $value The callable generating the choice
* values
* @param iterable $choices The choices
* @param null|callable $value The callable generating the choice
* values
*
* @return ChoiceListInterface The choice list
*/
@@ -41,22 +41,9 @@ use Symfony\Component\PropertyAccess\PropertyPath;
*/
class PropertyAccessDecorator implements ChoiceListFactoryInterface
{
/**
* @var ChoiceListFactoryInterface
*/
private $decoratedFactory;
/**
* @var PropertyAccessorInterface
*/
private $propertyAccessor;
/**
* Decorates the given factory.
*
* @param ChoiceListFactoryInterface $decoratedFactory The decorated factory
* @param null|PropertyAccessorInterface $propertyAccessor The used property accessor
*/
public function __construct(ChoiceListFactoryInterface $decoratedFactory, PropertyAccessorInterface $propertyAccessor = null)
{
$this->decoratedFactory = $decoratedFactory;
@@ -76,7 +63,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
/**
* {@inheritdoc}
*
* @param array|\Traversable $choices The choices
* @param iterable $choices The choices
* @param null|callable|string|PropertyPath $value The callable or path for
* generating the choice values
*
@@ -87,7 +74,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($value) && !is_callable($value)) {
$value = new PropertyPath($value);
} elseif (is_string($value) && is_callable($value)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($value instanceof PropertyPath) {
@@ -120,7 +107,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($value) && !is_callable($value)) {
$value = new PropertyPath($value);
} elseif (is_string($value) && is_callable($value)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($value instanceof PropertyPath) {
@@ -158,7 +145,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($label) && !is_callable($label)) {
$label = new PropertyPath($label);
} elseif (is_string($label) && is_callable($label)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($label instanceof PropertyPath) {
@@ -170,7 +157,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($preferredChoices) && !is_callable($preferredChoices)) {
$preferredChoices = new PropertyPath($preferredChoices);
} elseif (is_string($preferredChoices) && is_callable($preferredChoices)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($preferredChoices instanceof PropertyPath) {
@@ -187,7 +174,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($index) && !is_callable($index)) {
$index = new PropertyPath($index);
} elseif (is_string($index) && is_callable($index)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($index instanceof PropertyPath) {
@@ -199,7 +186,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($groupBy) && !is_callable($groupBy)) {
$groupBy = new PropertyPath($groupBy);
} elseif (is_string($groupBy) && is_callable($groupBy)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($groupBy instanceof PropertyPath) {
@@ -215,7 +202,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
if (is_string($attr) && !is_callable($attr)) {
$attr = new PropertyPath($attr);
} elseif (is_string($attr) && is_callable($attr)) {
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}
if ($attr instanceof PropertyPath) {
+7 -13
View File
@@ -27,11 +27,6 @@ use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
*/
class LazyChoiceList implements ChoiceListInterface
{
/**
* The choice loader.
*
* @var ChoiceLoaderInterface
*/
private $loader;
/**
@@ -65,8 +60,7 @@ class LazyChoiceList implements ChoiceListInterface
* argument.
*
* @param ChoiceLoaderInterface $loader The choice loader
* @param null|callable $value The callable generating the choice
* values
* @param null|callable $value The callable generating the choice values
*/
public function __construct(ChoiceLoaderInterface $loader, callable $value = null)
{
@@ -83,7 +77,7 @@ class LazyChoiceList implements ChoiceListInterface
// We can safely invoke the {@link ChoiceLoaderInterface} assuming it has the list
// in cache when the lazy list is already loaded
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Caching the choice list in %s is deprecated since Symfony 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
}
return $this->loadedList->getChoices();
@@ -106,7 +100,7 @@ class LazyChoiceList implements ChoiceListInterface
if ($this->loaded) {
// Check whether the loader has the same cache
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Caching the choice list in %s is deprecated since Symfony 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
}
return $this->loadedList->getValues();
@@ -129,7 +123,7 @@ class LazyChoiceList implements ChoiceListInterface
if ($this->loaded) {
// Check whether the loader has the same cache
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Caching the choice list in %s is deprecated since Symfony 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
}
return $this->loadedList->getStructuredValues();
@@ -152,7 +146,7 @@ class LazyChoiceList implements ChoiceListInterface
if ($this->loaded) {
// Check whether the loader has the same cache
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Caching the choice list in %s is deprecated since Symfony 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
}
return $this->loadedList->getOriginalKeys();
@@ -175,7 +169,7 @@ class LazyChoiceList implements ChoiceListInterface
if ($this->loaded) {
// Check whether the loader has the same cache
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Caching the choice list in %s is deprecated since Symfony 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
}
return $this->loadedList->getChoicesForValues($values);
@@ -192,7 +186,7 @@ class LazyChoiceList implements ChoiceListInterface
if ($this->loaded) {
// Check whether the loader has the same cache
if ($this->loadedList !== $this->loader->loadChoiceList($this->value)) {
@trigger_error(sprintf('Caching the choice list in %s is deprecated since 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Caching the choice list in %s is deprecated since Symfony 3.1 and will not happen in 4.0. Cache the list in the %s instead.', __CLASS__, ChoiceLoaderInterface::class), E_USER_DEPRECATED);
}
return $this->loadedList->getValuesForChoices($choices);
+1 -13
View File
@@ -18,26 +18,14 @@ namespace Symfony\Component\Form\ChoiceList\View;
*/
class ChoiceGroupView implements \IteratorAggregate
{
/**
* The label of the group.
*
* @var string
*/
public $label;
/**
* The choice views in the group.
*
* @var ChoiceGroupView[]|ChoiceView[]
*/
public $choices;
/**
* Creates a new choice group view.
*
* @param string $label The label of the group
* @param ChoiceGroupView[]|ChoiceView[] $choices The choice views in the
* group.
* @param ChoiceGroupView[]|ChoiceView[] $choices the choice views in the group
*/
public function __construct($label, array $choices = array())
{
+1 -13
View File
@@ -22,26 +22,14 @@ namespace Symfony\Component\Form\ChoiceList\View;
*/
class ChoiceListView
{
/**
* The choices.
*
* @var ChoiceGroupView[]|ChoiceView[]
*/
public $choices;
/**
* The preferred choices.
*
* @var ChoiceGroupView[]|ChoiceView[]
*/
public $preferredChoices;
/**
* Creates a new choice list view.
*
* @param ChoiceGroupView[]|ChoiceView[] $choices The choice views
* @param ChoiceGroupView[]|ChoiceView[] $preferredChoices The preferred
* choice views.
* @param ChoiceGroupView[]|ChoiceView[] $preferredChoices the preferred choice views
*/
public function __construct(array $choices = array(), array $preferredChoices = array())
{
-19
View File
@@ -18,31 +18,12 @@ namespace Symfony\Component\Form\ChoiceList\View;
*/
class ChoiceView
{
/**
* The label displayed to humans.
*
* @var string
*/
public $label;
/**
* The view representation of the choice.
*
* @var string
*/
public $value;
/**
* The original choice value.
*
* @var mixed
*/
public $data;
/**
* Additional attributes for the HTML tag.
*
* @var array
*/
public $attr;
+2 -2
View File
@@ -22,7 +22,7 @@ interface DataMapperInterface
* @param mixed $data Structured data
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported.
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
public function mapDataToForms($data, $forms);
@@ -32,7 +32,7 @@ interface DataMapperInterface
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
* @param mixed $data Structured data
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported.
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
public function mapFormsToData($forms, &$data);
}
+2 -2
View File
@@ -45,7 +45,7 @@ interface DataTransformerInterface
*
* @return mixed The value in the transformed representation
*
* @throws TransformationFailedException When the transformation fails.
* @throws TransformationFailedException when the transformation fails
*/
public function transform($value);
@@ -71,7 +71,7 @@ interface DataTransformerInterface
*
* @return mixed The value in the original representation
*
* @throws TransformationFailedException When the transformation fails.
* @throws TransformationFailedException when the transformation fails
*/
public function reverseTransform($value);
}
+2 -3
View File
@@ -16,7 +16,6 @@ use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;
@@ -53,12 +52,12 @@ class FormPass implements CompilerPassInterface
if (new IteratorArgument(array()) != $definition->getArgument(2)) {
return;
}
$definition->replaceArgument(0, $this->processFormTypes($container, $definition));
$definition->replaceArgument(0, $this->processFormTypes($container));
$definition->replaceArgument(1, $this->processFormTypeExtensions($container));
$definition->replaceArgument(2, $this->processFormTypeGuessers($container));
}
private function processFormTypes(ContainerBuilder $container, Definition $definition)
private function processFormTypes(ContainerBuilder $container)
{
// Get service locator argument
$servicesMap = array();
-7
View File
@@ -26,14 +26,7 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
*/
class CoreExtension extends AbstractExtension
{
/**
* @var PropertyAccessorInterface
*/
private $propertyAccessor;
/**
* @var ChoiceListFactoryInterface
*/
private $choiceListFactory;
public function __construct(PropertyAccessorInterface $propertyAccessor = null, ChoiceListFactoryInterface $choiceListFactory = null)
@@ -23,16 +23,8 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
*/
class PropertyPathMapper implements DataMapperInterface
{
/**
* @var PropertyAccessorInterface
*/
private $propertyAccessor;
/**
* Creates a new property path mapper.
*
* @param PropertyAccessorInterface $propertyAccessor The property accessor
*/
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
{
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
@@ -30,8 +30,6 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
protected $outputTimezone;
/**
* Constructor.
*
* @param string $inputTimezone The name of the input timezone
* @param string $outputTimezone The name of the output timezone
*
@@ -22,17 +22,10 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
*/
class BooleanToStringTransformer implements DataTransformerInterface
{
/**
* The value emitted upon transform if the input is true.
*
* @var string
*/
private $trueValue;
/**
* Sets the value emitted upon transform if the input is true.
*
* @param string $trueValue
* @param string $trueValue The value emitted upon transform if the input is true
*/
public function __construct($trueValue)
{
@@ -46,7 +39,7 @@ class BooleanToStringTransformer implements DataTransformerInterface
*
* @return string String value
*
* @throws TransformationFailedException If the given value is not a Boolean.
* @throws TransformationFailedException if the given value is not a Boolean
*/
public function transform($value)
{
@@ -68,7 +61,7 @@ class BooleanToStringTransformer implements DataTransformerInterface
*
* @return bool Boolean value
*
* @throws TransformationFailedException If the given value is not a string.
* @throws TransformationFailedException if the given value is not a string
*/
public function reverseTransform($value)
{
@@ -22,11 +22,6 @@ class ChoiceToValueTransformer implements DataTransformerInterface
{
private $choiceList;
/**
* Constructor.
*
* @param ChoiceListInterface $choiceList
*/
public function __construct(ChoiceListInterface $choiceList)
{
$this->choiceList = $choiceList;
@@ -22,22 +22,15 @@ class ChoicesToValuesTransformer implements DataTransformerInterface
{
private $choiceList;
/**
* Constructor.
*
* @param ChoiceListInterface $choiceList
*/
public function __construct(ChoiceListInterface $choiceList)
{
$this->choiceList = $choiceList;
}
/**
* @param array $array
*
* @return array
*
* @throws TransformationFailedException If the given value is not an array.
* @throws TransformationFailedException if the given value is not an array
*/
public function transform($array)
{
@@ -53,13 +46,11 @@ class ChoicesToValuesTransformer implements DataTransformerInterface
}
/**
* @param array $array
*
* @return array
*
* @throws TransformationFailedException If the given value is not an array
* @throws TransformationFailedException if the given value is not an array
* or if no matching choice could be
* found for some given value.
* found for some given value
*/
public function reverseTransform($array)
{
@@ -21,17 +21,12 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
*/
class DataTransformerChain implements DataTransformerInterface
{
/**
* The value transformers.
*
* @var DataTransformerInterface[]
*/
protected $transformers;
/**
* Uses the given value transformers to transform values.
*
* @param array $transformers
* @param DataTransformerInterface[] $transformers
*/
public function __construct(array $transformers)
{
@@ -62,7 +62,7 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
*
* @return array Interval array
*
* @throws UnexpectedTypeException If the given value is not a \DateInterval instance.
* @throws UnexpectedTypeException if the given value is not a \DateInterval instance
*/
public function transform($dateInterval)
{
@@ -108,8 +108,8 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
*
* @return \DateInterval Normalized date interval
*
* @throws UnexpectedTypeException If the given value is not an array.
* @throws TransformationFailedException If the value could not be transformed.
* @throws UnexpectedTypeException if the given value is not an array
* @throws TransformationFailedException if the value could not be transformed
*/
public function reverseTransform($value)
{
@@ -135,7 +135,7 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
throw new TransformationFailedException('The value of "invert" must be boolean');
}
foreach (self::$availableFields as $field => $char) {
if ($field !== 'invert' && isset($value[$field]) && !ctype_digit((string) $value[$field])) {
if ('invert' !== $field && isset($value[$field]) && !ctype_digit((string) $value[$field])) {
throw new TransformationFailedException(sprintf('This amount of "%s" is invalid', $field));
}
}
@@ -23,20 +23,17 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
class DateIntervalToStringTransformer implements DataTransformerInterface
{
private $format;
private $parseSigned;
/**
* Transforms a \DateInterval instance to a string.
*
* @see \DateInterval::format() for supported formats
*
* @param string $format The date format
* @param bool $parseSigned Whether to parse as a signed interval
* @param string $format The date format
*/
public function __construct($format = 'P%yY%mM%dDT%hH%iM%sS', $parseSigned = false)
public function __construct($format = 'P%yY%mM%dDT%hH%iM%sS')
{
$this->format = $format;
$this->parseSigned = $parseSigned;
}
/**
@@ -46,7 +43,7 @@ class DateIntervalToStringTransformer implements DataTransformerInterface
*
* @return string An ISO 8601 or relative date string like date interval presentation
*
* @throws UnexpectedTypeException If the given value is not a \DateInterval instance.
* @throws UnexpectedTypeException if the given value is not a \DateInterval instance
*/
public function transform($value)
{
@@ -67,8 +64,8 @@ class DateIntervalToStringTransformer implements DataTransformerInterface
*
* @return \DateInterval An instance of \DateInterval
*
* @throws UnexpectedTypeException If the given value is not a string.
* @throws TransformationFailedException If the date interval could not be parsed.
* @throws UnexpectedTypeException if the given value is not a string
* @throws TransformationFailedException if the date interval could not be parsed
*/
public function reverseTransform($value)
{
@@ -27,8 +27,6 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
private $fields;
/**
* Constructor.
*
* @param string $inputTimezone The input timezone
* @param string $outputTimezone The output timezone
* @param array $fields The date fields
@@ -28,8 +28,6 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
private $calendar;
/**
* Constructor.
*
* @see BaseDateTimeTransformer::formats for available format options
*
* @param string $inputTimezone The name of the input timezone
@@ -74,8 +72,8 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
*
* @return string|array Localized date string/array
*
* @throws TransformationFailedException If the given value is not a \DateTimeInterface
* or if the date could not be transformed.
* @throws TransformationFailedException if the given value is not a \DateTimeInterface
* or if the date could not be transformed
*/
public function transform($dateTime)
{
@@ -89,7 +87,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
$value = $this->getIntlDateFormatter()->format($dateTime->getTimestamp());
if (intl_get_error_code() != 0) {
if (0 != intl_get_error_code()) {
throw new TransformationFailedException(intl_get_error_message());
}
@@ -122,8 +120,11 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
$timestamp = $this->getIntlDateFormatter($dateOnly)->parse($value);
if (intl_get_error_code() != 0) {
if (0 != intl_get_error_code()) {
throw new TransformationFailedException(intl_get_error_message());
} elseif ($timestamp > 253402214400) {
// This timestamp represents UTC midnight of 9999-12-31 to prevent 5+ digit years
throw new TransformationFailedException('Years beyond 9999 are not supported.');
}
try {
@@ -151,11 +152,11 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
/**
* Returns a preconfigured IntlDateFormatter instance.
*
* @param bool $ignoreTimezone Use UTC regardless of the configured timezone.
* @param bool $ignoreTimezone Use UTC regardless of the configured timezone
*
* @return \IntlDateFormatter
*
* @throws TransformationFailedException in case the date formatter can not be constructed.
* @throws TransformationFailedException in case the date formatter can not be constructed
*/
protected function getIntlDateFormatter($ignoreTimezone = false)
{
@@ -49,17 +49,16 @@ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransform
*
* @return string Localized money string
*
* @throws TransformationFailedException If the given value is not numeric or
* if the value can not be transformed.
* @throws TransformationFailedException if the given value is not numeric or
* if the value can not be transformed
*/
public function transform($value)
{
if (null !== $value) {
if (null !== $value && 1 !== $this->divisor) {
if (!is_numeric($value)) {
throw new TransformationFailedException('Expected a numeric.');
}
$value /= $this->divisor;
$value = (string) ($value / $this->divisor);
}
return parent::transform($value);
@@ -72,15 +71,14 @@ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransform
*
* @return int|float Normalized number
*
* @throws TransformationFailedException If the given value is not a string
* or if the value can not be transformed.
* @throws TransformationFailedException if the given value is not a string
* or if the value can not be transformed
*/
public function reverseTransform($value)
{
$value = parent::reverseTransform($value);
if (null !== $value) {
$value *= $this->divisor;
if (null !== $value && 1 !== $this->divisor) {
$value = (float) (string) ($value * $this->divisor);
}
return $value;
@@ -100,8 +100,8 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
*
* @return string Localized value
*
* @throws TransformationFailedException If the given value is not numeric
* or if the value can not be transformed.
* @throws TransformationFailedException if the given value is not numeric
* or if the value can not be transformed
*/
public function transform($value)
{
@@ -133,8 +133,8 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
*
* @return int|float The numeric value
*
* @throws TransformationFailedException If the given value is not a string
* or if the value can not be transformed.
* @throws TransformationFailedException if the given value is not a string
* or if the value can not be transformed
*/
public function reverseTransform($value)
{
@@ -32,12 +32,9 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
);
private $type;
private $scale;
/**
* Constructor.
*
* @see self::$types for a list of supported types
*
* @param int $scale The scale
@@ -70,8 +67,8 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
*
* @return string Percentage value
*
* @throws TransformationFailedException If the given value is not numeric or
* if the value could not be transformed.
* @throws TransformationFailedException if the given value is not numeric or
* if the value could not be transformed
*/
public function transform($value)
{
@@ -105,8 +102,8 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
*
* @return int|float Normalized value
*
* @throws TransformationFailedException If the given value is not a string or
* if the value could not be transformed.
* @throws TransformationFailedException if the given value is not a string or
* if the value could not be transformed
*/
public function reverseTransform($value)
{
@@ -118,19 +115,58 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
return;
}
$position = 0;
$formatter = $this->getNumberFormatter();
$groupSep = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
$decSep = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$grouping = $formatter->getAttribute(\NumberFormatter::GROUPING_USED);
if ('.' !== $decSep && (!$grouping || '.' !== $groupSep)) {
$value = str_replace('.', $decSep, $value);
}
if (',' !== $decSep && (!$grouping || ',' !== $groupSep)) {
$value = str_replace(',', $decSep, $value);
}
if (false !== strpos($value, $decSep)) {
$type = \NumberFormatter::TYPE_DOUBLE;
} else {
$type = \PHP_INT_SIZE === 8 ? \NumberFormatter::TYPE_INT64 : \NumberFormatter::TYPE_INT32;
}
// replace normal spaces so that the formatter can read them
$value = $formatter->parse(str_replace(' ', "\xc2\xa0", $value));
$result = $formatter->parse(str_replace(' ', "\xc2\xa0", $value), $type, $position);
if (intl_is_failure($formatter->getErrorCode())) {
throw new TransformationFailedException($formatter->getErrorMessage());
}
if (self::FRACTIONAL == $this->type) {
$value /= 100;
$result /= 100;
}
return $value;
if (\function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value, null, true)) {
$length = mb_strlen($value, $encoding);
$remainder = mb_substr($value, $position, $length, $encoding);
} else {
$length = \strlen($value);
$remainder = substr($value, $position, $length);
}
// After parsing, position holds the index of the character where the
// parsing stopped
if ($position < $length) {
// Check if there are unrecognized characters at the end of the
// number (excluding whitespace characters)
$remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0");
if ('' !== $remainder) {
throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s"', $remainder));
}
}
return $result;
}
/**
@@ -47,12 +47,10 @@ class ValueToDuplicatesTransformer implements DataTransformerInterface
/**
* Extracts the duplicated value from an array.
*
* @param array $array
*
* @return mixed The value
*
* @throws TransformationFailedException If the given value is not an array or
* if the given array can not be transformed.
* @throws TransformationFailedException if the given value is not an array or
* if the given array can not be transformed
*/
public function reverseTransform($array)
{
@@ -25,8 +25,6 @@ class FixUrlProtocolListener implements EventSubscriberInterface
private $defaultProtocol;
/**
* Constructor.
*
* @param string|null $defaultProtocol The URL scheme to add when there is none or null to not modify the data
*/
public function __construct($defaultProtocol = 'http')
@@ -21,27 +21,12 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
*/
class MergeCollectionListener implements EventSubscriberInterface
{
/**
* Whether elements may be added to the collection.
*
* @var bool
*/
private $allowAdd;
/**
* Whether elements may be removed from the collection.
*
* @var bool
*/
private $allowDelete;
/**
* Creates a new listener.
*
* @param bool $allowAdd Whether values might be added to the
* collection.
* @param bool $allowDelete Whether values might be removed from the
* collection.
* @param bool $allowAdd Whether values might be added to the collection
* @param bool $allowDelete Whether values might be removed from the collection
*/
public function __construct($allowAdd = false, $allowDelete = false)
{
@@ -80,7 +65,7 @@ class MergeCollectionListener implements EventSubscriberInterface
return;
}
if (!$dataToMergeInto) {
if (null === $dataToMergeInto) {
// No original data was set. Set it if allowed
if ($this->allowAdd) {
$dataToMergeInto = $data;
@@ -15,6 +15,7 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormInterface;
/**
* Resize a collection form element based on the data sent from the client.
@@ -23,35 +24,20 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
class ResizeFormListener implements EventSubscriberInterface
{
/**
* @var string
*/
protected $type;
/**
* @var array
*/
protected $options;
/**
* Whether children could be added to the group.
*
* @var bool
*/
protected $allowAdd;
/**
* Whether children could be removed from the group.
*
* @var bool
*/
protected $allowDelete;
/**
* @var bool
*/
private $deleteEmpty;
/**
* @param string $type
* @param array $options
* @param bool $allowAdd Whether children could be added to the group
* @param bool $allowDelete Whether children could be removed from the group
* @param bool $deleteEmpty
*/
public function __construct($type, array $options = array(), $allowAdd = false, $allowDelete = false, $deleteEmpty = false)
{
$this->type = $type;
@@ -103,7 +89,7 @@ class ResizeFormListener implements EventSubscriberInterface
$data = $event->getData();
if ($data instanceof \Traversable && $data instanceof \ArrayAccess) {
@trigger_error('Support for objects implementing both \Traversable and \ArrayAccess is deprecated since version 3.1 and will be removed in 4.0. Use an array instead.', E_USER_DEPRECATED);
@trigger_error('Support for objects implementing both \Traversable and \ArrayAccess is deprecated since Symfony 3.1 and will be removed in 4.0. Use an array instead.', E_USER_DEPRECATED);
}
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
@@ -150,6 +136,7 @@ class ResizeFormListener implements EventSubscriberInterface
if ($this->deleteEmpty) {
$previousData = $event->getForm()->getData();
/** @var FormInterface $child */
foreach ($form as $name => $child) {
$isNew = !isset($previousData[$name]);
+2 -15
View File
@@ -37,11 +37,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ChoiceType extends AbstractType
{
/**
* Caches created choice lists.
*
* @var ChoiceListFactoryInterface
*/
private $choiceListFactory;
public function __construct(ChoiceListFactoryInterface $choiceListFactory = null)
@@ -116,6 +111,7 @@ class ChoiceType extends AbstractType
// Reconstruct the data as mapping from child names to values
$data = array();
/** @var FormInterface $child */
foreach ($form as $child) {
$value = $child->getConfig()->getOption('value');
@@ -284,7 +280,7 @@ class ChoiceType extends AbstractType
throw new \RuntimeException(sprintf('The "choices_as_values" option of the %s should not be used. Remove it and flip the contents of the "choices" option instead.', get_class($this)));
}
@trigger_error('The "choices_as_values" option is deprecated since version 3.1 and will be removed in 4.0. You should not use it anymore.', E_USER_DEPRECATED);
@trigger_error('The "choices_as_values" option is deprecated since Symfony 3.1 and will be removed in 4.0. You should not use it anymore.', E_USER_DEPRECATED);
return true;
};
@@ -368,10 +364,6 @@ class ChoiceType extends AbstractType
/**
* Adds the sub fields for an expanded choice field.
*
* @param FormBuilderInterface $builder The form builder
* @param array $choiceViews The choice view objects
* @param array $options The build options
*/
private function addSubForms(FormBuilderInterface $builder, array $choiceViews, array $options)
{
@@ -392,11 +384,6 @@ class ChoiceType extends AbstractType
}
/**
* @param FormBuilderInterface $builder
* @param $name
* @param $choiceView
* @param array $options
*
* @return mixed
*/
private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $choiceView, array $options)
+1 -1
View File
@@ -39,7 +39,7 @@ class CountryType extends AbstractType implements ChoiceLoaderInterface
$resolver->setDefaults(array(
'choice_loader' => function (Options $options) {
if ($options['choices']) {
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since Symfony 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
return null;
}
+1 -1
View File
@@ -39,7 +39,7 @@ class CurrencyType extends AbstractType implements ChoiceLoaderInterface
$resolver->setDefaults(array(
'choice_loader' => function (Options $options) {
if ($options['choices']) {
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since Symfony 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
return null;
}
@@ -178,7 +178,7 @@ class DateIntervalType extends AbstractType
{
$timeParts = $this->timeParts;
$compound = function (Options $options) {
return $options['widget'] !== 'single_text';
return 'single_text' !== $options['widget'];
};
$placeholderDefault = function (Options $options) {
@@ -30,7 +30,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class DateTimeType extends AbstractType
{
const DEFAULT_DATE_FORMAT = \IntlDateFormatter::MEDIUM;
const DEFAULT_TIME_FORMAT = \IntlDateFormatter::MEDIUM;
/**
+1 -2
View File
@@ -27,7 +27,6 @@ use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
class DateType extends AbstractType
{
const DEFAULT_FORMAT = \IntlDateFormatter::MEDIUM;
const HTML5_FORMAT = 'yyyy-MM-dd';
private static $acceptedFormats = array(
@@ -286,7 +285,7 @@ class DateType extends AbstractType
private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $timestamps)
{
$pattern = $formatter->getPattern();
$timezone = $formatter->getTimezoneId();
$timezone = $formatter->getTimeZoneId();
$formattedTimestamps = array();
$formatter->setTimeZone('UTC');
+34 -11
View File
@@ -27,20 +27,40 @@ class FileType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['multiple']) {
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
$form = $event->getForm();
$data = $event->getData();
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options) {
$form = $event->getForm();
$requestHandler = $form->getConfig()->getRequestHandler();
$data = null;
if ($options['multiple']) {
$data = array();
$files = $event->getData();
if (!is_array($files)) {
$files = array();
}
foreach ($files as $file) {
if ($requestHandler->isFileUpload($file)) {
$data[] = $file;
}
}
// submitted data for an input file (not required) without choosing any file
if (array(null) === $data) {
if (array(null) === $data || array() === $data) {
$emptyData = $form->getConfig()->getEmptyData();
$data = is_callable($emptyData) ? call_user_func($emptyData, $form, $data) : $emptyData;
$event->setData($data);
}
});
}
$event->setData($data);
} elseif (!$requestHandler->isFileUpload($event->getData())) {
$emptyData = $form->getConfig()->getEmptyData();
$data = is_callable($emptyData) ? call_user_func($emptyData, $form, $data) : $emptyData;
$event->setData($data);
}
});
}
/**
@@ -72,9 +92,12 @@ class FileType extends AbstractType
*/
public function configureOptions(OptionsResolver $resolver)
{
$dataClass = function (Options $options) {
return $options['multiple'] ? null : 'Symfony\Component\HttpFoundation\File\File';
};
$dataClass = null;
if (class_exists('Symfony\Component\HttpFoundation\File\File')) {
$dataClass = function (Options $options) {
return $options['multiple'] ? null : 'Symfony\Component\HttpFoundation\File\File';
};
}
$emptyData = function (Options $options) {
return $options['multiple'] ? array() : null;
-3
View File
@@ -24,9 +24,6 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
class FormType extends BaseType
{
/**
* @var PropertyAccessorInterface
*/
private $propertyAccessor;
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
+1 -1
View File
@@ -39,7 +39,7 @@ class LanguageType extends AbstractType implements ChoiceLoaderInterface
$resolver->setDefaults(array(
'choice_loader' => function (Options $options) {
if ($options['choices']) {
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since Symfony 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
return null;
}
+1 -1
View File
@@ -39,7 +39,7 @@ class LocaleType extends AbstractType implements ChoiceLoaderInterface
$resolver->setDefaults(array(
'choice_loader' => function (Options $options) {
if ($options['choices']) {
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since Symfony 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
return null;
}
+2 -2
View File
@@ -36,7 +36,7 @@ class TimezoneType extends AbstractType implements ChoiceLoaderInterface
$resolver->setDefaults(array(
'choice_loader' => function (Options $options) {
if ($options['choices']) {
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since version 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('Using the "choices" option in %s has been deprecated since Symfony 3.3 and will be ignored in 4.0. Override the "choice_loader" option instead or set it to null.', __CLASS__), E_USER_DEPRECATED);
return null;
}
@@ -72,7 +72,7 @@ class TimezoneType extends AbstractType implements ChoiceLoaderInterface
return $this->choiceList;
}
return $this->choiceList = new ArrayChoiceList($this->getTimezones(), $value);
return $this->choiceList = new ArrayChoiceList(self::getTimezones(), $value);
}
/**
-13
View File
@@ -22,24 +22,11 @@ use Symfony\Component\Translation\TranslatorInterface;
*/
class CsrfExtension extends AbstractExtension
{
/**
* @var CsrfTokenManagerInterface
*/
private $tokenManager;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var null|string
*/
private $translationDomain;
/**
* Constructor.
*
* @param CsrfTokenManagerInterface $tokenManager The CSRF token manager
* @param TranslatorInterface $translator The translator for translating error messages
* @param null|string $translationDomain The translation domain for translating
@@ -25,50 +25,12 @@ use Symfony\Component\Translation\TranslatorInterface;
*/
class CsrfValidationListener implements EventSubscriberInterface
{
/**
* The name of the CSRF field.
*
* @var string
*/
private $fieldName;
/**
* The generator for CSRF tokens.
*
* @var CsrfTokenManagerInterface
*/
private $tokenManager;
/**
* A text mentioning the tokenId of the CSRF token.
*
* Validation of the token will only succeed if it was generated in the
* same session and with the same tokenId.
*
* @var string
*/
private $tokenId;
/**
* The message displayed in case of an error.
*
* @var string
*/
private $errorMessage;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var null|string
*/
private $translationDomain;
/**
* @var ServerParams
*/
private $serverParams;
public static function getSubscribedEvents()
@@ -92,7 +54,7 @@ class CsrfValidationListener implements EventSubscriberInterface
public function preSubmit(FormEvent $event)
{
$form = $event->getForm();
$postRequestSizeExceeded = $form->getConfig()->getMethod() === 'POST' && $this->serverParams->hasPostMaxSizeBeenExceeded();
$postRequestSizeExceeded = 'POST' === $form->getConfig()->getMethod() && $this->serverParams->hasPostMaxSizeBeenExceeded();
if ($form->isRoot() && $form->getConfig()->getOption('compound') && !$postRequestSizeExceeded) {
$data = $event->getData();
@@ -26,36 +26,21 @@ use Symfony\Component\Translation\TranslatorInterface;
*/
class FormTypeCsrfExtension extends AbstractTypeExtension
{
/**
* @var CsrfTokenManagerInterface
*/
private $defaultTokenManager;
/**
* @var bool
*/
private $defaultEnabled;
/**
* @var string
*/
private $defaultFieldName;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var null|string
*/
private $translationDomain;
/**
* @var ServerParams
*/
private $serverParams;
/**
* @param CsrfTokenManagerInterface $defaultTokenManager
* @param bool $defaultEnabled
* @param string $defaultFieldName
* @param TranslatorInterface $translator
* @param null|string $translationDomain
* @param ServerParams $serverParams
*/
public function __construct(CsrfTokenManagerInterface $defaultTokenManager, $defaultEnabled = true, $defaultFieldName = '_token', TranslatorInterface $translator = null, $translationDomain = null, ServerParams $serverParams = null)
{
$this->defaultTokenManager = $defaultTokenManager;
@@ -11,7 +11,6 @@
namespace Symfony\Component\Form\Extension\DataCollector;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\AbstractExtension;
/**
@@ -22,9 +21,6 @@ use Symfony\Component\Form\AbstractExtension;
*/
class DataCollectorExtension extends AbstractExtension
{
/**
* @var EventSubscriberInterface
*/
private $dataCollector;
public function __construct(FormDataCollectorInterface $dataCollector)
@@ -24,9 +24,6 @@ use Symfony\Component\Form\FormEvents;
*/
class DataCollectorListener implements EventSubscriberInterface
{
/**
* @var FormDataCollectorInterface
*/
private $dataCollector;
public function __construct(FormDataCollectorInterface $dataCollector)
@@ -49,8 +46,6 @@ class DataCollectorListener implements EventSubscriberInterface
/**
* Listener for the {@link FormEvents::POST_SET_DATA} event.
*
* @param FormEvent $event The event object
*/
public function postSetData(FormEvent $event)
{
@@ -65,8 +60,6 @@ class DataCollectorListener implements EventSubscriberInterface
/**
* Listener for the {@link FormEvents::POST_SUBMIT} event.
*
* @param FormEvent $event The event object
*/
public function postSubmit(FormEvent $event)
{
@@ -16,15 +16,10 @@ use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\VarDumper\Caster\Caster;
use Symfony\Component\VarDumper\Caster\ClassStub;
use Symfony\Component\VarDumper\Caster\CutStub;
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Cloner\Stub;
use Symfony\Component\VarDumper\Cloner\VarCloner;
/**
* Data collector for {@link FormInterface} instances.
@@ -34,9 +29,6 @@ use Symfony\Component\VarDumper\Cloner\VarCloner;
*/
class FormDataCollector extends DataCollector implements FormDataCollectorInterface
{
/**
* @var FormDataExtractor
*/
private $dataExtractor;
/**
@@ -72,16 +64,6 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
*/
private $formsByView;
/**
* @var ValueExporter
*/
private $valueExporter;
/**
* @var ClonerInterface
*/
private $cloner;
private $hasVarDumper;
public function __construct(FormDataExtractorInterface $dataExtractor)
@@ -255,61 +237,33 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
/**
* {@inheritdoc}
*/
protected function cloneVar($var, $isClass = false)
protected function getCasters()
{
if ($var instanceof Data) {
return $var;
}
if (null === $this->cloner) {
if ($this->hasVarDumper) {
$this->cloner = new VarCloner();
$this->cloner->setMaxItems(-1);
$this->cloner->addCasters(array(
'*' => function ($v, array $a, Stub $s, $isNested) {
foreach ($a as &$v) {
if (is_object($v) && !$v instanceof \DateTimeInterface) {
$v = new CutStub($v);
}
}
return parent::getCasters() + array(
\Exception::class => function (\Exception $e, array $a, Stub $s) {
foreach (array("\0Exception\0previous", "\0Exception\0trace") as $k) {
if (isset($a[$k])) {
unset($a[$k]);
++$s->cut;
}
}
return $a;
},
\Exception::class => function (\Exception $e, array $a, Stub $s) {
if (isset($a[$k = "\0Exception\0previous"])) {
unset($a[$k]);
++$s->cut;
}
return $a;
},
FormInterface::class => function (FormInterface $f, array $a) {
return array(
Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())),
);
},
ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) {
return array(
Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(),
Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(),
Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(),
);
},
));
} else {
@trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED);
$this->cloner = false;
}
}
if (false !== $this->cloner) {
return $this->cloner->cloneVar($var, Caster::EXCLUDE_VERBOSE);
}
if (null === $this->valueExporter) {
$this->valueExporter = new ValueExporter();
}
return $this->valueExporter->exportValue($var);
return $a;
},
FormInterface::class => function (FormInterface $f, array $a) {
return array(
Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())),
);
},
ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) {
return array(
Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(),
Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(),
Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(),
);
},
);
}
private function &recursiveBuildPreliminaryFormTree(FormInterface $form, array &$outputByHash)
@@ -24,37 +24,26 @@ interface FormDataCollectorInterface extends DataCollectorInterface
{
/**
* Stores configuration data of the given form and its children.
*
* @param FormInterface $form A root form
*/
public function collectConfiguration(FormInterface $form);
/**
* Stores the default data of the given form and its children.
*
* @param FormInterface $form A root form
*/
public function collectDefaultData(FormInterface $form);
/**
* Stores the submitted data of the given form and its children.
*
* @param FormInterface $form A root form
*/
public function collectSubmittedData(FormInterface $form);
/**
* Stores the view variables of the given form view and its children.
*
* @param FormView $view A root form view
*/
public function collectViewVariables(FormView $view);
/**
* Specifies that the given objects represent the same conceptual form.
*
* @param FormInterface $form A form object
* @param FormView $view A view object
*/
public function associateFormWithView(FormInterface $form, FormView $view);
@@ -63,8 +52,6 @@ interface FormDataCollectorInterface extends DataCollectorInterface
* a tree-like data structure.
*
* The result can be queried using {@link getData()}.
*
* @param FormInterface $form A root form
*/
public function buildPreliminaryFormTree(FormInterface $form);
@@ -85,9 +72,6 @@ interface FormDataCollectorInterface extends DataCollectorInterface
* tree, only the view data will be included in the result. If a
* corresponding {@link FormInterface} exists otherwise, call
* {@link associateFormWithView()} before calling this method.
*
* @param FormInterface $form A root form
* @param FormView $view A root view
*/
public function buildFinalFormTree(FormInterface $form, FormView $view);
@@ -166,8 +166,6 @@ class FormDataExtractor implements FormDataExtractorInterface
/**
* Recursively builds an HTML ID for a form.
*
* @param FormInterface $form The form
*
* @return string The HTML ID
*/
private function buildId(FormInterface $form)
@@ -24,8 +24,6 @@ interface FormDataExtractorInterface
/**
* Extracts the configuration data of a form.
*
* @param FormInterface $form The form
*
* @return array Information about the form's configuration
*/
public function extractConfiguration(FormInterface $form);
@@ -33,8 +31,6 @@ interface FormDataExtractorInterface
/**
* Extracts the default data of a form.
*
* @param FormInterface $form The form
*
* @return array Information about the form's default data
*/
public function extractDefaultData(FormInterface $form);
@@ -42,8 +38,6 @@ interface FormDataExtractorInterface
/**
* Extracts the submitted data of a form.
*
* @param FormInterface $form The form
*
* @return array Information about the form's submitted data
*/
public function extractSubmittedData(FormInterface $form);
@@ -51,8 +45,6 @@ interface FormDataExtractorInterface
/**
* Extracts the view variables of a form.
*
* @param FormView $view The form view
*
* @return array Information about the view's variables
*/
public function extractViewVariables(FormView $view);
@@ -25,14 +25,7 @@ use Symfony\Component\Form\ResolvedFormTypeInterface;
*/
class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface
{
/**
* @var ResolvedFormTypeInterface
*/
private $proxiedType;
/**
* @var FormDataCollectorInterface
*/
private $dataCollector;
public function __construct(ResolvedFormTypeInterface $proxiedType, FormDataCollectorInterface $dataCollector)
@@ -24,14 +24,7 @@ use Symfony\Component\Form\ResolvedFormTypeInterface;
*/
class ResolvedTypeFactoryDataCollectorProxy implements ResolvedFormTypeFactoryInterface
{
/**
* @var ResolvedFormTypeFactoryInterface
*/
private $proxiedFactory;
/**
* @var FormDataCollectorInterface
*/
private $dataCollector;
public function __construct(ResolvedFormTypeFactoryInterface $proxiedFactory, FormDataCollectorInterface $dataCollector)
@@ -25,7 +25,7 @@ use Symfony\Component\Form\FormBuilderInterface;
class DataCollectorTypeExtension extends AbstractTypeExtension
{
/**
* @var \Symfony\Component\EventDispatcher\EventSubscriberInterface
* @var DataCollectorListener
*/
private $listener;
@@ -29,8 +29,6 @@ class DependencyInjectionExtension implements FormExtensionInterface
private $guesserServiceIds;
/**
* Constructor.
*
* @param ContainerInterface $typeContainer
* @param iterable[] $typeExtensionServices
* @param iterable $guesserServices
@@ -16,6 +16,7 @@ use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\RequestHandlerInterface;
use Symfony\Component\Form\Util\ServerParams;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\Request;
/**
@@ -26,14 +27,8 @@ use Symfony\Component\HttpFoundation\Request;
*/
class HttpFoundationRequestHandler implements RequestHandlerInterface
{
/**
* @var ServerParams
*/
private $serverParams;
/**
* {@inheritdoc}
*/
public function __construct(ServerParams $serverParams = null)
{
$this->serverParams = $serverParams ?: new ServerParams();
@@ -112,4 +107,12 @@ class HttpFoundationRequestHandler implements RequestHandlerInterface
$form->submit($data, 'PATCH' !== $method);
}
/**
* {@inheritdoc}
*/
public function isFileUpload($data)
{
return $data instanceof File;
}
}
@@ -21,14 +21,8 @@ use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler
*/
class FormTypeHttpFoundationExtension extends AbstractTypeExtension
{
/**
* @var RequestHandlerInterface
*/
private $requestHandler;
/**
* @param RequestHandlerInterface $requestHandler
*/
public function __construct(RequestHandlerInterface $requestHandler = null)
{
$this->requestHandler = $requestHandler ?: new HttpFoundationRequestHandler();
@@ -20,9 +20,6 @@ use Symfony\Component\Templating\EngineInterface;
*/
class TemplatingRendererEngine extends AbstractRendererEngine
{
/**
* @var EngineInterface
*/
private $engine;
public function __construct(EngineInterface $engine, array $defaultThemes = array())
@@ -56,28 +56,44 @@ class FormValidator extends ConstraintValidator
// Validate the data against the constraints defined
// in the form
$constraints = $config->getOption('constraints', array());
foreach ($constraints as $constraint) {
// For the "Valid" constraint, validate the data in all groups
if ($constraint instanceof Valid) {
$validator->atPath('data')->validate($form->getData(), $constraint, $groups);
continue;
}
if ($groups instanceof GroupSequence) {
$validator->atPath('data')->validate($form->getData(), $constraints, $groups);
// Otherwise validate a constraint only once for the first
// matching group
foreach ($groups as $group) {
if (in_array($group, $constraint->groups)) {
$validator->atPath('data')->validate($form->getData(), $constraint, $group);
if (count($this->context->getViolations()) > 0) {
break;
}
}
}
} else {
foreach ($constraints as $constraint) {
// For the "Valid" constraint, validate the data in all groups
if ($constraint instanceof Valid) {
$validator->atPath('data')->validate($form->getData(), $constraint, $groups);
// Prevent duplicate validation
continue 2;
continue;
}
// Otherwise validate a constraint only once for the first
// matching group
foreach ($groups as $group) {
if (in_array($group, $constraint->groups)) {
$validator->atPath('data')->validate($form->getData(), $constraint, $group);
// Prevent duplicate validation
continue 2;
}
}
}
}
} else {
$childrenSynchronized = true;
/** @var FormInterface $child */
foreach ($form as $child) {
if (!$child->isSynchronized()) {
$childrenSynchronized = false;
@@ -119,8 +135,6 @@ class FormValidator extends ConstraintValidator
/**
* Returns the validation groups of the given form.
*
* @param FormInterface $form The form
*
* @return array The validation groups
*/
private static function getValidationGroups(FormInterface $form)
@@ -23,14 +23,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class FormTypeValidatorExtension extends BaseValidatorExtension
{
/**
* @var ValidatorInterface
*/
private $validator;
/**
* @var ViolationMapper
*/
private $violationMapper;
public function __construct(ValidatorInterface $validator)
@@ -73,8 +73,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
/**
* Guesses a field class name for a given constraint.
*
* @param Constraint $constraint The constraint to guess for
*
* @return TypeGuess|null The guessed field class and options
*/
public function guessTypeForConstraint(Constraint $constraint)
@@ -151,8 +149,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
case 'Symfony\Component\Validator\Constraints\Count':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), Guess::LOW_CONFIDENCE);
case 'Symfony\Component\Validator\Constraints\True':
case 'Symfony\Component\Validator\Constraints\False':
case 'Symfony\Component\Validator\Constraints\IsTrue':
case 'Symfony\Component\Validator\Constraints\IsFalse':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', array(), Guess::MEDIUM_CONFIDENCE);
@@ -162,8 +158,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
/**
* Guesses whether a field is required based on the given constraint.
*
* @param Constraint $constraint The constraint to guess for
*
* @return ValueGuess|null The guess whether the field is required
*/
public function guessRequiredForConstraint(Constraint $constraint)
@@ -171,7 +165,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
switch (get_class($constraint)) {
case 'Symfony\Component\Validator\Constraints\NotNull':
case 'Symfony\Component\Validator\Constraints\NotBlank':
case 'Symfony\Component\Validator\Constraints\True':
case 'Symfony\Component\Validator\Constraints\IsTrue':
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
}
@@ -180,8 +173,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
/**
* Guesses a field's maximum length based on the given constraint.
*
* @param Constraint $constraint The constraint to guess for
*
* @return ValueGuess|null The guess for the maximum length
*/
public function guessMaxLengthForConstraint(Constraint $constraint)
@@ -210,8 +201,6 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
/**
* Guesses a field's pattern based on the given constraint.
*
* @param Constraint $constraint The constraint to guess for
*
* @return ValueGuess|null The guess for the pattern
*/
public function guessPatternForConstraint(Constraint $constraint)
@@ -254,7 +243,7 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
* @param \Closure $closure The closure that returns a guess
* for a given constraint
* @param mixed $defaultValue The default value assumed if no other value
* can be guessed.
* can be guessed
*
* @return Guess|null The guessed value with the highest confidence
*/
@@ -19,21 +19,15 @@ use Symfony\Component\Form\Exception\ErrorMappingException;
*/
class MappingRule
{
/**
* @var FormInterface
*/
private $origin;
/**
* @var string
*/
private $propertyPath;
/**
* @var string
*/
private $targetPath;
/**
* @param FormInterface $origin
* @param string $propertyPath
* @param string $targetPath
*/
public function __construct(FormInterface $origin, $propertyPath, $targetPath)
{
$this->origin = $origin;
@@ -19,9 +19,6 @@ use Symfony\Component\PropertyAccess\PropertyPath;
*/
class RelativePath extends PropertyPath
{
/**
* @var FormInterface
*/
private $root;
/**
@@ -269,8 +269,6 @@ class ViolationMapper implements ViolationMapperInterface
}
/**
* @param FormInterface $form
*
* @return bool
*/
private function acceptsErrors(FormInterface $form)
@@ -24,10 +24,8 @@ interface ViolationMapperInterface
* the given form.
*
* @param ConstraintViolation $violation The violation to map
* @param FormInterface $form The root form of the tree
* to map it to.
* @param bool $allowNonSynchronized Whether to allow
* mapping to non-synchronized forms.
* @param FormInterface $form The root form of the tree to map it to
* @param bool $allowNonSynchronized Whether to allow mapping to non-synchronized forms
*/
public function mapViolation(ConstraintViolation $violation, FormInterface $form, $allowNonSynchronized = false);
}
@@ -48,8 +48,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
/**
* Creates a new violation path from a string.
*
* @param string $violationPath The property path of a {@link \Symfony\Component\Validator\ConstraintViolation}
* object.
* @param string $violationPath The property path of a {@link \Symfony\Component\Validator\ConstraintViolation} object
*/
public function __construct($violationPath)
{
@@ -210,7 +209,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
*
* @return bool Whether the element maps to a form
*
* @throws OutOfBoundsException If the offset is invalid.
* @throws OutOfBoundsException if the offset is invalid
*/
public function mapsForm($index)
{
+6 -8
View File
@@ -49,7 +49,7 @@ use Symfony\Component\PropertyAccess\PropertyPath;
* either as "Y-m-d" string or as timestamp. Internally we still want to
* use a DateTime object for processing. To convert the data from string/integer
* to DateTime you can set a normalization transformer by calling
* addNormTransformer(). The normalized data is then converted to the displayed
* addModelTransformer(). The normalized data is then converted to the displayed
* data as described before.
*
* The conversions (1) -> (2) -> (3) use the transform methods of the transformers.
@@ -161,8 +161,6 @@ class Form implements \IteratorAggregate, FormInterface
/**
* Creates a new form based on the given configuration.
*
* @param FormConfigInterface $config The form configuration
*
* @throws LogicException if a data mapper is not provided for a compound form
*/
public function __construct(FormConfigInterface $config)
@@ -736,7 +734,7 @@ class Form implements \IteratorAggregate, FormInterface
public function isValid()
{
if (!$this->submitted) {
@trigger_error('Call Form::isValid() with an unsubmitted form is deprecated since version 3.2 and will throw an exception in 4.0. Use Form::isSubmitted() before Form::isValid() instead.', E_USER_DEPRECATED);
@trigger_error('Call Form::isValid() with an unsubmitted form is deprecated since Symfony 3.2 and will throw an exception in 4.0. Use Form::isSubmitted() before Form::isValid() instead.', E_USER_DEPRECATED);
return false;
}
@@ -944,7 +942,7 @@ class Form implements \IteratorAggregate, FormInterface
*
* @return FormInterface The child form
*
* @throws \OutOfBoundsException If the named child does not exist.
* @throws \OutOfBoundsException if the named child does not exist
*/
public function offsetGet($name)
{
@@ -957,8 +955,8 @@ class Form implements \IteratorAggregate, FormInterface
* @param string $name Ignored. The name of the child is used
* @param FormInterface $child The child to be added
*
* @throws AlreadySubmittedException If the form has already been submitted.
* @throws LogicException When trying to add a child to a non-compound form.
* @throws AlreadySubmittedException if the form has already been submitted
* @throws LogicException when trying to add a child to a non-compound form
*
* @see self::add()
*/
@@ -972,7 +970,7 @@ class Form implements \IteratorAggregate, FormInterface
*
* @param string $name The name of the child to remove
*
* @throws AlreadySubmittedException If the form has already been submitted.
* @throws AlreadySubmittedException if the form has already been submitted
*/
public function offsetUnset($name)
{
+8 -8
View File
@@ -32,7 +32,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*
* @var NativeRequestHandler
*/
private static $nativeRequestProcessor;
private static $nativeRequestHandler;
/**
* The accepted request methods.
@@ -185,8 +185,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
* @param EventDispatcherInterface $dispatcher The event dispatcher
* @param array $options The form options
*
* @throws InvalidArgumentException If the data class is not a valid class or if
* the name contains invalid characters.
* @throws InvalidArgumentException if the data class is not a valid class or if
* the name contains invalid characters
*/
public function __construct($name, $dataClass, EventDispatcherInterface $dispatcher, array $options = array())
{
@@ -496,10 +496,10 @@ class FormConfigBuilder implements FormConfigBuilderInterface
public function getRequestHandler()
{
if (null === $this->requestHandler) {
if (null === self::$nativeRequestProcessor) {
self::$nativeRequestProcessor = new NativeRequestHandler();
if (null === self::$nativeRequestHandler) {
self::$nativeRequestHandler = new NativeRequestHandler();
}
$this->requestHandler = self::$nativeRequestProcessor;
$this->requestHandler = self::$nativeRequestHandler;
}
return $this->requestHandler;
@@ -852,8 +852,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*
* @param string|int $name The tested form name
*
* @throws UnexpectedTypeException If the name is not a string or an integer.
* @throws InvalidArgumentException If the name contains invalid characters.
* @throws UnexpectedTypeException if the name is not a string or an integer
* @throws InvalidArgumentException if the name contains invalid characters
*/
public static function validateName($name)
{
+5 -18
View File
@@ -35,8 +35,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Adds an event subscriber for events on this form.
*
* @param EventSubscriberInterface $subscriber The subscriber to attach
*
* @return $this The configuration object
*/
public function addEventSubscriber(EventSubscriberInterface $subscriber);
@@ -50,7 +48,7 @@ interface FormConfigBuilderInterface extends FormConfigInterface
* view to the normalized format.
*
* @param DataTransformerInterface $viewTransformer
* @param bool $forcePrepend if set to true, prepend instead of appending
* @param bool $forcePrepend If set to true, prepend instead of appending
*
* @return $this The configuration object
*/
@@ -72,7 +70,7 @@ interface FormConfigBuilderInterface extends FormConfigInterface
* normalized to the model format.
*
* @param DataTransformerInterface $modelTransformer
* @param bool $forceAppend if set to true, append instead of prepending
* @param bool $forceAppend If set to true, append instead of prepending
*
* @return $this The configuration object
*/
@@ -98,8 +96,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Sets the attributes.
*
* @param array $attributes The attributes
*
* @return $this The configuration object
*/
public function setAttributes(array $attributes);
@@ -107,8 +103,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Sets the data mapper used by the form.
*
* @param DataMapperInterface $dataMapper
*
* @return $this The configuration object
*/
public function setDataMapper(DataMapperInterface $dataMapper = null);
@@ -152,9 +146,8 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Sets the property path that the form should be mapped to.
*
* @param null|string|PropertyPathInterface $propertyPath
* The property path or null if the path should be set
* automatically based on the form's name.
* @param null|string|PropertyPathInterface $propertyPath The property path or null if the path should be set
* automatically based on the form's name
*
* @return $this The configuration object
*/
@@ -174,7 +167,7 @@ interface FormConfigBuilderInterface extends FormConfigInterface
* Sets whether the form's data should be modified by reference.
*
* @param bool $byReference Whether the data should be
* modified by reference.
* modified by reference
*
* @return $this The configuration object
*/
@@ -203,8 +196,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Set the types.
*
* @param ResolvedFormTypeInterface $type The type of the form
*
* @return $this The configuration object
*/
public function setType(ResolvedFormTypeInterface $type);
@@ -233,8 +224,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Sets the form factory used for creating new forms.
*
* @param FormFactoryInterface $formFactory The form factory
*/
public function setFormFactory(FormFactoryInterface $formFactory);
@@ -259,8 +248,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
/**
* Sets the request handler used by the form.
*
* @param RequestHandlerInterface $requestHandler
*
* @return $this The configuration object
*/
public function setRequestHandler(RequestHandlerInterface $requestHandler);
+3 -3
View File
@@ -167,7 +167,7 @@ interface FormConfigInterface
/**
* Returns the class of the form data or null if the data is scalar or an array.
*
* @return string The data class or null
* @return null|string The data class or null
*/
public function getDataClass();
@@ -213,8 +213,8 @@ interface FormConfigInterface
/**
* Returns whether the form should be initialized upon creation.
*
* @return bool Returns true if the form should be initialized
* when created, false otherwise.
* @return bool returns true if the form should be initialized
* when created, false otherwise
*/
public function getAutoInitialize();
+1 -29
View File
@@ -20,37 +20,11 @@ use Symfony\Component\Form\Exception\BadMethodCallException;
*/
class FormError implements \Serializable
{
/**
* @var string
*/
private $message;
/**
* The template for the error message.
*
* @var string
*/
protected $messageTemplate;
/**
* The parameters that should be substituted in the message template.
*
* @var array
*/
protected $messageParameters;
/**
* The value for error message pluralization.
*
* @var int|null
*/
protected $messagePluralization;
/**
* The cause for this error.
*
* @var mixed
*/
private $message;
private $cause;
/**
@@ -61,8 +35,6 @@ class FormError implements \Serializable
private $origin;
/**
* Constructor.
*
* Any array key in $messageParameters will be used as a placeholder in
* $messageTemplate.
*
+5 -14
View File
@@ -33,26 +33,17 @@ class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \Array
{
/**
* The prefix used for indenting nested error messages.
*
* @var string
*/
const INDENTATION = ' ';
/**
* @var FormInterface
*/
private $form;
/**
* @var FormError[]|FormErrorIterator[]
*/
private $errors;
/**
* Creates a new iterator.
*
* @param FormInterface $form The erroneous form
* @param array $errors The form errors
* @param FormInterface $form The erroneous form
* @param FormError[]|FormErrorIterator[] $errors The form errors
*
* @throws InvalidArgumentException If the errors are invalid
*/
@@ -108,8 +99,8 @@ class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \Array
/**
* Returns the current element of the iterator.
*
* @return FormError|FormErrorIterator An error or an iterator containing
* nested errors.
* @return FormError|FormErrorIterator an error or an iterator containing
* nested errors
*/
public function current()
{
@@ -271,7 +262,7 @@ class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \Array
*
* @param string|string[] $codes The codes to find
*
* @return static New instance which contains only specific errors.
* @return static new instance which contains only specific errors
*/
public function findByCodes($codes)
{
-6
View File
@@ -21,12 +21,6 @@ class FormEvent extends Event
private $form;
protected $data;
/**
* Constructs an event.
*
* @param FormInterface $form The associated form
* @param mixed $data The data
*/
public function __construct(FormInterface $form, $data)
{
$this->form = $form;
-10
View File
@@ -21,8 +21,6 @@ interface FormFactoryBuilderInterface
/**
* Sets the factory for creating ResolvedFormTypeInterface instances.
*
* @param ResolvedFormTypeFactoryInterface $resolvedTypeFactory
*
* @return $this
*/
public function setResolvedTypeFactory(ResolvedFormTypeFactoryInterface $resolvedTypeFactory);
@@ -30,8 +28,6 @@ interface FormFactoryBuilderInterface
/**
* Adds an extension to be loaded by the factory.
*
* @param FormExtensionInterface $extension The extension
*
* @return $this
*/
public function addExtension(FormExtensionInterface $extension);
@@ -48,8 +44,6 @@ interface FormFactoryBuilderInterface
/**
* Adds a form type to the factory.
*
* @param FormTypeInterface $type The form type
*
* @return $this
*/
public function addType(FormTypeInterface $type);
@@ -66,8 +60,6 @@ interface FormFactoryBuilderInterface
/**
* Adds a form type extension to the factory.
*
* @param FormTypeExtensionInterface $typeExtension The form type extension
*
* @return $this
*/
public function addTypeExtension(FormTypeExtensionInterface $typeExtension);
@@ -84,8 +76,6 @@ interface FormFactoryBuilderInterface
/**
* Adds a type guesser to the factory.
*
* @param FormTypeGuesserInterface $typeGuesser The type guesser
*
* @return $this
*/
public function addTypeGuesser(FormTypeGuesserInterface $typeGuesser);
+15 -20
View File
@@ -23,13 +23,11 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
/**
* Sets the parent form.
*
* @param FormInterface|null $parent The parent form or null if it's the root
*
* @return self
*
* @throws Exception\AlreadySubmittedException If the form has already been submitted.
* @throws Exception\LogicException When trying to set a parent for a form with
* an empty name.
* @throws Exception\AlreadySubmittedException if the form has already been submitted
* @throws Exception\LogicException when trying to set a parent for a form with
* an empty name
*/
public function setParent(FormInterface $parent = null);
@@ -49,9 +47,9 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return self
*
* @throws Exception\AlreadySubmittedException If the form has already been submitted.
* @throws Exception\LogicException When trying to add a child to a non-compound form.
* @throws Exception\UnexpectedTypeException If $child or $type has an unexpected type.
* @throws Exception\AlreadySubmittedException if the form has already been submitted
* @throws Exception\LogicException when trying to add a child to a non-compound form
* @throws Exception\UnexpectedTypeException if $child or $type has an unexpected type
*/
public function add($child, $type = null, array $options = array());
@@ -62,7 +60,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return self
*
* @throws \OutOfBoundsException If the named child does not exist.
* @throws \OutOfBoundsException if the named child does not exist
*/
public function get($name);
@@ -82,7 +80,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return $this
*
* @throws Exception\AlreadySubmittedException If the form has already been submitted.
* @throws Exception\AlreadySubmittedException if the form has already been submitted
*/
public function remove($name);
@@ -112,7 +110,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
*
* @return $this
*
* @throws Exception\AlreadySubmittedException If the form has already been submitted.
* @throws Exception\AlreadySubmittedException if the form has already been submitted
* @throws Exception\LogicException If listeners try to call setData in a cycle. Or if
* the view data does not match the expected type
* according to {@link FormConfigInterface::getDataClass}.
@@ -129,7 +127,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
/**
* Returns the normalized data of the field.
*
* @return mixed When the field is not submitted, the default data is returned
* @return mixed When the field is not submitted, the default data is returned.
* When the field is submitted, the normalized submitted data is
* returned if the field is valid, null otherwise.
*/
@@ -173,7 +171,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
/**
* Returns the property path that the form is mapped to.
*
* @return \Symfony\Component\PropertyAccess\PropertyPathInterface The property path
* @return \Symfony\Component\PropertyAccess\PropertyPathInterface|null The property path
*/
public function getPropertyPath();
@@ -269,14 +267,13 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
/**
* Submits data to the form, transforms and validates it.
*
* @param null|string|array $submittedData The submitted data
* @param bool $clearMissing Whether to set fields to NULL
* when they are missing in the
* submitted data.
* @param mixed $submittedData The submitted data
* @param bool $clearMissing Whether to set fields to NULL when they
* are missing in the submitted data
*
* @return $this
*
* @throws Exception\AlreadySubmittedException If the form has already been submitted.
* @throws Exception\AlreadySubmittedException if the form has already been submitted
*/
public function submit($submittedData, $clearMissing = true);
@@ -297,8 +294,6 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
/**
* Creates a view.
*
* @param FormView $parent The parent view
*
* @return FormView The view
*/
public function createView(FormView $parent = null);
+7 -6
View File
@@ -45,8 +45,6 @@ class FormRegistry implements FormRegistryInterface
private $resolvedTypeFactory;
/**
* Constructor.
*
* @param FormExtensionInterface[] $extensions An array of FormExtensionInterface
* @param ResolvedFormTypeFactoryInterface $resolvedTypeFactory The factory for resolved form types
*
@@ -81,11 +79,14 @@ class FormRegistry implements FormRegistryInterface
if (!$type) {
// Support fully-qualified class names
if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) {
$type = new $name();
} else {
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
if (!class_exists($name)) {
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not exist.', $name));
}
if (!is_subclass_of($name, 'Symfony\Component\Form\FormTypeInterface')) {
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not implement "Symfony\Component\Form\FormTypeInterface".', $name));
}
$type = new $name();
}
$this->types[$name] = $this->resolveType($type);
-25
View File
@@ -24,37 +24,12 @@ class FormRenderer implements FormRendererInterface
{
const CACHE_KEY_VAR = 'unique_block_prefix';
/**
* @var FormRendererEngineInterface
*/
private $engine;
/**
* @var CsrfTokenManagerInterface
*/
private $csrfTokenManager;
/**
* @var array
*/
private $blockNameHierarchyMap = array();
/**
* @var array
*/
private $hierarchyLevelMap = array();
/**
* @var array
*/
private $variableStack = array();
/**
* Constructor.
*
* @param FormRendererEngineInterface $engine
* @param CsrfTokenManagerInterface|null $csrfTokenManager
*/
public function __construct(FormRendererEngineInterface $engine, CsrfTokenManagerInterface $csrfTokenManager = null)
{
$this->engine = $engine;
+6 -6
View File
@@ -36,13 +36,13 @@ interface FormRendererEngineInterface
* The type of the resource is decided by the implementation. The resource
* is later passed to {@link renderBlock()} by the rendering algorithm.
*
* @param FormView $view The view for determining the used themes
* @param FormView $view The view for determining the used themes.
* First the themes attached directly to the
* view with {@link setTheme()} are considered,
* then the ones of its parent etc.
* @param string $blockName The name of the block to render
*
* @return mixed The renderer resource or false, if none was found
* @return mixed the renderer resource or false, if none was found
*/
public function getResourceForBlockName(FormView $view, $blockName);
@@ -70,12 +70,12 @@ interface FormRendererEngineInterface
* The type of the resource is decided by the implementation. The resource
* is later passed to {@link renderBlock()} by the rendering algorithm.
*
* @param FormView $view The view for determining the used themes
* @param FormView $view The view for determining the used themes.
* First the themes attached directly to
* the view with {@link setTheme()} are
* considered, then the ones of its parent etc.
* @param array $blockNameHierarchy The block name hierarchy, with the root block
* at the beginning.
* at the beginning
* @param int $hierarchyLevel The level in the hierarchy at which to start
* looking. Level 0 indicates the root block, i.e.
* the first element of $blockNameHierarchy.
@@ -110,12 +110,12 @@ interface FormRendererEngineInterface
* The type of the resource is decided by the implementation. The resource
* is later passed to {@link renderBlock()} by the rendering algorithm.
*
* @param FormView $view The view for determining the used themes
* @param FormView $view The view for determining the used themes.
* First the themes attached directly to
* the view with {@link setTheme()} are
* considered, then the ones of its parent etc.
* @param array $blockNameHierarchy The block name hierarchy, with the root block
* at the beginning.
* at the beginning
* @param int $hierarchyLevel The level in the hierarchy at which to start
* looking. Level 0 indicates the root block, i.e.
* the first element of $blockNameHierarchy.
-11
View File
@@ -25,9 +25,6 @@ interface FormTypeExtensionInterface
* further modify it.
*
* @see FormTypeInterface::buildForm()
*
* @param FormBuilderInterface $builder The form builder
* @param array $options The options
*/
public function buildForm(FormBuilderInterface $builder, array $options);
@@ -38,10 +35,6 @@ interface FormTypeExtensionInterface
* further modify it.
*
* @see FormTypeInterface::buildView()
*
* @param FormView $view The view
* @param FormInterface $form The form
* @param array $options The options
*/
public function buildView(FormView $view, FormInterface $form, array $options);
@@ -52,10 +45,6 @@ interface FormTypeExtensionInterface
* further modify it.
*
* @see FormTypeInterface::finishView()
*
* @param FormView $view The view
* @param FormInterface $form The form
* @param array $options The options
*/
public function finishView(FormView $view, FormInterface $form, array $options);
-2
View File
@@ -19,8 +19,6 @@ class FormTypeGuesserChain implements FormTypeGuesserInterface
private $guessers = array();
/**
* Constructor.
*
* @param FormTypeGuesserInterface[] $guessers Guessers as instances of FormTypeGuesserInterface
*
* @throws UnexpectedTypeException if any guesser does not implement FormTypeGuesserInterface
-4
View File
@@ -20,8 +20,6 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* The variables assigned to this view.
*
* @var array
*/
public $vars = array(
'value' => null,
@@ -30,8 +28,6 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* The parent view.
*
* @var FormView
*/
public $parent;
-10
View File
@@ -26,29 +26,21 @@ abstract class Guess
{
/**
* Marks an instance with a value that is extremely likely to be correct.
*
* @var int
*/
const VERY_HIGH_CONFIDENCE = 3;
/**
* Marks an instance with a value that is very likely to be correct.
*
* @var int
*/
const HIGH_CONFIDENCE = 2;
/**
* Marks an instance with a value that is likely to be correct.
*
* @var int
*/
const MEDIUM_CONFIDENCE = 1;
/**
* Marks an instance with a value that may be correct.
*
* @var int
*/
const LOW_CONFIDENCE = 0;
@@ -88,8 +80,6 @@ abstract class Guess
}
/**
* Constructor.
*
* @param int $confidence The confidence
*
* @throws InvalidArgumentException if the given value of confidence is unknown
-13
View File
@@ -19,23 +19,10 @@ namespace Symfony\Component\Form\Guess;
*/
class TypeGuess extends Guess
{
/**
* The guessed field type.
*
* @var string
*/
private $type;
/**
* The guessed options for creating an instance of the guessed class.
*
* @var array
*/
private $options;
/**
* Constructor.
*
* @param string $type The guessed field type
* @param array $options The options for creating instances of the
* guessed class
-2
View File
@@ -21,8 +21,6 @@ class ValueGuess extends Guess
private $value;
/**
* Constructor.
*
* @param string|int|bool|null $value The guessed value
* @param int $confidence The confidence that the guessed class name
* is correct
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2017 Fabien Potencier
Copyright (c) 2004-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+16 -15
View File
@@ -21,23 +21,10 @@ use Symfony\Component\Form\Util\ServerParams;
*/
class NativeRequestHandler implements RequestHandlerInterface
{
/**
* @var ServerParams
*/
private $serverParams;
/**
* {@inheritdoc}
*/
public function __construct(ServerParams $params = null)
{
$this->serverParams = $params ?: new ServerParams();
}
/**
* The allowed keys of the $_FILES array.
*
* @var array
*/
private static $fileKeys = array(
'error',
@@ -47,6 +34,11 @@ class NativeRequestHandler implements RequestHandlerInterface
'type',
);
public function __construct(ServerParams $params = null)
{
$this->serverParams = $params ?: new ServerParams();
}
/**
* {@inheritdoc}
*/
@@ -126,6 +118,17 @@ class NativeRequestHandler implements RequestHandlerInterface
$form->submit($data, 'PATCH' !== $method);
}
/**
* {@inheritdoc}
*/
public function isFileUpload($data)
{
// POST data will always be strings or arrays of strings. Thus, we can be sure
// that the submitted data is a file upload if the "error" value is an integer
// (this value must have been injected by PHP itself).
return is_array($data) && isset($data['error']) && is_int($data['error']);
}
/**
* Returns the method used to submit the request to the server.
*
@@ -159,8 +162,6 @@ class NativeRequestHandler implements RequestHandlerInterface
* This method is identical to {@link \Symfony\Component\HttpFoundation\FileBag::fixPhpFilesArray}
* and should be kept as such in order to port fixes quickly and easily.
*
* @param array $data
*
* @return array
*/
private static function fixPhpFilesArray($data)
-11
View File
@@ -20,19 +20,8 @@ use Symfony\Component\Form\Exception\InvalidArgumentException;
*/
class PreloadedExtension implements FormExtensionInterface
{
/**
* @var FormTypeInterface[]
*/
private $types = array();
/**
* @var array[FormTypeExtensionInterface[]]
*/
private $typeExtensions = array();
/**
* @var FormTypeGuesserInterface
*/
private $typeGuesser;
/**
+9
View File
@@ -25,4 +25,13 @@ interface RequestHandlerInterface
* @param mixed $request The current request
*/
public function handleRequest(FormInterface $form, $request = null);
/**
* Returns true if the given data is a file upload.
*
* @param mixed $data The form field data
*
* @return bool
*/
public function isFileUpload($data);
}
@@ -11,8 +11,8 @@
<target>Den uppladdade filen var för stor. Försök ladda upp en mindre fil.</target>
</trans-unit>
<trans-unit id="30">
<source>The CSRF token is invalid.</source>
<target>CSRF-symbolen är inte giltig.</target>
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>CSRF-elementet är inte giltigt. Försök att skicka formuläret igen.</target>
</trans-unit>
</body>
</file>
-10
View File
@@ -21,18 +21,8 @@ namespace Symfony\Component\Form;
*/
class ReversedTransformer implements DataTransformerInterface
{
/**
* The reversed transformer.
*
* @var DataTransformerInterface
*/
protected $reversedTransformer;
/**
* Reverses this transformer.
*
* @param DataTransformerInterface $reversedTransformer
*/
public function __construct(DataTransformerInterface $reversedTransformer)
{
$this->reversedTransformer = $reversedTransformer;
+7 -1
View File
@@ -39,10 +39,16 @@ class SubmitButton extends Button implements ClickableInterface
*
* @return $this
*
* @throws Exception\AlreadySubmittedException If the form has already been submitted.
* @throws Exception\AlreadySubmittedException if the form has already been submitted
*/
public function submit($submittedData, $clearMissing = true)
{
if ($this->getConfig()->getDisabled()) {
$this->clicked = false;
return $this;
}
parent::submit($submittedData, $clearMissing);
$this->clicked = null !== $submittedData;
+1 -1
View File
@@ -35,7 +35,7 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase
parent::runTest();
$time = microtime(true) - $s;
if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) {
$this->fail(
sprintf(
'expected running time: <= %s but was: %s',
-5
View File
@@ -34,11 +34,6 @@ abstract class TypeTestCase extends FormIntegrationTestCase
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
}
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
{
self::assertEquals($expected->format('c'), $actual->format('c'));
}
public static function assertDateIntervalEquals(\DateInterval $expected, \DateInterval $actual)
{
self::assertEquals($expected->format('%RP%yY%mM%dDT%hH%iM%sS'), $actual->format('%RP%yY%mM%dDT%hH%iM%sS'));
@@ -1914,6 +1914,25 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
);
}
public function testMoneyWithoutCurrency()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array(
'currency' => false,
));
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/input
[@id="my&id"]
[@type="text"]
[@name="name"]
[@class="my&class form-control"]
[@value="1234.56"]
[not(preceding-sibling::*)]
[not(following-sibling::*)]
'
);
}
public function testNumber()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56);
+3 -3
View File
@@ -58,7 +58,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
protected function assertMatchesXpath($html, $expression, $count = 1)
{
$dom = new \DomDocument('UTF-8');
$dom = new \DOMDocument('UTF-8');
try {
// Wrap in <root> node so we can load HTML with multiple tags at
// the top level
@@ -78,8 +78,8 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
$this->fail(sprintf(
"Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s",
$expression,
$count == 1 ? 'once' : $count.' times',
$nodeList->length == 1 ? 'once' : $nodeList->length.' times',
1 == $count ? 'once' : $count.' times',
1 == $nodeList->length ? 'once' : $nodeList->length.' times',
// strip away <root> and </root>
substr($dom->saveHTML(), 6, -8)
));
@@ -353,12 +353,24 @@ abstract class AbstractRequestHandlerTest extends TestCase
);
}
public function testUploadedFilesAreAccepted()
{
$this->assertTrue($this->requestHandler->isFileUpload($this->getMockFile()));
}
public function testInvalidFilesAreRejected()
{
$this->assertFalse($this->requestHandler->isFileUpload($this->getInvalidFile()));
}
abstract protected function setRequestData($method, $data, $files = array());
abstract protected function getRequestHandler();
abstract protected function getMockFile($suffix = '');
abstract protected function getInvalidFile();
protected function getMockForm($name, $method = null, $compound = true)
{
$config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
+7 -4
View File
@@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\ButtonBuilder;
use Symfony\Component\Form\Exception\InvalidArgumentException;
/**
* @author Alexander Cheprasov <cheprasov.84@ya.ru>
@@ -53,10 +54,12 @@ class ButtonBuilderTest extends TestCase
*/
public function testInvalidNames($name)
{
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(
'\Symfony\Component\Form\Exception\InvalidArgumentException',
'Buttons cannot have empty names.'
);
if (method_exists($this, 'expectException')) {
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Buttons cannot have empty names.');
} else {
$this->setExpectedException(InvalidArgumentException::class, 'Buttons cannot have empty names.');
}
new ButtonBuilder($name);
}
}

Some files were not shown because too many files have changed in this diff Show More