8000 Merge branch '2.3' into 2.7 · symfony/symfony@b6604f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit b6604f3

Browse files
Merge branch '2.3' into 2.7
* 2.3: Finnish translation fix [CssSelector] Optimize regexs matching simple selectors Fix the phpdoc in the CssS 10000 elector TranslatorInterface [Console] Add clock mock to fix transient test on HHVM [EventDispatcher] skip one lazy loading call [EventDispatcher] fix memory leak in a getListeners
2 parents 9840193 + b2f7753 commit b6604f3

File tree

14 files changed

+103
-81
lines changed

14 files changed

+103
-81
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Console\Helper;
13+
14+
use Symfony\Component\Console\Tests;
15+
16+
function time()
17+
{
18+
return Tests\time();
19+
}
20+
21+
namespace Symfony\Component\Console\Tests;
22+
23+
function with_clock_mock($enable = null)
24+
{
25+
static $enabled;
26+
27+
if (null === $enable) {
28+
return $enabled;
29+
}
30+
31+
$enabled = $enable;
32+
}
33+
34+
function time()
35+
{
36+
if (!with_clock_mock()) {
37+
return \time();
38+
}
39+
40+
return $_SERVER['REQUEST_TIME'];
41+
}

src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@
1313

1414
use Symfony\Component\Console\Helper\ProgressHelper;
1515
use Symfony\Component\Console\Output\StreamOutput;
16+
use Symfony\Component\Console\Tests;
17+
18+
require_once __DIR__.'/../ClockMock.php';
1619

1720
/**
1821
* @group legacy
1922
*/
2023
class LegacyProgressHelperTest extends \PHPUnit_Framework_TestCase
2124
{
25+
protected function setUp()
26+
{
27+
Tests\with_clock_mock(true);
28+
}
29+
30+
protected function tearDown()
31+
{
32+
Tests\with_clock_mock(false);
33+
}
34+
2235
public function testAdvance()
2336
{
2437
$progress = new ProgressHelper();

src/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ public function parse($source)
3333
{
3434
// Matches an optional namespace, optional element, and required class
3535
// $source = 'test|input.ab6bd_field';
36-
// $matches = array (size=5)
37-
// 0 => string 'test:input.ab6bd_field' (length=22)
38-
// 1 => string 'test:' (length=5)
39-
// 2 => string 'test' (length=4)
40-
// 3 => string 'input' (length=5)
41-
// 4 => string 'ab6bd_field' (length=11)
42-
if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?\.([\w-]+)$/i', trim($source), $matches)) {
36+
// $matches = array (size=4)
37+
// 0 => string 'test|input.ab6bd_field' (length=22)
38+
// 1 => string 'test' (length=4)
39+
// 2 => string 'input' (length=5)
40+
// 3 => string 'ab6bd_field' (length=11)
41+
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+\.([\w-]++)$/i', trim($source), $matches)) {
4342
return array(
44-
new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])),
43+
new SelectorNode(new ClassNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
4544
);
4645
}
4746

src/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ public function parse($source)
3232
{
3333
// Matches an optional namespace, required element or `*`
3434
// $source = 'testns|testel';
35-
// $matches = array (size=4)
36-
// 0 => string 'testns:testel' (length=13)
37-
// 1 => string 'testns:' (length=7)
38-
// 2 => string 'testns' (length=6)
39-
// 3 => string 'testel' (length=6)
40-
if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)$/i', trim($source), $matches)) {
41-
return array(new SelectorNode(new ElementNode($matches[2] ?: null, $matches[3])));
35+
// $matches = array (size=3)
36+
// 0 => string 'testns|testel' (length=13)
37+
// 1 => string 'testns' (length=6)
38+
// 2 => string 'testel' (length=6)
39+
if (preg_match('/^(?:([a-z]++)\|)?([\w-]++|\*)$/i', trim($source), $matches)) {
40+
return array(new SelectorNode(new ElementNode($matches[1] ?: null, $matches[2])));
4241
}
4342

4443
return array();

