Merge branch '3.1' into 3.2
* 3.1: fixed typo fixed composer.json always check for all fields to be mapped clarify exception when no args are configured [PropertyAccess] Handle interfaces in the invalid argument exception [DI] Fix defaults overriding empty strings in AutowirePass [Debug] Workaround "null" $context [Debug] Remove $context arg from handleError(), preparing for PHP 7.2 [Routing] Fix BC break in AnnotationClassLoader defaults attributes handling Fix tests with ICU 57.1 Fix the condition checking the minimum ICU version
This commit is contained in:
commit
09d5f4eb72
|
@ -90,7 +90,8 @@
|
||||||
"symfony/phpunit-bridge": "~3.2",
|
"symfony/phpunit-bridge": "~3.2",
|
||||||
"symfony/polyfill-apcu": "~1.1",
|
"symfony/polyfill-apcu": "~1.1",
|
||||||
"symfony/security-acl": "~2.8|~3.0",
|
"symfony/security-acl": "~2.8|~3.0",
|
||||||
"phpdocumentor/reflection-docblock": "^3.0"
|
"phpdocumentor/reflection-docblock": "^3.0",
|
||||||
|
"sensio/framework-extra-bundle": "^3.0.2"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"phpdocumentor/reflection-docblock": "<3.0",
|
"phpdocumentor/reflection-docblock": "<3.0",
|
||||||
|
|
|
@ -264,6 +264,23 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest
|
||||||
->assertRaised();
|
->assertRaised();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||||
|
*/
|
||||||
|
public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled()
|
||||||
|
{
|
||||||
|
$constraint = new UniqueEntity(array(
|
||||||
|
'message' => 'myMessage',
|
||||||
|
'fields' => array('name', 'name2'),
|
||||||
|
'em' => self::EM_NAME,
|
||||||
|
'ignoreNull' => true,
|
||||||
|
));
|
||||||
|
|
||||||
|
$entity1 = new SingleIntIdEntity(1, null);
|
||||||
|
|
||||||
|
$this->validator->validate($entity1, $constraint);
|
||||||
|
}
|
||||||
|
|
||||||
public function testValidateUniquenessWithValidCustomErrorPath()
|
public function testValidateUniquenessWithValidCustomErrorPath()
|
||||||
{
|
{
|
||||||
$constraint = new UniqueEntity(array(
|
$constraint = new UniqueEntity(array(
|
||||||
|
|
|
@ -86,12 +86,14 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||||
throw new ConstraintDefinitionException(sprintf('The field "%s" is not mapped by Doctrine, so it cannot be validated for uniqueness.', $fieldName));
|
throw new ConstraintDefinitionException(sprintf('The field "%s" is not mapped by Doctrine, so it cannot be validated for uniqueness.', $fieldName));
|
||||||
}
|
}
|
||||||
|
|
||||||
$criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);
|
$fieldValue = $class->reflFields[$fieldName]->getValue($entity);
|
||||||
|
|
||||||
if ($constraint->ignoreNull && null === $criteria[$fieldName]) {
|
if ($constraint->ignoreNull && null === $fieldValue) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$criteria[$fieldName] = $fieldValue;
|
||||||
|
|
||||||
if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
|
if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
|
||||||
/* Ensure the Proxy is initialized before using reflection to
|
/* Ensure the Proxy is initialized before using reflection to
|
||||||
* read its identifiers. This is necessary because the wrapped
|
* read its identifiers. This is necessary because the wrapped
|
||||||
|
@ -101,6 +103,12 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip validation if there are no criteria (this can happen when the
|
||||||
|
// "ignoreNull" option is enabled and fields to be checked are null
|
||||||
|
if (empty($criteria)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $constraint->entityClass) {
|
if (null !== $constraint->entityClass) {
|
||||||
/* Retrieve repository from given entity name.
|
/* Retrieve repository from given entity name.
|
||||||
* We ensure the retrieved repository can handle the entity
|
* We ensure the retrieved repository can handle the entity
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
||||||
|
|
||||||
|
class AnnotatedControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider getRoutes
|
||||||
|
*/
|
||||||
|
public function testAnnotatedController($path, $expectedValue)
|
||||||
|
{
|
||||||
|
$client = $this->createClient(array('test_case' => 'AnnotatedController', 'root_config' => 'config.yml'));
|
||||||
|
$client->request('GET', '/annotated'.$path);
|
||||||
|
|
||||||
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||||
|
$this->assertSame($expectedValue, $client->getResponse()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRoutes()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('/null_request', 'Symfony\Component\HttpFoundation\Request'),
|
||||||
|
array('/null_argument', ''),
|
||||||
|
array('/null_argument_with_route_param', ''),
|
||||||
|
array('/null_argument_with_route_param/value', 'value'),
|
||||||
|
array('/argument_with_route_param_and_default', 'value'),
|
||||||
|
array('/argument_with_route_param_and_default/custom', 'custom'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
class AnnotatedController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Route("/null_request", name="null_request")
|
||||||
|
*/
|
||||||
|
public function requestDefaultNullAction(Request $request = null)
|
||||||
|
{
|
||||||
|
return new Response($request ? get_class($request) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/null_argument", name="null_argument")
|
||||||
|
*/
|
||||||
|
public function argumentDefaultNullWithoutRouteParamAction($value = null)
|
||||||
|
{
|
||||||
|
return new Response($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/null_argument_with_route_param/{value}", name="null_argument_with_route_param")
|
||||||
|
*/
|
||||||
|
public function argumentDefaultNullWithRouteParamAction($value = null)
|
||||||
|
{
|
||||||
|
return new Response($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/argument_with_route_param_and_default/{value}", defaults={"value": "value"}, name="argument_with_route_param_and_default")
|
||||||
|
*/
|
||||||
|
public function argumentWithoutDefaultWithRouteParamAndDefaultAction($value)
|
||||||
|
{
|
||||||
|
return new Response($value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
|
||||||
|
|
||||||
|
return array(
|
||||||
|
new FrameworkBundle(),
|
||||||
|
new TestBundle(),
|
||||||
|
new SensioFrameworkExtraBundle(),
|
||||||
|
);
|
|
@ -0,0 +1,2 @@
|
||||||
|
imports:
|
||||||
|
- { resource: ../config/default.yml }
|
|
@ -0,0 +1,4 @@
|
||||||
|
annotated_controller:
|
||||||
|
prefix: /annotated
|
||||||
|
resource: "@TestBundle/Controller/AnnotatedController.php"
|
||||||
|
type: annotation
|
|
@ -27,7 +27,9 @@
|
||||||
"symfony/polyfill-mbstring": "~1.0",
|
"symfony/polyfill-mbstring": "~1.0",
|
||||||
"symfony/filesystem": "~2.8|~3.0",
|
"symfony/filesystem": "~2.8|~3.0",
|
||||||
"symfony/finder": "~2.8|~3.0",
|
"symfony/finder": "~2.8|~3.0",
|
||||||
"symfony/routing": "~3.0",
|
"symfony/routing": "~3.1.10|~3.2.3",
|
||||||
|
"symfony/security-core": "~2.8|~3.0",
|
||||||
|
"symfony/security-csrf": "~2.8|~3.0",
|
||||||
"symfony/stopwatch": "~2.8|~3.0",
|
"symfony/stopwatch": "~2.8|~3.0",
|
||||||
"doctrine/cache": "~1.0"
|
"doctrine/cache": "~1.0"
|
||||||
},
|
},
|
||||||
|
@ -52,7 +54,8 @@
|
||||||
"symfony/property-info": "~2.8|~3.0",
|
"symfony/property-info": "~2.8|~3.0",
|
||||||
"doctrine/annotations": "~1.0",
|
"doctrine/annotations": "~1.0",
|
||||||
"phpdocumentor/reflection-docblock": "^3.0",
|
"phpdocumentor/reflection-docblock": "^3.0",
|
||||||
"twig/twig": "~1.26|~2.0"
|
"twig/twig": "~1.26|~2.0",
|
||||||
|
"sensio/framework-extra-bundle": "^3.0.2"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"phpdocumentor/reflection-docblock": "<3.0",
|
"phpdocumentor/reflection-docblock": "<3.0",
|
||||||
|
|
|
@ -352,12 +352,10 @@ class ErrorHandler
|
||||||
/**
|
/**
|
||||||
* Handles errors by filtering then logging them according to the configured bit fields.
|
* Handles errors by filtering then logging them according to the configured bit fields.
|
||||||
*
|
*
|
||||||
* @param int $type One of the E_* constants
|
* @param int $type One of the E_* constants
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @param int $line
|
* @param int $line
|
||||||
* @param array $context
|
|
||||||
* @param array $backtrace
|
|
||||||
*
|
*
|
||||||
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
|
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
|
||||||
*
|
*
|
||||||
|
@ -365,7 +363,7 @@ class ErrorHandler
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function handleError($type, $message, $file, $line, array $context, array $backtrace = null)
|
public function handleError($type, $message, $file, $line)
|
||||||
{
|
{
|
||||||
// Level is the current error reporting level to manage silent error.
|
// Level is the current error reporting level to manage silent error.
|
||||||
// Strong errors are not authorized to be silenced.
|
// Strong errors are not authorized to be silenced.
|
||||||
|
@ -377,9 +375,20 @@ class ErrorHandler
|
||||||
if (!$type || (!$log && !$throw)) {
|
if (!$type || (!$log && !$throw)) {
|
||||||
return $type && $log;
|
return $type && $log;
|
||||||
}
|
}
|
||||||
|
$scope = $this->scopedErrors & $type;
|
||||||
|
|
||||||
if (isset($context['GLOBALS']) && ($this->scopedErrors & $type)) {
|
if (4 < $numArgs = func_num_args()) {
|
||||||
unset($context['GLOBALS']);
|
$context = $scope ? (func_get_arg(4) ?: array()) : array();
|
||||||
|
$backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM
|
||||||
|
} else {
|
||||||
|
$context = array();
|
||||||
|
$backtrace = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($context['GLOBALS']) && $scope) {
|
||||||
|
$e = $context; // Whatever the signature of the method,
|
||||||
|
unset($e['GLOBALS'], $context); // $context is always a reference in 5.3
|
||||||
|
$context = $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $backtrace && $type & E_ERROR) {
|
if (null !== $backtrace && $type & E_ERROR) {
|
||||||
|
@ -399,7 +408,7 @@ class ErrorHandler
|
||||||
} elseif (!$throw && !($type & $level)) {
|
} elseif (!$throw && !($type & $level)) {
|
||||||
$errorAsException = new SilencedErrorContext($type, $file, $line);
|
$errorAsException = new SilencedErrorContext($type, $file, $line);
|
||||||
} else {
|
} else {
|
||||||
if ($this->scopedErrors & $type) {
|
if ($scope) {
|
||||||
$errorAsException = new ContextErrorException($logMessage, 0, $type, $file, $line, $context);
|
$errorAsException = new ContextErrorException($logMessage, 0, $type, $file, $line, $context);
|
||||||
} else {
|
} else {
|
||||||
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
|
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
|
||||||
|
|
|
@ -114,8 +114,10 @@ class AutowirePass implements CompilerPassInterface
|
||||||
throw new RuntimeException(sprintf('Unable to autowire argument index %d ($%s) for the service "%s". If this is an object, give it a type-hint. Otherwise, specify this argument\'s value explicitly.', $index, $parameter->name, $id));
|
throw new RuntimeException(sprintf('Unable to autowire argument index %d ($%s) for the service "%s". If this is an object, give it a type-hint. Otherwise, specify this argument\'s value explicitly.', $index, $parameter->name, $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// specifically pass the default value
|
if (!array_key_exists($index, $arguments)) {
|
||||||
$arguments[$index] = $parameter->getDefaultValue();
|
// specifically pass the default value
|
||||||
|
$arguments[$index] = $parameter->getDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,10 @@ class Definition
|
||||||
*/
|
*/
|
||||||
public function replaceArgument($index, $argument)
|
public function replaceArgument($index, $argument)
|
||||||
{
|
{
|
||||||
|
if (0 === count($this->arguments)) {
|
||||||
|
throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
|
||||||
|
}
|
||||||
|
|
||||||
if ($index < 0 || $index > count($this->arguments) - 1) {
|
if ($index < 0 || $index > count($this->arguments) - 1) {
|
||||||
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
|
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, count($this->arguments) - 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,6 +494,22 @@ class AutowirePassTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertTrue($container->hasDefinition('bar'));
|
$this->assertTrue($container->hasDefinition('bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmptyStringIsKept()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
$container->register('a', __NAMESPACE__.'\A');
|
||||||
|
$container->register('lille', __NAMESPACE__.'\Lille');
|
||||||
|
$container->register('foo', __NAMESPACE__.'\MultipleArgumentsOptionalScalar')
|
||||||
|
->setAutowired(true)
|
||||||
|
->setArguments(array('', ''));
|
||||||
|
|
||||||
|
$pass = new AutowirePass();
|
||||||
|
$pass->process($container);
|
||||||
|
|
||||||
|
$this->assertEquals(array(new Reference('a'), '', new Reference('lille')), $container->getDefinition('foo')->getArguments());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Foo
|
class Foo
|
||||||
|
|
|
@ -257,6 +257,7 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \OutOfBoundsException
|
* @expectedException \OutOfBoundsException
|
||||||
|
* @expectedExceptionMessage The index "1" is not in the range [0, 0].
|
||||||
*/
|
*/
|
||||||
public function testReplaceArgumentShouldCheckBounds()
|
public function testReplaceArgumentShouldCheckBounds()
|
||||||
{
|
{
|
||||||
|
@ -266,6 +267,16 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||||
$def->replaceArgument(1, 'bar');
|
$def->replaceArgument(1, 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \OutOfBoundsException
|
||||||
|
* @expectedExceptionMessage Cannot replace arguments if none have been configured yet.
|
||||||
|
*/
|
||||||
|
public function testReplaceArgumentWithoutExistingArgumentsShouldCheckBounds()
|
||||||
|
{
|
||||||
|
$def = new Definition('stdClass');
|
||||||
|
$def->replaceArgument(0, 'bar');
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetGetProperties()
|
public function testSetGetProperties()
|
||||||
{
|
{
|
||||||
$def = new Definition('stdClass');
|
$def = new Definition('stdClass');
|
||||||
|
|
|
@ -69,10 +69,10 @@ class DateTypeTest extends TestCase
|
||||||
|
|
||||||
public function testSubmitFromSingleTextDateTime()
|
public function testSubmitFromSingleTextDateTime()
|
||||||
{
|
{
|
||||||
// we test against "de_AT", so we need the full implementation
|
// we test against "de_DE", so we need the full implementation
|
||||||
IntlTestHelper::requireFullIntl($this, false);
|
IntlTestHelper::requireFullIntl($this, false);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
@ -90,10 +90,10 @@ class DateTypeTest extends TestCase
|
||||||
|
|
||||||
public function testSubmitFromSingleTextString()
|
public function testSubmitFromSingleTextString()
|
||||||
{
|
{
|
||||||
// we test against "de_AT", so we need the full implementation
|
// we test against "de_DE", so we need the full implementation
|
||||||
IntlTestHelper::requireFullIntl($this, false);
|
IntlTestHelper::requireFullIntl($this, false);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
@ -111,10 +111,10 @@ class DateTypeTest extends TestCase
|
||||||
|
|
||||||
public function testSubmitFromSingleTextTimestamp()
|
public function testSubmitFromSingleTextTimestamp()
|
||||||
{
|
{
|
||||||
// we test against "de_AT", so we need the full implementation
|
// we test against "de_DE", so we need the full implementation
|
||||||
IntlTestHelper::requireFullIntl($this, false);
|
IntlTestHelper::requireFullIntl($this, false);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
@ -134,10 +134,10 @@ class DateTypeTest extends TestCase
|
||||||
|
|
||||||
public function testSubmitFromSingleTextRaw()
|
public function testSubmitFromSingleTextRaw()
|
||||||
{
|
{
|
||||||
// we test against "de_AT", so we need the full implementation
|
// we test against "de_DE", so we need the full implementation
|
||||||
IntlTestHelper::requireFullIntl($this, false);
|
IntlTestHelper::requireFullIntl($this, false);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
@ -398,10 +398,10 @@ class DateTypeTest extends TestCase
|
||||||
|
|
||||||
public function testSetDataWithNegativeTimezoneOffsetStringInput()
|
public function testSetDataWithNegativeTimezoneOffsetStringInput()
|
||||||
{
|
{
|
||||||
// we test against "de_AT", so we need the full implementation
|
// we test against "de_DE", so we need the full implementation
|
||||||
IntlTestHelper::requireFullIntl($this, false);
|
IntlTestHelper::requireFullIntl($this, false);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
@ -420,10 +420,10 @@ class DateTypeTest extends TestCase
|
||||||
|
|
||||||
public function testSetDataWithNegativeTimezoneOffsetDateTimeInput()
|
public function testSetDataWithNegativeTimezoneOffsetDateTimeInput()
|
||||||
{
|
{
|
||||||
// we test against "de_AT", so we need the full implementation
|
// we test against "de_DE", so we need the full implementation
|
||||||
IntlTestHelper::requireFullIntl($this, false);
|
IntlTestHelper::requireFullIntl($this, false);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_DE');
|
||||||
|
|
||||||
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
$form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\DateType', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
|
|
|
@ -41,7 +41,7 @@ class IntlTestHelper
|
||||||
// * the intl extension is loaded with version Intl::getIcuStubVersion()
|
// * the intl extension is loaded with version Intl::getIcuStubVersion()
|
||||||
// * the intl extension is not loaded
|
// * the intl extension is not loaded
|
||||||
|
|
||||||
if (($minimumIcuVersion || defined('HHVM_VERSION_ID')) && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '!=', 1)) {
|
if (($minimumIcuVersion || defined('HHVM_VERSION_ID')) && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '<', 1)) {
|
||||||
$testCase->markTestSkipped('ICU version '.$minimumIcuVersion.' is required.');
|
$testCase->markTestSkipped('ICU version '.$minimumIcuVersion.' is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ class PropertyAccessor implements PropertyAccessorInterface
|
||||||
private static function throwInvalidArgumentException($message, $trace, $i)
|
private static function throwInvalidArgumentException($message, $trace, $i)
|
||||||
{
|
{
|
||||||
if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file']) {
|
if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file']) {
|
||||||
$pos = strpos($message, $delim = 'must be of the type ') ?: strpos($message, $delim = 'must be an instance of ');
|
$pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface '));
|
||||||
$pos += strlen($delim);
|
$pos += strlen($delim);
|
||||||
$type = $trace[$i]['args'][0];
|
$type = $trace[$i]['args'][0];
|
||||||
$type = is_object($type) ? get_class($type) : gettype($type);
|
$type = is_object($type) ? get_class($type) : gettype($type);
|
||||||
|
|
|
@ -18,6 +18,11 @@ class TypeHinted
|
||||||
{
|
{
|
||||||
private $date;
|
private $date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Countable
|
||||||
|
*/
|
||||||
|
private $countable;
|
||||||
|
|
||||||
public function setDate(\DateTime $date)
|
public function setDate(\DateTime $date)
|
||||||
{
|
{
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
|
@ -27,4 +32,20 @@ class TypeHinted
|
||||||
{
|
{
|
||||||
return $this->date;
|
return $this->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Countable
|
||||||
|
*/
|
||||||
|
public function getCountable()
|
||||||
|
{
|
||||||
|
return $this->countable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Countable $countable
|
||||||
|
*/
|
||||||
|
public function setCountable(\Countable $countable)
|
||||||
|
{
|
||||||
|
$this->countable = $countable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -566,4 +566,15 @@ class PropertyAccessorTest extends \PHPUnit_Framework_TestCase
|
||||||
$propertyAccessor->setValue($obj, 'publicGetSetter', 'baz');
|
$propertyAccessor->setValue($obj, 'publicGetSetter', 'baz');
|
||||||
$this->assertEquals('baz', $propertyAccessor->getValue($obj, 'publicGetSetter'));
|
$this->assertEquals('baz', $propertyAccessor->getValue($obj, 'publicGetSetter'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidArgumentException
|
||||||
|
* @expectedExceptionMessage Expected argument of type "Countable", "string" given
|
||||||
|
*/
|
||||||
|
public function testThrowTypeErrorWithInterface()
|
||||||
|
{
|
||||||
|
$object = new TypeHinted();
|
||||||
|
|
||||||
|
$this->propertyAccessor->setValue($object, 'countable', 'This is a string, \Countable expected.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,11 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
|
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
|
||||||
|
foreach ($method->getParameters() as $param) {
|
||||||
|
if (false !== strpos($globals['path'].$annot->getPath(), sprintf('{%s}', $param->getName())) && !isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
|
||||||
|
$defaults[$param->getName()] = $param->getDefaultValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
$requirements = array_replace($globals['requirements'], $annot->getRequirements());
|
$requirements = array_replace($globals['requirements'], $annot->getRequirements());
|
||||||
$options = array_replace($globals['options'], $annot->getOptions());
|
$options = array_replace($globals['options'], $annot->getOptions());
|
||||||
$schemes = array_merge($globals['schemes'], $annot->getSchemes());
|
$schemes = array_merge($globals['schemes'], $annot->getSchemes());
|
||||||
|
|
Reference in New Issue