8000 Merge branch '3.2' · symfony/symfony@33d4bce · GitHub
[go: up one dir, main page]

Skip to content

Commit 33d4bce

Browse files
committed
Merge branch '3.2'
* 3.2: fixed tests fixed merge Fix minor phpdoc mismatches with the code(detected by phan) [Asset] Starting slash should indicate no basePath wanted [Security] Fix phpdoc logout listener [EventDispatcher] fix getting priorities of listeners during dispatch Add iconv extension to suggested dependencies Fix minor typo in the main README.md Allow Upper Case property names in ObjectNormalizer [EventDispatcher] fix: unwrap listeners for correct info
2 parents 3c9a7e4 + c7a7170 commit 33d4bce

File tree

30 files changed

+165
-84
lines changed

30 files changed

+165
-84
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If you discover a security vulnerability within Symfony, please follow our
4646
About Us
4747
--------
4848

49-
Symfony development is sponsored by [SensioLabs][21], lead by the
49+
Symfony development is sponsored by [SensioLabs][21], led by the
5050
[Symfony Core Team][22] and supported by [Symfony contributors][19].
5151

5252
[1]: https://symfony.com

src/Symfony/Component/Asset/PathPackage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public function getUrl($path)
5959

6060
$versionedPath = $this->getVersionStrategy()->applyVersion($path);
6161

62-
if ($this->isAbsoluteUrl($versionedPath)) {
62+
// if absolute or begins with /, we're done
63+
if ($this->isAbsoluteUrl($versionedPath) || ($versionedPath && '/' === $versionedPath[0])) {
6364
return $versionedPath;
6465
}
6566

src/Symfony/Component/Asset/Tests/PathPackageTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ public function getConfigs()
3535

3636
array('', '', '/foo', '/foo?v1'),
3737

38-
array('/foo', '', '/foo', '/foo/foo?v1'),
39-
array('/foo', '', 'foo', '/foo/foo?v1'),
40-
array('foo', '', 'foo', '/foo/foo?v1'),
41-
array('foo/', '', 'foo', '/foo/foo?v1'),
42-
array('/foo/', '', 'foo', '/foo/foo?v1'),
43-
44-
array('/foo', 'version-%2$s/%1$s', '/foo', '/foo/version-v1/foo'),
45-
array('/foo', 'version-%2$s/%1$s', 'foo', '/foo/version-v1/foo'),
46-
array('/foo', 'version-%2$s/%1$s', 'foo/', '/foo/version-v1/foo/'),
47-
array('/foo', 'version-%2$s/%1$s', '/foo/', '/foo/version-v1/foo/'),
38+
array('/foo', '', '/bar', '/bar?v1'),
39+
array('/foo', '', 'bar', '/foo/bar?v1'),
40+
array('foo', '', 'bar', '/foo/bar?v1'),
41+
array('foo/', '', 'bar', '/foo/bar?v1'),
42+
array('/foo/', '', 'bar', '/foo/bar?v1'),
43+
44+
array('/foo', 'version-%2$s/%1$s', '/bar', '/version-v1/bar'),
45+
array('/foo', 'version-%2$s/%1$s', 'bar', '/foo/version-v1/bar'),
46+
array('/foo', 'version-%2$s/%1$s', 'bar/', '/foo/version-v1/bar/'),
47+
array('/foo', 'version-%2$s/%1$s', '/bar/', '/version-v1/bar/'),
4848
);
4949
}
5050