src/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ public function parse($source)
3333
{
3434
// Matches an optional namespace, optional element, and required id
3535
// $source = 'test|input#ab6bd_field';
36-
// $matches = array (size=5)
37-
// 0 => string 'test:input#ab6bd_field' (length=22)
38-
// 1 => string 'test:' (length=5)
39-
// 2 => string 'test' (length=4)
40-
// 3 => string 'input' (length=5)
41-
// 4 => string 'ab6bd_field' (length=11)
42-
if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?#([\w-]+)$/i', trim($source), $matches)) {
36+
// $matches = array (size=4)
37+
// 0 => string 'test|input#ab6bd_field' (length=22)
38+
// 1 => string 'test' (length=4)
39+
// 2 => string 'input' (length=5)
40+
// 3 => string 'ab6bd_field' (length=11)
41+
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+#([\w-]++)$/i', trim($source), $matches)) {
4342
return array(
44-
new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])),
43+
new SelectorNode(new HashNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
4544
);
4645
}
4746

src/Symfony/Component/CssSelector/XPath/TranslatorInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface TranslatorInterface
2929
* @param string $cssExpr
3030
* @param string $prefix
3131
*
32-
* @return XPathExpr
32+
* @return string
3333
*/
3434
public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::');
3535

@@ -39,7 +39,7 @@ public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::');
3939
* @param SelectorNode $selector
4040
* @param string $prefix
4141
*
42-
* @return XPathExpr
42+
* @return string
4343
*/
4444
public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::');
4545
}

src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function removeListener($eventName, $listener)
100100
}
101101

102102
/**
103-
* @see EventDispatcherInterface::hasListeners()
103+
* {@inheritdoc}
104104
*/
105105
public function hasListeners($eventName = null)
106106
{
@@ -116,7 +116,7 @@ public function hasListeners($eventName = null)
116116
}
117117

118118
/**
119-
* @see EventDispatcherInterface::getListeners()
119+
* {@inheritdoc}
120120
*/
121121
public function getListeners($eventName = null)
122122
{
@@ -152,21 +152,6 @@ public function addSubscriberService($serviceId, $class)
152152
}
153153
}
154154

