Merge branch '2.7' into 2.8
* 2.7: [Config] Fix enum default value in Yaml dumper 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 [DomCrawler] Optimize the regex used to find namespace prefixes [EventDispatcher] skip one lazy loading call [EventDispatcher] fix memory leak in a getListeners Default to stderr for console helpers (only merge if #15794 gets merged)
This commit is contained in:
commit
b75755cdde
@ -93,7 +93,7 @@ class YamlReferenceDumper
|
||||
}
|
||||
} elseif ($node instanceof EnumNode) {
|
||||
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
|
||||
$default = '~';
|
||||
$default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
|
||||
} else {
|
||||
$default = '~';
|
||||
|
||||
|
@ -37,6 +37,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
|
||||
return str_replace("\n", PHP_EOL, <<<EOL
|
||||
<!-- Namespace: http://example.org/schema/dic/acme_root -->
|
||||
<!-- scalar-required: Required -->
|
||||
<!-- enum-with-default: One of "this"; "that" -->
|
||||
<!-- enum: One of "this"; "that" -->
|
||||
<config
|
||||
boolean="true"
|
||||
@ -48,6 +49,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
|
||||
scalar-array-empty=""
|
||||
scalar-array-defaults="elem1,elem2"
|
||||
scalar-required=""
|
||||
enum-with-default="this"
|
||||
enum=""
|
||||
>
|
||||
|
||||
|
@ -43,6 +43,7 @@ acme_root:
|
||||
- elem1
|
||||
- elem2
|
||||
scalar_required: ~ # Required
|
||||
enum_with_default: this # One of "this"; "that"
|
||||
enum: ~ # One of "this"; "that"
|
||||
|
||||
# some info
|
||||
|
@ -34,6 +34,7 @@ class ExampleConfiguration implements ConfigurationInterface
|
||||
->scalarNode('scalar_array_empty')->defaultValue(array())->end()
|
||||
->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end()
|
||||
->scalarNode('scalar_required')->isRequired()->end()
|
||||
->enumNode('enum_with_default')->values(array('this', 'that'))->defaultValue('this')->end()
|
||||
->enumNode('enum')->values(array('this', 'that'))->end()
|
||||
->arrayNode('array')
|
||||
->info('some info')
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
@ -37,6 +38,10 @@ class ProcessHelper extends Helper
|
||||
*/
|
||||
public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$formatter = $this->getHelperSet()->get('debug_formatter');
|
||||
|
||||
if (is_array($cmd)) {
|
||||
@ -109,6 +114,10 @@ class ProcessHelper extends Helper
|
||||
*/
|
||||
public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$formatter = $this->getHelperSet()->get('debug_formatter');
|
||||
|
||||
$that = $this;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
@ -54,6 +55,10 @@ class ProgressBar
|
||||
*/
|
||||
public function __construct(OutputInterface $output, $max = 0)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
$this->output = $output;
|
||||
$this->setMaxSteps($max);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
@ -41,6 +42,10 @@ class QuestionHelper extends Helper
|
||||
*/
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
|
||||
if (!$input->isInteractive()) {
|
||||
return $question->getDefault();
|
||||
}
|
||||
|
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::');
|
||||
}
|
||||
|
@ -1036,13 +1036,13 @@ class Crawler extends \SplObjectStorage
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $xpath
|
||||
* @param string $xpath
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function findNamespacePrefixes($xpath)
|
||||
{
|
||||
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*):[^"\/:]/i', $xpath, $matches)) {
|
||||
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*+):[^"\/:]/i', $xpath, $matches)) {
|
||||
return array_unique($matches['prefix']);
|
||||
}
|
||||
|
||||
|
@ -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, $withPriorities = false)
|
||||
{
|
||||
@ -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,17 +44,15 @@ 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, $withPriorities = false)
|
||||
{
|
||||
@ -65,6 +61,10 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
if (null !== $eventName) {
|
||||
if (!isset($this->listeners[$eventName])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!isset($this->sorted[$eventName])) {
|
||||
$this->sortListeners($eventName);
|
||||
}
|
||||
@ -82,7 +82,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::hasListeners()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners($eventName = null)
|
||||
{
|
||||
@ -90,9 +90,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::addListener()
|
||||
*
|
||||
* @api
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addListener($eventName, $listener, $priority = 0)
|
||||
{
|
||||
@ -101,7 +99,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::removeListener()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeListener($eventName, $listener)
|
||||
{
|
||||
@ -117,9 +115,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::addSubscriber()
|
||||
*
|
||||
* @api
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addSubscriber(EventSubscriberInterface $subscriber)
|
||||
{
|
||||
@ -137,7 +133,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventDispatcherInterface::removeSubscriber()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeSubscriber(EventSubscriberInterface $subscriber)
|
||||
{
|
||||
@ -181,9 +177,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