Merge branch '2.7'
* 2.7: fixed tests [EventDispatcher] Add missing checks to RegisterListenersPass Inline private 'is quoting required' methods in Escaper [HttpKernel] Add request uri to Logger context removed notices for some constants as it does not work well [Debug] fix loading order for legacy classes Add comment as requested Remove duplicate 'require' [Yaml] Improve YAML boolean escaping
This commit is contained in:
commit
d5df960022
@ -9,9 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Debug\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
|
||||
namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
/**
|
||||
* Fatal Error Exception.
|
||||
@ -19,21 +17,23 @@ use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErr
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Konstanton Myakshin <koc-dp@yandex.ru>
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FatalErrorException extends LegacyFatalErrorException
|
||||
class FatalErrorException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Exception;
|
||||
namespace Symfony\Component\Debug\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
|
||||
|
||||
/**
|
||||
* Fatal Error Exception.
|
||||
*
|
||||
* @author Konstanton Myakshin <koc-dp@yandex.ru>
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FatalErrorException extends \ErrorException
|
||||
class FatalErrorException extends LegacyFatalErrorException
|
||||
{
|
||||
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true)
|
||||
{
|
||||
|
@ -9,6 +9,46 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
|
||||
|
||||
/**
|
||||
* FlattenException wraps a PHP Exception to be able to serialize it.
|
||||
*
|
||||
* Basically, this class removes all objects from the trace.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FlattenException
|
||||
{
|
||||
private $handler;
|
||||
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method));
|
||||
}
|
||||
|
||||
return call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
|
||||
}
|
||||
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!isset($this->handler)) {
|
||||
$this->handler = new DebugFlattenException();
|
||||
}
|
||||
|
||||
if (!method_exists($this->handler, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method));
|
||||
}
|
||||
|
||||
return call_user_func_array(array($this->handler, $method), $args);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Symfony\Component\Debug\Exception;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
|
||||
@ -250,35 +290,3 @@ class FlattenException extends LegacyFlattenException
|
||||
return $array['__PHP_Incomplete_Class_Name'];
|
||||
}
|
||||
}
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Exception;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
|
||||
|
||||
/**
|
||||
* FlattenException wraps a PHP Exception to be able to serialize it.
|
||||
*
|
||||
* Basically, this class removes all objects from the trace.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
|
||||
*/
|
||||
class FlattenException
|
||||
{
|
||||
private $handler;
|
||||
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
return forward_static_call_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
|
||||
}
|
||||
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!isset($this->handler)) {
|
||||
$this->handler = new DebugFlattenException();
|
||||
}
|
||||
|
||||
return call_user_func_array(array($this->handler, $method), $args);
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,12 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id));
|
||||
}
|
||||
|
||||
if ($def->isAbstract()) {
|
||||
throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event subscribers are lazy-loaded.', $id));
|
||||
}
|
||||
|
||||
// We must assume that the class value has been correctly filled, even if the service is created by a factory
|
||||
$class = $def->getClass();
|
||||
$class = $container->getParameterBag()->resolveValue($def->getClass());
|
||||
|
||||
$refClass = new \ReflectionClass($class);
|
||||
$interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface';
|
||||
|
@ -138,6 +138,58 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
|
||||
$registerListenersPass = new RegisterListenersPass();
|
||||
$registerListenersPass->process($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded.
|
||||
*/
|
||||
public function testAbstractEventSubscriber()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', array());
|
||||
$container->register('event_dispatcher', 'stdClass');
|
||||
|
||||
$registerListenersPass = new RegisterListenersPass();
|
||||
$registerListenersPass->process($container);
|
||||
}
|
||||
|
||||
public function testEventSubscriberResolvableClassName()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$container->setParameter('subscriber.class', 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService');
|
||||
$container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array());
|
||||
$container->register('event_dispatcher', 'stdClass');
|
||||
|
||||
$registerListenersPass = new RegisterListenersPass();
|
||||
$registerListenersPass->process($container);
|
||||
|
||||
$definition = $container->getDefinition('event_dispatcher');
|
||||
$expected_calls = array(
|
||||
array(
|
||||
'addSubscriberService',
|
||||
array(
|
||||
'foo',
|
||||
'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService',
|
||||
),
|
||||
),
|
||||
);
|
||||
$this->assertSame($expected_calls, $definition->getMethodCalls());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class"
|
||||
*/
|
||||
public function testEventSubscriberUnresolvableClassName()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array());
|
||||
$container->register('event_dispatcher', 'stdClass');
|
||||
|
||||
$registerListenersPass = new RegisterListenersPass();
|
||||
$registerListenersPass->process($container);
|
||||
}
|
||||
}
|
||||
|
||||
class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
|
||||
|
@ -1,29 +0,0 @@
|
||||
<?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\Component\Form\Deprecated;
|
||||
|
||||
trigger_error('Constants ROUND_HALFEVEN, ROUND_HALFUP and ROUND_HALFDOWN in class NumberToLocalizedStringTransformer are deprecated since version 2.4 and will be removed in 3.0. Use ROUND_HALF_EVEN, ROUND_HALF_UP and ROUND_HALF_DOWN instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.7, to be removed in 3.0.
|
||||
* @internal
|
||||
*/
|
||||
final class NumberToLocalizedStringTransformer
|
||||
{
|
||||
const ROUND_HALFEVEN = \NumberFormatter::ROUND_HALFEVEN;
|
||||
const ROUND_HALFUP = \NumberFormatter::ROUND_HALFUP;
|
||||
const ROUND_HALFDOWN = \NumberFormatter::ROUND_HALFDOWN;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
@ -78,21 +78,21 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
*/
|
||||
const ROUND_HALFEVEN = Deprecated::ROUND_HALFEVEN;
|
||||
const ROUND_HALFEVEN = \NumberFormatter::ROUND_HALFEVEN;
|
||||
|
||||
/**
|
||||
* Alias for {@link self::ROUND_HALF_UP}.
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
*/
|
||||
const ROUND_HALFUP = Deprecated::ROUND_HALFUP;
|
||||
const ROUND_HALFUP = \NumberFormatter::ROUND_HALFUP;
|
||||
|
||||
/**
|
||||
* Alias for {@link self::ROUND_HALF_DOWN}.
|
||||
*
|
||||
* @deprecated since version 2.4, to be removed in 3.0.
|
||||
*/
|
||||
const ROUND_HALFDOWN = Deprecated::ROUND_HALFDOWN;
|
||||
const ROUND_HALFDOWN = \NumberFormatter::ROUND_HALFDOWN;
|
||||
|
||||
protected $precision;
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?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\Component\Form\Extension\Validator\Constraints\Deprecated;
|
||||
|
||||
trigger_error('Constant ERR_INVALID in class Symfony\Component\Form\Extension\Validator\Constraints\Form is deprecated since version 2.6 and will be removed in 3.0. Use NOT_SYNCHRONIZED_ERROR constant instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.7, to be removed in 3.0.
|
||||
* @internal
|
||||
*/
|
||||
final class Form
|
||||
{
|
||||
const ERR_INVALID = 1;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ class Form extends Constraint
|
||||
* @deprecated since version 2.6, to be removed in 3.0.
|
||||
* Use {@self NOT_SYNCHRONIZED_ERROR} instead.
|
||||
*/
|
||||
const ERR_INVALID = Deprecated::ERR_INVALID;
|
||||
const ERR_INVALID = 1;
|
||||
|
||||
protected static $errorNames = array(
|
||||
self::NOT_SYNCHRONIZED_ERROR => 'NOT_SYNCHRONIZED_ERROR',
|
||||
|
@ -140,7 +140,10 @@ class RouterListener implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info(sprintf('Matched route "%s"', $parameters['_route']), $parameters);
|
||||
$this->logger->info(sprintf('Matched route "%s"', $parameters['_route']), array(
|
||||
'route_parameters' => $parameters,
|
||||
'request_uri' => $request->getUri(),
|
||||
));
|
||||
}
|
||||
|
||||
$request->attributes->add($parameters);
|
||||
|
@ -72,7 +72,15 @@ class Escaper
|
||||
*/
|
||||
public static function requiresSingleQuoting($value)
|
||||
{
|
||||
return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
|
||||
// Determines if the PHP value contains any single characters that would
|
||||
// cause it to require single quoting in YAML.
|
||||
if (preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Determines if a PHP value is entirely composed of a value that would
|
||||
// require single quoting in YAML.
|
||||
return in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,12 +147,10 @@ class Inline
|
||||
case Escaper::requiresDoubleQuoting($value):
|
||||
return Escaper::escapeWithDoubleQuotes($value);
|
||||
case Escaper::requiresSingleQuoting($value):
|
||||
case preg_match(self::getTimestampRegex(), $value):
|
||||
return Escaper::escapeWithSingleQuotes($value);
|
||||
case '' == $value:
|
||||
return "''";
|
||||
case preg_match(self::getTimestampRegex(), $value):
|
||||
case in_array(strtolower($value), array('null', '~', 'true', 'false')):
|
||||
return "'$value'";
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
|
@ -194,6 +194,14 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
array("'#cfcfcf'", '#cfcfcf'),
|
||||
array('::form_base.html.twig', '::form_base.html.twig'),
|
||||
|
||||
// Pre-YAML-1.2 booleans
|
||||
array("'y'", 'y'),
|
||||
array("'n'", 'n'),
|
||||
array("'yes'", 'yes'),
|
||||
array("'no'", 'no'),
|
||||
array("'on'", 'on'),
|
||||
array("'off'", 'off'),
|
||||
|
||||
array('2007-10-30', mktime(0, 0, 0, 10, 30, 2007)),
|
||||
array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
|
||||
@ -339,6 +347,14 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
array("'-dash'", '-dash'),
|
||||
array("'-'", '-'),
|
||||
|
||||
// Pre-YAML-1.2 booleans
|
||||
array("'y'", 'y'),
|
||||
array("'n'", 'n'),
|
||||
array("'yes'", 'yes'),
|
||||
array("'no'", 'no'),
|
||||
array("'on'", 'on'),
|
||||
array("'off'", 'off'),
|
||||
|
||||
// sequences
|
||||
array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)),
|
||||
array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
|
||||
|
Reference in New Issue
Block a user