155-
/**
156-
* {@inheritdoc}
157-
*
158-
* Lazily loads listeners for this event from the dependency injection
159-
* container.
160-
*
161-
* @throws \InvalidArgumentException if the service is not defined
162-
*/
163-
public function dispatch($eventName, Event $event = null)
164-
{
165-
$this->lazyLoad($eventName);
166-
167-
return parent::dispatch($eventName, $event);
168-
}
169-
170155
public function getContainer()
171156
{
172157
return $this->container;

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class EventDispatcher implements EventDispatcherInterface
3333
private $sorted = array();
3434

3535
/**
36-
* @see EventDispatcherInterface::dispatch()
37-
*
38-
* @api
36+
* {@inheritdoc}
3937
*/
4038
public function dispatch($eventName, Event $event = null)
4139
{
@@ -46,21 +44,23 @@ public function dispatch($eventName, Event $event = null)
4644
$event->setDispatcher($this);
4745
$event->setName($eventName);
4846

49-
if (!isset($this->listeners[$eventName])) {
50-
return $event;
47+
if ($listeners = $this->getListeners($eventName)) {
48+
$this->doDispatch($listeners, $eventName, $event);
5149
}
5250

53-
$this->doDispatch($this->getListeners($eventName), $eventName, $event);
54-
5551
return $event;
5652
}
5753

5854
/**
59-
* @see EventDispatcherInterface::getListeners()
55+
* {@inheritdoc}
6056
*/
6157
public function getListeners($eventName = null)
6258
{
6359
if (null !== $eventName) {
60+
if (!isset($this->listeners[$eventName])) {
61+
return array();
62+
}
63+
6464
if (!isset($this->sorted[$eventName])) {
6565
$this->sortListeners($eventName);
6666
}
@@ -78,17 +78,15 @@ public function getListeners($eventName = null)
7878
}
7979

8080
/**
81-
* @see EventDispatcherInterface::hasListeners()
81+
* {@inheritdoc}
8282
*/
8383
public function hasListeners($eventName = null)
8484
{
8585
return (bool) count($this->getListeners($eventName));
8686
}
8787

8888
/**
89-
* @see EventDispatcherInterface::addListener()
90-
*
91-
* @api
89+
* {@inheritdoc}
9290
*/
9391
public function addListener($eventName, $listener, $priority = 0)
9492
{
@@ -97,7 +95,7 @@ public function addListener($eventName, $listener, $priority = 0)
9795
}
9896

9997
/**
100-
* @see EventDispatcherInterface::removeListener()
98+
* {@inheritdoc}
10199
*/
102100
public function removeListener($eventName, $listener)
103101
{
@@ -113,9 +111,7 @@ public function removeListener($eventName, $listener)
113111
}
114112

115113
/**
116-
* @see EventDispatcherInterface::addSubscriber()
117-
*
118-
* @api
114+
* {@inheritdoc}
119115
*/
120116
public function addSubscriber(EventSubscriberInterface $subscriber)
121117
{
@@ -133,7 +129,7 @@ public function addSubscriber(EventSubscriberInterface $subscriber)
133129
}
134130

135131
/**
136-
* @see EventDispatcherInterface::removeSubscriber()
132+
* {@inheritdoc}
137133
*/
138134
public function removeSubscriber(EventSubscriberInterface $subscriber)
139135
{
@@ -177,9 +173,7 @@ private function sortListeners($eventName)
177173
{
178174
$this->sorted[$eventName] = array();
179175

180-
if (isset($this->listeners[$eventName])) {
181-
krsort($this->listeners[$eventName]);
182-
$this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
183-
}
176+
krsort($this->listeners[$eventName]);
177+
$this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]);
184178
}
185179
}

src/Symfony/Component/Form/Resources/translations/validators.fi.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</trans-unit>
1313
<trans-unit id="30">
1414
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
15-
<target>CSRF tarkiste on virheellinen. Olen hyvä ja yritä lähettää lomake uudestaan.</target>
15+
<target>CSRF tarkiste on virheellinen. Ole hyvä ja yritä lähettää lomake uudestaan.</target>
1616
</trans-unit>
1717
</body>
1818
</file>

src/Symfony/Component/HttpFoundation/Tests/ClockMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\HttpFoundation;
1313

14-
function time($asFloat = false)
14+
function time()
1515
{
1616
return Tests\time();
1717
}

src/Symfony/Component/HttpFoundation/Tests/CookieTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@
2323
*/
2424
class CookieTest extends \PHPUnit_Framework_TestCase
2525
{
26-
public function setUp()
26+
protected function setUp()
2727
{
2828
with_clock_mock(true);
29-
parent::setUp();
3029
}
3130

32-
public function tearDown()
31+
protected function tearDown()
3332
{
3433
with_clock_mock(false);
35-
parent::tearDown();
3634
}
3735

3836
public function invalidNames()

src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818

1919
class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
2020
{
21-
public function setUp()
21+
protected function setUp()
2222
{
2323
with_clock_mock(true);
24-
parent::setUp();
2524
}
2625

27-
public function tearDown()
26+
protected function tearDown()
2827
{
2928
with_clock_mock(false);
30-
parent::tearDown();
3129
}
3230

3331
/**

src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
2424
{
2525
const DELTA = 37;
2626

27-
public function setUp()
27+
protected function setUp()
2828
{
2929
with_clock_mock(true);
30-
parent::setUp();
3130
}
3231

33-
public function tearDown()
32+
protected function tearDown()
3433
{
3534
with_clock_mock(false);
36-
parent::tearDown();
3735
}
3836

3937
public function testGetOrigin()

src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php

Copy file name to clipboard
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase
2424
{
2525
const DELTA = 20;
2626

27-
public function setUp()
27+
protected function setUp()
2828
{
2929
with_clock_mock(true);
30-
parent::setUp();
3130
}
3231

33-
public function tearDown()
32+
protected function tearDown()
3433
{
3534
with_clock_mock(false);
36-
parent::tearDown();
3735
}
3836

3937
public function testStart()

0 commit comments

Comments
 (0)
0