Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8fd2cc

Browse filesBrowse files
author
Nick Stemerdink
committed
Merge remote-tracking branch 'upstream/2.4' into fix-select-required
2 parents 13c0eea + 65ea988 commit e8fd2cc
Copy full SHA for e8fd2cc

File tree

Expand file treeCollapse file tree

63 files changed

+1109
-129
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

63 files changed

+1109
-129
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ services: mongodb
1515

1616
before_script:
1717
- sudo apt-get install parallel
18-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "" >> "~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"; fi;'
19-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
20-
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
21-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
22-
- sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
18+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;'
19+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
20+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
21+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
22+
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
2323
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
2424

2525
script:

‎src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,18 @@ public function getEntitiesByIds($identifier, array $values)
8181
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
8282
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);
8383

84+
// Guess type
85+
$entity = current($qb->getRootEntities());
86+
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
87+
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
88+
$parameterType = Connection::PARAM_INT_ARRAY;
89+
} else {
90+
$parameterType = Connection::PARAM_STR_ARRAY;
91+
}
92+
8493
return $qb->andWhere($where)
8594
->getQuery()
86-
->setParameter($parameter, $values, Connection::PARAM_STR_ARRAY)
95+
->setParameter($parameter, $values, $parameterType)
8796
->getResult();
8897
}
8998
}

‎src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php
+42-1Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
1313

1414
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
15+
use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase;
16+
use Doctrine\DBAL\Connection;
1517

16-
class ORMQueryBuilderLoaderTest extends \PHPUnit_Framework_TestCase
18+
class ORMQueryBuilderLoaderTest extends DoctrineOrmTestCase
1719
{
1820
/**
1921
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
@@ -32,4 +34,43 @@ public function testClosureRequiresTheEntityManager()
3234

3335
new ORMQueryBuilderLoader($closure);
3436
}
37+
38+
public function testIdentifierTypeIsStringArray()
39+
{
40+
$this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity', Connection::PARAM_STR_ARRAY);
41+
}
42+
43+
public function testIdentifierTypeIsIntegerArray()
44+
{
45+
$this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', Connection::PARAM_INT_ARRAY);
46+
}
47+
48+
protected function checkIdentifierType($classname, $expectedType)
49+
{
50+
$em = $this->createTestEntityManager();
51+
52+
$query = $this->getMockBuilder('QueryMock')
53+
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
54+
->getMock();
55+
56+
$query->expects($this->once())
57+
->method('setParameter')
58+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(), $expectedType)
59+
->will($this->returnValue($query));
60+
61+
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
62+
->setConstructorArgs(array($em))
63+
->setMethods(array('getQuery'))
64+
->getMock();
65+
66+
$qb->expects($this->once())
67+
->method('getQuery')
68+
->will($this->returnValue($query));
69+
70+
$qb->select('e')
71+
->from($classname, 'e');
72+
73+
$loader = new ORMQueryBuilderLoader($qb);
74+
$loader->getEntitiesByIds('id', array());
75+
}
3576
}

‎src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,23 @@ public function testAssociatedEntity()
330330
$this->assertEquals(1, $violationsList->count());
331331
}
332332

333+
public function testAssociatedEntityWithNull()
334+
{
335+
$entityManagerName = "foo";
336+
$em = DoctrineTestHelper::createTestEntityManager();
337+
$this->createSchema($em);
338+
$validator = $this->createValidator($entityManagerName, $em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity', array('single'), null, 'findBy', false);
339+
340+
$associated = new AssociationEntity();
341+
$associated->single = null;
342+
343+
$em->persist($associated);
344+
$em->flush();
345+
346+
$violationsList = $validator->validate($associated);
347+
$this->assertEquals(0, $violationsList->count());
348+
}
349+
333350
/**
334351
* @group GH-1635
335352
*/

‎src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function validate($entity, Constraint $constraint)
8989
return;
9090
}
9191