@@ -61,17 +61,17 @@ public function testGetUrlWithContext($basePathRequest, $basePath, $format, $pat
6161
public function getContextConfigs()
6262
{
6363
return array(
64-
array('', '/foo', '', '/foo', '/foo/foo?v1'),
65-
array('', '/foo', '', 'foo', '/foo/foo?v1'),
66-
array('', 'foo', '', 'foo', '/foo/foo?v1'),
67-
array('', 'foo/', '', 'foo', '/foo/foo?v1'),
68-
array('', '/foo/', '', 'foo', '/foo/foo?v1'),
69-
70-
array('/bar', '/foo', '', '/foo', '/bar/foo/foo?v1'),
71-
array('/bar', '/foo', '', 'foo', '/bar/foo/foo?v1'),
72-
array('/bar', 'foo', '', 'foo', '/bar/foo/foo?v1'),
73-
array('/bar', 'foo/', '', 'foo', '/bar/foo/foo?v1'),
74-
array('/bar', '/foo/', '', 'foo', '/bar/foo/foo?v1'),
64+
array('', '/foo', '', '/baz', '/baz?v1'),
65+
array('', '/foo', '', 'baz', '/foo/baz?v1'),
66+
array('', 'foo', '', 'baz', '/foo/baz?v1'),
67+
array('', 'foo/', '', 'baz', '/foo/baz?v1'),
68+
array('', '/foo/', '', 'baz', '/foo/baz?v1'),
69+
70+
array('/bar', '/foo', '', '/baz', '/baz?v1'),
71+
array('/bar', '/foo', '', 'baz', '/bar/foo/baz?v1'),
72+
array('/bar', 'foo', '', 'baz', '/bar/foo/baz?v1'),
73+
array('/bar', 'foo/', '', 'baz', '/bar/foo/baz?v1'),
74+
array('/bar', '/foo/', '', 'baz', '/bar/foo/baz?v1'),
7575
);
7676
}
7777

src/Symfony/Component/CssSelector/Parser/Reader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getOffset($string)
9797
/**
9898
* @param string $pattern
9999
*
100-
* @return bool
100+
* @return array|false
101101
*/
102102
public function findPattern($pattern)
103103
{

src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function setFlag($flag, $on)
7272
*/
7373
public function hasFlag($flag)
7474
{
75-
return $this->flags & $flag;
75+
return (bool) ($this->flags & $flag);
7676
}
7777

7878
/**

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ public function getListeners($eventName = null)
104104
*/
105105
public function getListenerPriority($eventName, $listener)
106106
{
107+
// we might have wrapped listeners for the event (if called while dispatching)
108+
// in that case get the priority by wrapper
109+
if (isset($this->wrappedListeners[$eventName])) {
110+
foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) {
111+
if ($wrappedListener->getWrappedListener() === $listener) {
112+
return $this->dispatcher->getListenerPriority($eventName, $wrappedListener);
113+
}
114+
}
115+
}
116+
107117
return $this->dispatcher->getListenerPriority($eventName, $listener);
108118
}
109119

src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
16+
use Symfony\Component\EventDispatcher\Debug\WrappedListener;
1617
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1718
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1819
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -74,6 +75,20 @@ public function testGetListenerPriority()
7475
$this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0]));
7576
}
7677

78+
public function testGetListenerPriorityWhileDispatching()
79+
{
80+
$tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
81+
$priorityWhileDispatching = null;
82+
83+
$listener = function () use ($tdispatcher, &$priorityWhileDispatching, &$listener) {
84+
$priorityWhileDispatching = $tdispatcher->getListenerPriority('bar', $listener);
85+
};
86+
87+
$tdispatcher->addListener('bar', $listener, 5);
88+
$tdispatcher->dispatch('bar');
89+
$this->assertSame(5, $priorityWhileDispatching);
90+
}
91+
7792
public function testAddRemoveSubscriber()
7893
{
7994
$dispatcher = new EventDispatcher();
@@ -90,27 +105,44 @@ public function testAddRemoveSubscriber()
90105
$this->assertCount(0, $dispatcher->getListeners('foo'));
91106
}
92107

93-
public function testGetCalledListeners()
108+
/**
109+
* @dataProvider isWrappedDataProvider
110+
*
111+
* @param bool $isWrapped
112+
*/
113+
public function testGetCalledListeners($isWrapped)
94114
{
95115
$dispatcher = new EventDispatcher();
96-
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch());
97-
$tdispatcher->addListener('foo', $listener = function () {});
116+
$stopWatch = new Stopwatch();
117+
$tdispatcher = new TraceableEventDispatcher($dispatcher, $stopWatch);
118+
119+
$listener = function () {};
120+
121+
$tdispatcher->addListener('foo', $listener, 5);
98122

