Merge branch '2.3' into 2.7
* 2.3: Finnish translation fix [CssSelector] Optimize regexs matching simple selectors Fix the phpdoc in the CssSelector TranslatorInterface [Console] Add clock mock to fix transient test on HHVM [EventDispatcher] skip one lazy loading call [EventDispatcher] fix memory leak in a getListeners
This commit is contained in:
commit
b6604f3e6f
41
src/Symfony/Component/Console/Tests/ClockMock.php
Normal file
41
src/Symfony/Component/Console/Tests/ClockMock.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?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\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Tests;
|
||||
|
||||
function time()
|
||||
{
|
||||
return Tests\time();
|
||||
}
|
||||
|
||||
namespace Symfony\Component\Console\Tests;
|
||||
|
||||
function with_clock_mock($enable = null)
|
||||
{
|
||||
static $enabled;
|
||||
|
||||
if (null === $enable) {
|
||||
return $enabled;
|
||||
}
|
||||
|
||||
$enabled = $enable;
|
||||
}
|
||||
|
||||
function time()
|
||||
{
|
||||
if (!with_clock_mock()) {
|
||||
return \time();
|
||||
}
|
||||
|
||||
return $_SERVER['REQUEST_TIME'];
|
||||
}
|
@ -13,12 +13,25 @@ namespace Symfony\Component\Console\Tests\Helper;
|
||||
|
||||
use Symfony\Component\Console\Helper\ProgressHelper;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Tests;
|
||||
|
||||
require_once __DIR__.'/../ClockMock.php';
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
Tests\with_clock_mock(true);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
Tests\with_clock_mock(false);
|
||||
}
|
||||
|
||||
public function testAdvance()
|
||||
{
|
||||
$progress = new ProgressHelper();
|
||||
|
@ -33,15 +33,14 @@ class ClassParser implements ParserInterface
|
||||
{
|
||||
// Matches an optional namespace, optional element, and required class
|
||||
// $source = 'test|input.ab6bd_field';
|
||||
// $matches = array (size=5)
|
||||
// 0 => string 'test:input.ab6bd_field' (length=22)
|
||||
// 1 => string 'test:' (length=5)
|
||||
// 2 => string 'test' (length=4)
|
||||
// 3 => string 'input' (length=5)
|
||||
// 4 => string 'ab6bd_field' (length=11)
|
||||
if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?\.([\w-]+)$/i', trim($source), $matches)) {
|
||||
// $matches = array (size=4)
|
||||
// 0 => string 'test|input.ab6bd_field' (length=22)
|
||||
// 1 => string 'test' (length=4)
|
||||
// 2 => string 'input' (length=5)
|
||||
// 3 => string 'ab6bd_field' (length=11)
|
||||
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+\.([\w-]++)$/i', trim($source), $matches)) {
|
||||
return array(
|
||||
new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])),
|
||||
new SelectorNode(new ClassNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,12 @@ class ElementParser implements ParserInterface
|
||||
{
|
||||
// Matches an optional namespace, required element or `*`
|
||||
// $source = 'testns|testel';
|
||||
// $matches = array (size=4)
|
||||
// 0 => string 'testns:testel' (length=13)
|
||||
// 1 => string 'testns:' (length=7)
|
||||
// 2 => string 'testns' (length=6)
|
||||
// 3 => string 'testel' (length=6)
|
||||
if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)$/i', trim($source), $matches)) {
|
||||
return array(new SelectorNode(new ElementNode($matches[2] ?: null, $matches[3])));
|
||||
// $matches = array (size=3)
|
||||
// 0 => string 'testns|testel' (length=13)
|
||||
// 1 => string 'testns' (length=6)
|
||||
// 2 => string 'testel' (length=6)
|
||||
if (preg_match('/^(?:([a-z]++)\|)?([\w-]++|\*)$/i', trim($source), $matches)) {
|
||||
return array(new SelectorNode(new ElementNode($matches[1] ?: null, $matches[2])));
|
||||
}
|
||||
|
||||
return array();
|
||||
|
@ -33,15 +33,14 @@ class HashParser implements ParserInterface
|
||||
{
|
||||
// Matches an optional namespace, optional element, and required id
|
||||
// $source = 'test|input#ab6bd_field';
|
||||
// $matches = array (size=5)
|
||||
// 0 => string 'test:input#ab6bd_field' (length=22)
|
||||
// 1 => string 'test:' (length=5)
|
||||
// 2 => string 'test' (length=4)
|
||||
// 3 => string 'input' (length=5)
|
||||
// 4 => string 'ab6bd_field' (length=11)
|
||||
if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?#([\w-]+)$/i', trim($source), $matches)) {
|
||||
// $matches = array (size=4)
|
||||
// 0 => string 'test|input#ab6bd_field' (length=22)
|
||||
// 1 => string 'test' (length=4)
|
||||
// 2 => string 'input' (length=5)
|
||||
// 3 => string 'ab6bd_field' (length=11)
|
||||
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+#([\w-]++)$/i', trim($source), $matches)) {
|
||||
return array(
|
||||
new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])),
|
||||
new SelectorNode(new HashNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ interface TranslatorInterface
|
||||
* @param string $cssExpr
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return XPathExpr
|
||||
* @return string
|
||||
*/
|
||||
public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::');
|
||||
|
||||
@ -39,7 +39,7 @@ interface TranslatorInterface
|
||||
* @param SelectorNode $selector
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return XPathExpr
|
||||
* @return string
|
||||
*/
|
||||
public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::');
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::hasListeners()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners($eventName = null)
|
||||
{
|
||||
@ -116,7 +116,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::getListeners()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListeners($eventName = null)
|
||||
{
|
||||
@ -152,21 +152,6 @@ class ContainerAwareEventDispatcher extends EventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Lazily loads listeners for this event from the dependency injection
|
||||
* container.
|
||||
*
|
||||
* @throws \InvalidArgumentException if the service is not defined
|
||||
*/
|
||||
public function dispatch($eventName, Event $event = null)
|
||||
{
|
||||
$this->lazyLoad($eventName);
|
||||
|
||||
return parent::dispatch($eventName, $event);
|
||||
}
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
|
@ -33,9 +33,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
private $sorted = array();
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::dispatch()
|
||||
*
|
||||
* @api
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dispatch($eventName, Event $event = null)
|
||||
{
|
||||
@ -46,21 +44,23 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
$event->setDispatcher($this);
|
||||
$event->setName($eventName);
|
||||
|
||||
if (!isset($this->listeners[$eventName])) {
|
||||
return $event;
|
||||
if ($listeners = $this->getListeners($eventName)) {
|
||||
$this->doDispatch($listeners, $eventName, $event);
|
||||
}
|
||||
|
||||
$this->doDispatch($this->getListeners($eventName), $eventName, $event);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::getListeners()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListeners($eventName = null)
|
||||
{
|
||||
if (null !== $eventName) {
|
||||
if (!isset($this->listeners[$eventName])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!isset($this->sorted[$eventName])) {
|
||||
$this->sortListeners($eventName);
|
||||
}
|
||||
@ -78,7 +78,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::hasListeners()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners($eventName = null)
|
||||
{
|
||||
@ -86,9 +86,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::addListener()
|
||||
*
|
||||
* @api
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addListener($eventName, $listener, $priority = 0)
|
||||
{
|
||||
@ -97,7 +95,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::removeListener()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeListener($eventName, $listener)
|
||||
{
|
||||
@ -113,9 +111,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::addSubscriber()
|
||||
*
|
||||
* @api
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addSubscriber(EventSubscriberInterface $subscriber)
|
||||
{
|
||||
@ -133,7 +129,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::removeSubscriber()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeSubscriber(EventSubscriberInterface $subscriber)
|
||||
{
|
||||
@ -177,9 +173,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
{
|
||||
$this->sorted[$eventName] = array();
|
||||
|
||||
if (isset($this->listeners[$eventName])) {
|
||||
krsort($this->listeners[$eventName]);
|
||||
$this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
|
||||
}
|
||||
krsort($this->listeners[$eventName]);
|
||||
$this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="30">
|
||||
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
|
||||
<target>CSRF tarkiste on virheellinen. Olen hyvä ja yritä lähettää lomake uudestaan.</target>
|
||||
<target>CSRF tarkiste on virheellinen. Ole hyvä ja yritä lähettää lomake uudestaan.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation;
|
||||
|
||||
function time($asFloat = false)
|
||||
function time()
|
||||
{
|
||||
return Tests\time();
|
||||
}
|
||||
|
@ -23,16 +23,14 @@ require_once __DIR__.'/ClockMock.php';
|
||||
*/
|
||||
class CookieTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
with_clock_mock(true);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
with_clock_mock(false);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function invalidNames()
|
||||
|
@ -18,16 +18,14 @@ require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
with_clock_mock(true);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
with_clock_mock(false);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,16 +24,14 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
const DELTA = 37;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
with_clock_mock(true);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
with_clock_mock(false);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetOrigin()
|
||||
|
@ -24,16 +24,14 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
const DELTA = 20;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
with_clock_mock(true);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
with_clock_mock(false);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testStart()
|
||||
|
Reference in New Issue
Block a user