diff --git a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php index a6a3a1a284..6392474ff1 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\Doctrine\Form\DataTransformer; -use Symfony\Component\Form\Exception\UnexpectedTypeException; +use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\DataTransformerInterface; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; @@ -28,7 +28,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface * * @return mixed An array of entities * - * @throws UnexpectedTypeException + * @throws TransformationFailedException */ public function transform($collection) { @@ -37,7 +37,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface } if (!$collection instanceof Collection) { - throw new UnexpectedTypeException($collection, 'Doctrine\Common\Collections\Collection'); + throw new TransformationFailedException('Expected a Doctrine\Common\Collections\Collection object.'); } return $collection->toArray(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php index db80925111..3298271e1f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php @@ -286,6 +286,31 @@ class UniqueValidatorTest extends DoctrineOrmTestCase $this->assertEquals(0, $violationsList->count(), 'Violation is using custom repository method.'); } + public function testValidateUniquenessWithUnrewoundArray() + { + $entity = new SingleIdentEntity(1, 'foo'); + + $entityManagerName = 'foo'; + $repository = $this->createRepositoryMock(); + $repository->expects($this->once()) + ->method('findByCustom') + ->will( + $this->returnCallback(function() use ($entity) { + $returnValue = array( + $entity, + ); + next($returnValue); + return $returnValue; + }) + ) + ; + $em = $this->createEntityManagerMock($repository); + $validator = $this->createValidator($entityManagerName, $em, null, array(), null, 'findByCustom'); + + $violationsList = $validator->validate($entity); + $this->assertCount(0, $violationsList, 'Violation is using unrewound array as return value in the repository method.'); + } + /** * @group GH-1635 */ diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 52d2eab7eb..a2f91c6463 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -111,6 +111,8 @@ class UniqueEntityValidator extends ConstraintValidator */ if ($result instanceof \Iterator) { $result->rewind(); + } elseif (is_array($result)) { + reset($result); } /* If no entity matched the query criteria or a single entity matched, diff --git a/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php b/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php index 9d3b61f712..a9671cc815 100644 --- a/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php @@ -13,7 +13,7 @@ namespace Symfony\Bridge\Propel1\Form\DataTransformer; use \PropelObjectCollection; use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; +use Symfony\Component\Form\Exception\TransformationFailedException; /** * CollectionToArrayTransformer class. @@ -30,7 +30,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface } if (!$collection instanceof PropelObjectCollection) { - throw new UnexpectedTypeException($collection, '\PropelObjectCollection'); + throw new TransformationFailedException('Expected a \PropelObjectCollection.'); } return $collection->getData(); @@ -45,7 +45,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface } if (!is_array($array)) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } $collection->setData($array); diff --git a/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php b/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php index 625b74806e..13a9f7ffd6 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php +++ b/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php @@ -47,7 +47,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformThrowsExceptionIfNotPropelObjectCollection() { @@ -84,7 +84,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformThrowsExceptionIfNotArray() { diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php index b2875e9f4d..6890a9b839 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php @@ -73,5 +73,21 @@ class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase $style->setOptions(array('bold')); $this->assertEquals("\033[1mfoo\033[0m", $style->apply('foo')); + + try { + $style->setOption('foo'); + $this->fail('->setOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + $this->assertContains('Invalid option specified: "foo"', $e->getMessage(), '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } + + try { + $style->unsetOption('foo'); + $this->fail('->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + $this->assertContains('Invalid option specified: "foo"', $e->getMessage(), '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 9d6f5b031d..f8f6d8d82d 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -946,9 +946,20 @@ class ContainerBuilder extends Container implements TaggedContainerInterface /** * Returns service ids for a given tag. * + * Example: + * + * $container->register('foo')->addTag('my.tag', array('hello' => 'world')); + * + * $serviceIds = $container->findTaggedServiceIds('my.tag'); + * foreach ($serviceIds as $serviceId => $tags) { + * foreach ($tags as $tag) { + * echo $tag['hello']; + * } + * } + * * @param string $name The tag name * - * @return array An array of tags + * @return array An array of tags with the tagged service as key, holding a list of attribute arrays. * * @api */ @@ -956,7 +967,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface { $tags = array(); foreach ($this->getDefinitions() as $id => $definition) { - if ($definition->getTag($name)) { + if ($definition->hasTag($name)) { $tags[$id] = $definition->getTag($name); } } diff --git a/src/Symfony/Component/Form/DataTransformerInterface.php b/src/Symfony/Component/Form/DataTransformerInterface.php index 07183d54b3..432dd36295 100644 --- a/src/Symfony/Component/Form/DataTransformerInterface.php +++ b/src/Symfony/Component/Form/DataTransformerInterface.php @@ -14,7 +14,7 @@ namespace Symfony\Component\Form; /** * Transforms a value between different representations. * - * @author Bernhard Schussek + * @author Bernhard Schussek */ interface DataTransformerInterface { @@ -43,8 +43,7 @@ interface DataTransformerInterface * * @return mixed The value in the transformed representation * - * @throws UnexpectedTypeException when the argument is not a string - * @throws TransformationFailedException when the transformation fails + * @throws \Symfony\Component\Form\Exception\TransformationFailedException When the transformation fails. */ public function transform($value); @@ -70,8 +69,7 @@ interface DataTransformerInterface * * @return mixed The value in the original representation * - * @throws UnexpectedTypeException when the argument is not of the expected type - * @throws TransformationFailedException when the transformation fails + * @throws \Symfony\Component\Form\Exception\TransformationFailedException When the transformation fails. */ public function reverseTransform($value); } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php index da5737037f..fc080f25c1 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek @@ -34,7 +33,7 @@ class ArrayToPartsTransformer implements DataTransformerInterface } if (!is_array($array) ) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } $result = array(); @@ -53,7 +52,7 @@ class ArrayToPartsTransformer implements DataTransformerInterface public function reverseTransform($array) { if (!is_array($array) ) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } $result = array(); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php index e902d89e0c..95e7332d3e 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; +use Symfony\Component\Form\Exception\TransformationFailedException; /** * Transforms between a Boolean and a string. @@ -45,7 +45,7 @@ class BooleanToStringTransformer implements DataTransformerInterface * * @return string String value. * - * @throws UnexpectedTypeException if the given value is not a Boolean + * @throws TransformationFailedException If the given value is not a Boolean. */ public function transform($value) { @@ -54,7 +54,7 @@ class BooleanToStringTransformer implements DataTransformerInterface } if (!is_bool($value)) { - throw new UnexpectedTypeException($value, 'Boolean'); + throw new TransformationFailedException('Expected a Boolean.'); } return true === $value ? $this->trueValue : null; @@ -67,7 +67,7 @@ class BooleanToStringTransformer implements DataTransformerInterface * * @return Boolean Boolean value. * - * @throws UnexpectedTypeException if the given value is not a string + * @throws TransformationFailedException If the given value is not a string. */ public function reverseTransform($value) { @@ -76,7 +76,7 @@ class BooleanToStringTransformer implements DataTransformerInterface } if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); + throw new TransformationFailedException('Expected a string.'); } return true; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php index 7e6203c64d..b8aa95effc 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek @@ -42,12 +41,12 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface * as select tag, the value is not modified. * * @param mixed $choice An array if "multiple" is set to true, a scalar - * value otherwise. + * value otherwise. * * @return mixed An array * - * @throws UnexpectedTypeException if the given value is not scalar - * @throws TransformationFailedException if the choices can not be retrieved + * @throws TransformationFailedException If the given value is not scalar or + * if the choices can not be retrieved. */ public function transform($choice) { @@ -77,14 +76,15 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface * * @return mixed A scalar value * - * @throws UnexpectedTypeException if the given value is not an array - * @throws TransformationFailedException if the recuperation of the choices fails or - * if some choice can't be found + * @throws TransformationFailedException If the given value is not an array, + * if the recuperation of the choices + * fails or if some choice can't be + * found. */ public function reverseTransform($values) { if (!is_array($values)) { - throw new UnexpectedTypeException($values, 'array'); + throw new TransformationFailedException('Expected an array.'); } try { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php index dfab6ec454..887201ab6c 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; @@ -41,7 +40,7 @@ class ChoiceToValueTransformer implements DataTransformerInterface public function reverseTransform($value) { if (null !== $value && !is_scalar($value)) { - throw new UnexpectedTypeException($value, 'scalar'); + throw new TransformationFailedException('Expected a scalar.'); } // These are now valid ChoiceList values, so we can return null diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php index 9c3b6475d1..0c2ea3a394 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek @@ -40,8 +39,8 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface * * @return mixed An array * - * @throws UnexpectedTypeException if the given value is not an array - * @throws TransformationFailedException if the choices can not be retrieved + * @throws TransformationFailedException If the given value is not an array + * or if the choices can not be retrieved. */ public function transform($array) { @@ -50,7 +49,7 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface } if (!is_array($array)) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } try { @@ -79,14 +78,15 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface * * @return mixed An array * - * @throws UnexpectedTypeException if the given value is not an array - * @throws TransformationFailedException if the recuperation of the choices fails or - * if some choice can't be found + * @throws TransformationFailedException If the given value is not an array, + * if the recuperation of the choices + * fails or if some choice can't be + * found. */ public function reverseTransform($values) { if (!is_array($values)) { - throw new UnexpectedTypeException($values, 'array'); + throw new TransformationFailedException('Expected an array.'); } try { @@ -109,7 +109,9 @@ class ChoicesToBooleanArrayTransformer implements DataTransformerInterface } if (count($unknown) > 0) { - throw new TransformationFailedException('The choices "' . implode('", "', $unknown) . '" were not found'); + throw new TransformationFailedException( + sprintf('The choices "%s" were not found', implode('", "', $unknown)) + ); } return $result; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php index e72fcf097e..4492865e5a 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; /** @@ -39,7 +38,7 @@ class ChoicesToValuesTransformer implements DataTransformerInterface * * @return array * - * @throws UnexpectedTypeException if the given value is not an array + * @throws TransformationFailedException If the given value is not an array. */ public function transform($array) { @@ -48,7 +47,7 @@ class ChoicesToValuesTransformer implements DataTransformerInterface } if (!is_array($array)) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } return $this->choiceList->getValuesForChoices($array); @@ -59,8 +58,9 @@ class ChoicesToValuesTransformer implements DataTransformerInterface * * @return array * - * @throws UnexpectedTypeException if the given value is not an array - * @throws TransformationFailedException if could not find all matching choices for the given values + * @throws TransformationFailedException If the given value is not an array + * or if no matching choice could be + * found for some given value. */ public function reverseTransform($array) { @@ -69,7 +69,7 @@ class ChoicesToValuesTransformer implements DataTransformerInterface } if (!is_array($array)) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } $choices = $this->choiceList->getChoicesForValues($array); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php index e653de9e8f..c471b439f1 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php @@ -24,7 +24,7 @@ class DataTransformerChain implements DataTransformerInterface { /** * The value transformers - * @var array + * @var DataTransformerInterface[] */ protected $transformers; @@ -51,7 +51,6 @@ class DataTransformerChain implements DataTransformerInterface * @return mixed The transformed value * * @throws TransformationFailedException - * @throws UnexpectedTypeException */ public function transform($value) { @@ -76,7 +75,6 @@ class DataTransformerChain implements DataTransformerInterface * @return mixed The reverse-transformed value * * @throws TransformationFailedException - * @throws UnexpectedTypeException */ public function reverseTransform($value) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index 873a596586..eb4ebec9cd 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between a normalized time and a localized time string/array. @@ -34,7 +33,7 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer * @param array $fields The date fields * @param Boolean $pad Whether to use padding * - * @throws UnexpectedTypeException if a timezone is not a string + * @throws \Symfony\Component\Form\Exception\UnexpectedTypeException if a timezone is not a string */ public function __construct($inputTimezone = null, $outputTimezone = null, array $fields = null, $pad = false) { @@ -51,12 +50,13 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer /** * Transforms a normalized date into a localized date. * - * @param DateTime $dateTime Normalized date. + * @param \DateTime $dateTime Normalized date. * * @return array Localized date. * - * @throws UnexpectedTypeException if the given value is not an instance of \DateTime - * @throws TransformationFailedException if the output timezone is not supported + * @throws TransformationFailedException If the given value is not an + * instance of \DateTime or if the + * output timezone is not supported. */ public function transform($dateTime) { @@ -72,7 +72,7 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer } if (!$dateTime instanceof \DateTime) { - throw new UnexpectedTypeException($dateTime, '\DateTime'); + throw new TransformationFailedException('Expected a \DateTime.'); } $dateTime = clone $dateTime; @@ -108,11 +108,12 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer * * @param array $value Localized date * - * @return DateTime Normalized date + * @return \DateTime Normalized date * - * @throws UnexpectedTypeException if the given value is not an array - * @throws TransformationFailedException if the value could not be transformed - * @throws TransformationFailedException if the input timezone is not supported + * @throws TransformationFailedException If the given value is not an array, + * if the value could not be transformed + * or if the input timezone is not + * supported. */ public function reverseTransform($value) { @@ -121,7 +122,7 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer } if (!is_array($value)) { - throw new UnexpectedTypeException($value, 'array'); + throw new TransformationFailedException('Expected an array.'); } if ('' === implode('', $value)) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 673fd5fde2..bcf877beca 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -39,8 +39,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer * @param integer $calendar One of the \IntlDateFormatter calendar constants * @param string $pattern A pattern to pass to \IntlDateFormatter * - * @throws UnexpectedTypeException If a format is not supported - * @throws UnexpectedTypeException if a timezone is not a string + * @throws UnexpectedTypeException If a format is not supported or if a timezone is not a string */ public function __construct($inputTimezone = null, $outputTimezone = null, $dateFormat = null, $timeFormat = null, $calendar = \IntlDateFormatter::GREGORIAN, $pattern = null) { @@ -73,10 +72,11 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer * * @param \DateTime $dateTime Normalized date. * - * @return string|array Localized date string/array. + * @return string|array Localized date string/array. * - * @throws UnexpectedTypeException if the given value is not an instance of \DateTime - * @throws TransformationFailedException if the date could not be transformed + * @throws TransformationFailedException If the given value is not an instance + * of \DateTime or if the date could not + * be transformed. */ public function transform($dateTime) { @@ -85,7 +85,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer } if (!$dateTime instanceof \DateTime) { - throw new UnexpectedTypeException($dateTime, '\DateTime'); + throw new TransformationFailedException('Expected a \DateTime.'); } // convert time to UTC before passing it to the formatter @@ -110,14 +110,14 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer * * @return \DateTime Normalized date * - * @throws UnexpectedTypeException if the given value is not a string - * @throws TransformationFailedException if the date could not be parsed - * @throws TransformationFailedException if the input timezone is not supported + * @throws TransformationFailedException if the given value is not a string, + * if the date could not be parsed or + * if the input timezone is not supported */ public function reverseTransform($value) { if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); + throw new TransformationFailedException('Expected a string.'); } if ('' === $value) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php index 4b8a2b76ae..0eb0742277 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; -use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Exception\TransformationFailedException; /** @@ -29,7 +28,7 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer } if (!$dateTime instanceof \DateTime) { - throw new UnexpectedTypeException($dateTime, '\DateTime'); + throw new TransformationFailedException('Expected a \DateTime.'); } if ($this->inputTimezone !== $this->outputTimezone) { @@ -46,7 +45,7 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer public function reverseTransform($rfc3339) { if (!is_string($rfc3339)) { - throw new UnexpectedTypeException($rfc3339, 'string'); + throw new TransformationFailedException('Expected a string.'); } if ('' === $rfc3339) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index 811bbd296e..48c3dc2621 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between a date string and a DateTime object @@ -58,7 +57,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * @param string $format The date format * @param Boolean $parseUsingPipe Whether to parse by appending a pipe "|" to the parse format * - * @throws UnexpectedTypeException if a timezone is not a string + * @throws \Symfony\Component\Form\Exception\UnexpectedTypeException if a timezone is not a string */ public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = null) { @@ -93,8 +92,9 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * * @return string A value as produced by PHP's date() function * - * @throws UnexpectedTypeException if the given value is not a \DateTime instance - * @throws TransformationFailedException if the output timezone is not supported + * @throws TransformationFailedException If the given value is not a \DateTime + * instance or if the output timezone + * is not supported. */ public function transform($value) { @@ -103,7 +103,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer } if (!$value instanceof \DateTime) { - throw new UnexpectedTypeException($value, '\DateTime'); + throw new TransformationFailedException('Expected a \DateTime.'); } $value = clone $value; @@ -123,9 +123,9 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * * @return \DateTime An instance of \DateTime * - * @throws UnexpectedTypeException if the given value is not a string - * @throws TransformationFailedException if the date could not be parsed - * @throws TransformationFailedException if the input timezone is not supported + * @throws TransformationFailedException If the given value is not a string, + * if the date could not be parsed or + * if the input timezone is not supported. */ public function reverseTransform($value) { @@ -134,7 +134,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer } if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); + throw new TransformationFailedException('Expected a string.'); } try { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php index dff3c52083..d2ca6604db 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between a timestamp and a DateTime object @@ -25,12 +24,13 @@ class DateTimeToTimestampTransformer extends BaseDateTimeTransformer /** * Transforms a DateTime object into a timestamp in the configured timezone. * - * @param DateTime $value A DateTime object + * @param \DateTime $value A \DateTime object * * @return integer A timestamp * - * @throws UnexpectedTypeException if the given value is not an instance of \DateTime - * @throws TransformationFailedException if the output timezone is not supported + * @throws TransformationFailedException If the given value is not an instance + * of \DateTime or if the output + * timezone is not supported. */ public function transform($value) { @@ -39,7 +39,7 @@ class DateTimeToTimestampTransformer extends BaseDateTimeTransformer } if (!$value instanceof \DateTime) { - throw new UnexpectedTypeException($value, '\DateTime'); + throw new TransformationFailedException('Expected a \DateTime.'); } $value = clone $value; @@ -57,10 +57,10 @@ class DateTimeToTimestampTransformer extends BaseDateTimeTransformer * * @param string $value A timestamp * - * @return \DateTime An instance of \DateTime + * @return \DateTime A \DateTime object * - * @throws UnexpectedTypeException if the given value is not a timestamp - * @throws TransformationFailedException if the given timestamp is invalid + * @throws TransformationFailedException If the given value is not a timestamp + * or if the given timestamp is invalid. */ public function reverseTransform($value) { @@ -69,7 +69,7 @@ class DateTimeToTimestampTransformer extends BaseDateTimeTransformer } if (!is_numeric($value)) { - throw new UnexpectedTypeException($value, 'numeric'); + throw new TransformationFailedException('Expected a numeric.'); } try { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php index 4dd04af820..6bb48a9a03 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between an integer and a localized number with grouping @@ -28,7 +27,7 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo public function reverseTransform($value) { if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); + throw new TransformationFailedException('Expected a string.'); } if ('' === $value) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php index d3b5998b42..5b8e9d9664 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; -use Symfony\Component\Form\Exception\UnexpectedTypeException; +use Symfony\Component\Form\Exception\TransformationFailedException; /** * Transforms between a normalized format and a localized money string. @@ -50,14 +50,14 @@ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransform * * @return string Localized money string. * - * @throws UnexpectedTypeException if the given value is not numeric - * @throws TransformationFailedException 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 (!is_numeric($value)) { - throw new UnexpectedTypeException($value, 'numeric'); + throw new TransformationFailedException('Expected a numeric.'); } $value /= $this->divisor; @@ -73,8 +73,8 @@ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransform * * @return number Normalized number * - * @throws UnexpectedTypeException if the given value is not a string - * @throws TransformationFailedException 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) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 7c21249fad..689c74a94a 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * Transforms between a number type and a localized number with grouping @@ -60,8 +59,8 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface * * @return string Localized value. * - * @throws UnexpectedTypeException if the given value is not numeric - * @throws TransformationFailedException 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) { @@ -70,7 +69,7 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface } if (!is_numeric($value)) { - throw new UnexpectedTypeException($value, 'numeric'); + throw new TransformationFailedException('Expected a numeric.'); } $formatter = $this->getNumberFormatter(); @@ -93,13 +92,13 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface * * @return integer|float The numeric value * - * @throws UnexpectedTypeException if the given value is not a string - * @throws TransformationFailedException 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) { if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); + throw new TransformationFailedException('Expected a string.'); } if ('' === $value) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php index bbf66466a0..e099d436bf 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php @@ -70,8 +70,8 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface * * @return number Percentage value * - * @throws UnexpectedTypeException if the given value is not numeric - * @throws TransformationFailedException 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) { @@ -80,7 +80,7 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface } if (!is_numeric($value)) { - throw new UnexpectedTypeException($value, 'numeric'); + throw new TransformationFailedException('Expected a numeric.'); } if (self::FRACTIONAL == $this->type) { @@ -105,13 +105,13 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface * * @return number Normalized value. * - * @throws UnexpectedTypeException if the given value is not a string - * @throws TransformationFailedException 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) { if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); + throw new TransformationFailedException('Expected a string.'); } if ('' === $value) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php index 22fa01c39a..c34a0139fa 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; /** * @author Bernhard Schussek @@ -52,13 +51,13 @@ class ValueToDuplicatesTransformer implements DataTransformerInterface * * @return mixed The value * - * @throws UnexpectedTypeException if the given value is not an array - * @throws TransformationFailedException 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) { if (!is_array($array)) { - throw new UnexpectedTypeException($array, 'array'); + throw new TransformationFailedException('Expected an array.'); } $result = current($array); diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 167fcd95e9..c19dc9a949 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -175,7 +175,7 @@ class FormValidator extends ConstraintValidator $groups = $form->getConfig()->getOption('validation_groups'); if (null !== $groups) { - if (is_callable($groups)) { + if (!is_string($groups) && is_callable($groups)) { $groups = call_user_func($groups, $form); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php index 4d449cf873..bafe5c098f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php @@ -68,7 +68,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformRequiresArray() { @@ -140,7 +140,7 @@ class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformRequiresArray() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php index cabdf76f2b..41f8f956d7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php @@ -38,14 +38,14 @@ class BooleanToStringTransformerTest extends \PHPUnit_Framework_TestCase public function testTransformExpectsBoolean() { - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->transformer->transform('1'); } public function testReverseTransformExpectsString() { - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $this->transformer->reverseTransform(1); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php index ec551e1cd1..bbae0621ce 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php @@ -67,7 +67,7 @@ class ChoiceToValueTransformerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformExpectsScalar() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php index 0abbd7b7eb..572971938d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php @@ -45,7 +45,7 @@ class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformExpectsArray() { @@ -67,7 +67,7 @@ class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformExpectsArray() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php index 5d0ae58fdd..4898b88d34 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php @@ -117,7 +117,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformRequiresDateTime() { @@ -326,7 +326,7 @@ class DateTimeToArrayTransformerTest extends DateTimeTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformRequiresArray() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index 25d582cfcb..afa979e2a8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -148,7 +148,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformRequiresValidDateTime() { @@ -231,7 +231,7 @@ class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformRequiresString() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php index 1f6bd0b822..f550d4bd20 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -79,7 +79,7 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformRequiresValidDateTime() { @@ -102,7 +102,7 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformRequiresString() { @@ -121,7 +121,7 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase } /** - * @expectedException Symfony\Component\Form\Exception\TransformationFailedException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformExpectsValidDateString() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index 18137fef04..987df1d81c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -101,7 +101,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase { $transformer = new DateTimeToStringTransformer(); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer->transform('1234'); } @@ -156,7 +156,7 @@ class DateTimeToStringTransformerTest extends DateTimeTestCase { $reverseTransformer = new DateTimeToStringTransformer(); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $reverseTransformer->reverseTransform(1234); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php index 5c4be26f54..b54f0c4c50 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php @@ -60,7 +60,7 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase { $transformer = new DateTimeToTimestampTransformer(); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer->transform('1234'); } @@ -97,7 +97,7 @@ class DateTimeToTimestampTransformerTest extends DateTimeTestCase { $reverseTransformer = new DateTimeToTimestampTransformer(); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $reverseTransformer->reverseTransform('2010-2010-2010'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index d099cde910..999c4272c5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -50,7 +50,7 @@ class IntegerToLocalizedStringTransformerTest extends LocalizedTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformExpectsString() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php index 8ff5c16ac0..843ad32fc5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -33,7 +33,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase { $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer->transform('abcd'); } @@ -56,7 +56,7 @@ class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase { $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer->reverseTransform(12345); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 09af7243d6..1062ce1ec6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -248,7 +248,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testTransformExpectsNumeric() { @@ -258,7 +258,7 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformExpectsString() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php index 6cbca5a402..07bf26766e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php @@ -94,7 +94,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase { $transformer = new PercentToLocalizedStringTransformer(); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer->transform('foo'); } @@ -103,7 +103,7 @@ class PercentToLocalizedStringTransformerTest extends LocalizedTestCase { $transformer = new PercentToLocalizedStringTransformer(); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); + $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); $transformer->reverseTransform(1); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php index f2d8f94ccd..2c5298da50 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php @@ -111,7 +111,7 @@ class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ public function testReverseTransformRequiresArray() { diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index a3d9f26d98..48f6123426 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -291,6 +291,24 @@ class FormValidatorTest extends \PHPUnit_Framework_TestCase $this->validator->validate($form, new Form()); } + public function testDontExecuteFunctionNames() + { + $context = $this->getExecutionContext(); + $graphWalker = $context->getGraphWalker(); + $object = $this->getMock('\stdClass'); + $options = array('validation_groups' => 'header'); + $form = $this->getBuilder('name', '\stdClass', $options) + ->setData($object) + ->getForm(); + + $graphWalker->expects($this->once()) + ->method('walkReference') + ->with($object, 'header', 'data', true); + + $this->validator->initialize($context); + $this->validator->validate($form, new Form()); + } + public function testHandleClosureValidationGroups() { $context = $this->getMockExecutionContext(); diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php index d7e46cf2b2..c6e47d083b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php @@ -47,7 +47,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface } /** - * Handles X509 authentication. + * Handles pre-authentication. * * @param GetResponseEvent $event A GetResponseEvent instance */ @@ -62,7 +62,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface list($user, $credentials) = $this->getPreAuthenticatedData($request); if (null !== $token = $this->securityContext->getToken()) { - if ($token instanceof PreAuthenticatedToken && $token->isAuthenticated() && $token->getUsername() === $user) { + if ($token instanceof PreAuthenticatedToken && $this->providerKey == $token->getProviderKey() && $token->isAuthenticated() && $token->getUsername() === $user) { return; } } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml index 73398bd48b..946200ba11 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/constraint-mapping.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> Symfony\Component\Validator\Tests\Fixtures\ diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml b/src/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml index 0c5e890cbd..0beacc32cd 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/withdoctype.xml @@ -2,6 +2,6 @@ + xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">