99123
$listeners = $tdispatcher->getNotCalledListeners();
100124
$this->assertArrayHasKey('stub', $listeners['foo.closure']);
101125
unset($listeners['foo.closure']['stub']);
102126
$this->assertEquals(array(), $tdispatcher->getCalledListeners());
103-
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 0)), $listeners);
127+
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
104128

105129
$tdispatcher->dispatch('foo');
106130

107131
$listeners = $tdispatcher->getCalledListeners();
108132
$this->assertArrayHasKey('stub', $listeners['foo.closure']);
109133
unset($listeners['foo.closure']['stub']);
110-
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => null)), $listeners);
134+
$this->assertEquals(array('foo.closure' => array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
111135
$this->assertEquals(array(), $tdispatcher->getNotCalledListeners());
112136
}
113137

138+
public function isWrappedDataProvider()
139+
{
140+
return array(
141+
array(false),
142+
array(true),
143+
);
144+
}
145+
114146
public function testGetCalledListenersNested()
115147
{
116148
$tdispatcher = null;

src/Symfony/Component/ExpressionLanguage/Lexer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function tokenize($expression)
4242
continue;
4343
}
4444

45-
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, null, $cursor)) {
45+
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, 0, $cursor)) {
4646
// numbers
4747
$number = (float) $match[0]; // floats
4848
if (preg_match('/^[0-9]+$/', $match[0]) && $number <= PHP_INT_MAX) {
@@ -69,19 +69,19 @@ public function tokenize($expression)
6969

7070
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
7171
++$cursor;
72-
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
72+
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, 0, $cursor)) {
7373
// strings
7474
$tokens[] = new Token(Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)), $cursor + 1);
7575
$cursor += strlen($match[0]);
76-
} elseif (preg_match('/not in(?=[\s(])|\!\=\=|not(?=[\s(])|and(?=[\s(])|\=\=\=|\>\=|or(?=[\s(])|\<\=|\*\*|\.\.|in(?=[\s(])|&&|\|\||matches|\=\=|\!\=|\*|~|%|\/|\>|\||\!|\^|&|\+|\<|\-/A', $expression, $match, null, $cursor)) {
76+
} elseif (preg_match('/not in(?=[\s(])|\!\=\=|not(?=[\s(])|and(?=[\s(])|\=\=\=|\>\=|or(?=[\s(])|\<\=|\*\*|\.\.|in(?=[\s(])|&&|\|\||matches|\=\=|\!\=|\*|~|%|\/|\>|\||\!|\^|&|\+|\<|\-/A', $expression, $match, 0, $cursor)) {
7777
// operators
7878
$tokens[] = new Token(Token::OPERATOR_TYPE, $match[0], $cursor + 1);
7979
$cursor += strlen($match[0]);
8080
} elseif (false !== strpos('.,?:', $expression[$cursor])) {
8181
// punctuation
8282
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
8383
++$cursor;
84-
} elseif (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $expression, $match, null, $cursor)) {
84+
} elseif (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $expression, $match, 0, $cursor)) {
8585
// names
8686
$tokens[] = new Token(Token::NAME_TYPE, $match[0], $cursor + 1);
8787
$cursor += strlen($match[0]);

src/Symfony/Component/ExpressionLanguage/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Token
3232
/**
3333
* Constructor.
3434
*
35-
* @param int $type The type of the token
35+
* @param string $type The type of the token (self::*_TYPE)
3636
* @param string $value The token value
3737
* @param int $cursor The cursor position in the source
3838
*/

src/Symfony/Component/HttpFoundation/FileBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function add(array $files = array())
6969
*
7070
* @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information
7171
*
72-
* @return array A (multi-dimensional) array of UploadedFile instances
72+
* @return UploadedFile|UploadedFile[] A (multi-dimensional) array of UploadedFile instances
7373
*/
7474
protected function convertFileInformation($file)
7575
{

0 commit comments

Comments
 (0)
0