92-
if ($class->hasAssociation($fieldName)) {
92+
if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
9393
/* Ensure the Proxy is initialized before using reflection to
9494
* read its identifiers. This is necessary because the wrapped
9595
* getter methods in the Proxy are being bypassed.

‎src/Symfony/Bridge/Twig/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.3.3",
2020
"symfony/security-csrf": "~2.4",
21-
"twig/twig": "~1.11"
21+
"twig/twig": "~1.12"
2222
},
2323
"require-dev": {
2424
"symfony/form": "~2.2",

‎src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\RedirectResponse;
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
18+
use Symfony\Component\HttpKernel\Exception\HttpException;
1819
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1920

2021
/**
@@ -39,11 +40,13 @@ class RedirectController extends ContainerAware
3940
* @param Boolean|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore
4041
*
4142
* @return Response A Response instance
43+
*
44+
* @throws HttpException In case the route name is empty
4245
*/
4346
public function redirectAction(Request $request, $route, $permanent = false, $ignoreAttributes = false)
4447
{
4548
if ('' == $route) {
46-
return new Response(null, $permanent ? 410 : 404);
49+
throw new HttpException($permanent ? 410 : 404);
4750
}
4851

4952
$attributes = array();
@@ -75,11 +78,13 @@ public function redirectAction(Request $request, $route, $permanent = false, $ig
7578
* @param integer|null $httpsPort The HTTPS port (null to keep the current one for the same scheme or the configured port in the container)
7679
*
7780
* @return Response A Response instance
81+
*
82+
* @throws HttpException In case the path is empty
7883
*/
7984
public function urlRedirectAction(Request $request, $path, $permanent = false, $scheme = null, $httpPort = null, $httpsPort = null)
8085
{
8186
if ('' == $path) {
82-
return new Response(null, $permanent ? 410 : 404);
87+
throw new HttpException($permanent ? 410 : 404);
8388
}
8489

8590
$statusCode = $permanent ? 301 : 302;
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<input type="<?php echo isset($type) ? $view->escape($type) : 'text' ?>" <?php echo $view['form']->block($form, 'widget_attributes') ?><?php if (!empty($value)): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?> />
1+
<input type="<?php echo isset($type) ? $view->escape($type) : 'text' ?>" <?php echo $view['form']->block($form, 'widget_attributes') ?><?php if (!empty($value) || is_numeric($value)): ?> value="<?php echo $view->escape($value) ?>"<?php endif ?> />

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
+25-12Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpFoundation\Response;
1515
use Symfony\Component\HttpFoundation\ParameterBag;
1616
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\HttpKernel\Exception\HttpException;
1718
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
1819
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1920

@@ -27,13 +28,19 @@ public function testEmptyRoute()
2728
$request = new Request();
2829
$controller = new RedirectController();
2930

30-
$returnResponse = $controller->redirectAction($request, '', true);
31-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
32-
$this->assertEquals(410, $returnResponse->getStatusCode());
31+
try {
32+
$controller->redirectAction($request, '', true);
33+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
34+
} catch (HttpException $e) {
35+
$this->assertSame(410, $e->getStatusCode());
36+
}
3337

34-
$returnResponse = $controller->redirectAction($request, '', false);
35-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
36-
$this->assertEquals(404, $returnResponse->getStatusCode());
38+
try {
39+
$controller->redirectAction($request, '', false);
40+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
41+
} catch (HttpException $e) {
42+
$this->assertSame(404, $e->getStatusCode());
43+
}
3744
}
3845

3946
/**
@@ -98,13 +105,19 @@ public function testEmptyPath()
98105
$request = new Request();
99106
$controller = new RedirectController();
100107

101-
$returnResponse = $controller->urlRedirectAction($request, '', true);
102-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
103-
$this->assertEquals(410, $returnResponse->getStatusCode());
108+
try {
109+
$controller->urlRedirectAction($request, '', true);
110+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
111+
} catch (HttpException $e) {
112+
$this->assertSame(410, $e->getStatusCode());
113+
}
104114

105-
$returnResponse = $controller->urlRedirectAction($request, '', false);
106-
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse);
107-
$this->assertEquals(404, $returnResponse->getStatusCode());
115+
try {
116+
$controller->urlRedirectAction($request, '', false);
117+
$this->fail('Expected Symfony\Component\HttpKernel\Exception\HttpException to be thrown');
118+
} catch (HttpException $e) {
119+
$this->assertSame(404, $e->getStatusCode());
120+
}
108121
}
109122

110123
public function testFullURL()

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ protected function createListener($container, $id, $config, $userProvider)
7575
{
7676
$listenerId = parent::createListener($container, $id, $config, $userProvider);
7777

78-
if (isset($config['csrf_provider'])) {
79-
$container
80-
->getDefinition($listenerId)
81-
->addArgument(new Reference($config['csrf_provider']))
82-
;
83-
}
78+
$container
79+
->getDefinition($listenerId)
80+
->addArgument(isset($config['csrf_provider']) ? new Reference($config['csrf_provider']) : null)
81+
;
8482

8583
return $listenerId;
8684
}

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
6363
protected function createListener($container, $id, $config, $userProvider)
6464
{
6565
$listenerId = parent::createListener($container, $id, $config, $userProvider);
66-
$listener = $container->getDefinition($listenerId);
67-
68-
if (!isset($config['csrf_token_generator'])) {
69-
$listener->addArgument(null);
70-
}
7166

7267
$simpleAuthHandlerId = 'security.authentication.simple_success_failure_handler.'.$id;
7368
$simpleAuthHandler = $container->setDefinition($simpleAuthHandlerId, new DefinitionDecorator('security.authentication.simple_success_failure_handler'));
7469
$simpleAuthHandler->replaceArgument(0, new Reference($config['authenticator']));
7570
$simpleAuthHandler->replaceArgument(1, new Reference($this->getSuccessHandlerId($id)));
7671
$simpleAuthHandler->replaceArgument(2, new Reference($this->getFailureHandlerId($id)));
7772

73+
$listener = $container->getDefinition($listenerId);
7874
$listener->replaceArgument(5, new Reference($simpleAuthHandlerId));
7975
$listener->replaceArgument(6, new Reference($simpleAuthHandlerId));
8076
$listener->addArgument(new Reference($config['authenticator']));

‎src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function toolbarAction(Request $request, $token)
227227

228228
$session = $request->getSession();
229229

230-
if (null !== $session && $session->getFlashBag() instanceof AutoExpireFlashBag) {
230+
if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
231231
// keep current flashes for one more request if using AutoExpireFlashBag
232232
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
233233
}

‎src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function onKernelResponse(FilterResponseEvent $event)
7676

7777
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects) {
7878
$session = $request->getSession();
79-
if ($session && $session->getFlashBag() instanceof AutoExpireFlashBag) {
79+
if (null !== $session && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
8080
// keep current flashes for one more request if using AutoExpireFlashBag
8181
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
8282
}

‎src/Symfony/Component/BrowserKit/Client.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Client.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,18 @@ public function request($method, $uri, array $parameters = array(), array $files
297297
}
298298

299299
$uri = $this->getAbsoluteUri($uri);
300-
301300
$server = array_merge($this->server, $server);
301+
302302
if (!$this->history->isEmpty()) {
303303
$server['HTTP_REFERER'] = $this->history->current()->getUri();
304304
}
305+
305306
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
307+
308+
if ($port = parse_url($uri, PHP_URL_PORT)) {
309+
$server['HTTP_HOST'] .= ':'.$port;
310+
}
311+
306312
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
307313

308314
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);

‎src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/ClientTest.php
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ public function testRequestHttpHeaders()
160160
$client->request('GET', 'https://www.example.com');
161161
$headers = $client->getRequest()->getServer();
162162
$this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
163+
164+
$client = new TestClient();
165+
$client->request('GET', 'http://www.example.com:8080');
166+
$headers = $client->getRequest()->getServer();
167+
$this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port');
163168
}
164169

165170
public function testRequestURIConversion()
@@ -416,6 +421,24 @@ public function testFollowRedirectWithHeaders()
416421
$this->assertEquals($headers, $client->getRequest()->getServer());
417422
}
418423

424+
public function testFollowRedirectWithPort()
425+
{
426+
$headers = array(
427+
'HTTP_HOST' => 'www.example.com:8080',
428+
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
429+
'HTTPS' => false
430+
);
431+
432+
$client = new TestClient();
433+
$client->followRedirects(false);
434+
$client->setNextResponse(new Response('', 302, array(
435+
'Location' => 'http://www.example.com:8080/redirected',
436+
)));
437+
$client->request('GET', 'http://www.example.com:8080/');
438+
439+
$this->assertEquals($headers, $client->getRequest()->getServer());
440+
}
441+
419442
public function testBack()
420443
{
421444
$client = new TestClient();

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ public function renderException($e, $output)
695695
do {
696696
$title = sprintf(' [%s] ', get_class($e));
697697
$len = $strlen($title);
698-
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
698+
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
699+
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : (defined('HHVM_VERSION') ? 1 << 31 : PHP_INT_MAX);
699700
$formatter = $output->getFormatter();
700701
$lines = array();
701702
foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) {
@@ -1052,7 +1053,7 @@ public function extractNamespace($name, $limit = null)
10521053
* if nothing is found in $collection, try in $abbrevs
10531054
*
10541055
* @param string $name The string
1055-
* @param array|Traversable $collection The collection
1056+
* @param array|\Traversable $collection The collection
10561057
*
10571058
* @return array A sorted array of similar string
10581059
*/

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Parser/Parser.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,11 @@ private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $s
378378
$stream->skipWhitespace();
379379
$value = $stream->getNext();
380380

381+
if ($value->isNumber()) {
382+
// if the value is a number, it's casted into a string
383+
$value = new Token(Token::TYPE_STRING, (string) $value->getValue(), $value->getPosition());
384+
}
385+
381386
if (!($value->isIdentifier() || $value->isString())) {
382387
throw SyntaxErrorException::unexpectedToken('string or identifier', $value);
383388
}

‎src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function getParserTestData()
133133
array('div#foobar', array('Hash[Element[div]#foobar]')),
134134
array('div:not(div.foo)', array('Negation[Element[div]:not(Class[Element[div].foo])]')),
135135
array('td ~ th', array('CombinedSelector[Element[td] ~ Element[th]]')),
136+
array('.foo[data-bar][data-baz=0]', array("Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]")),
136137
);
137138
}
138139

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.