Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed610df

Browse files
committed
Merge branch '2.8'
* 2.8: fixed deprecation notices fixed typos [FrameworkBundle] Tag deprecated services [VarDumper] Dump PHP+Twig code excerpts in backtraces [Config] Fix ArrayNode extra keys "ignore" and "remove" behaviors
2 parents 6816451 + 5ad49c6 commit ed610df

File tree

17 files changed

+406
-137
lines changed

17 files changed

+406
-137
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/form_csrf.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<services>
88
<service id="form.csrf_provider" class="Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter">
99
<argument type="service" id="security.csrf.token_manager" />
10+
<deprecated>The "%service_id%" service is deprecated since Symfony 2.4 and will be removed in 3.0. Use the "security.csrf.token_manager" service instead.</deprecated>
1011
</service>
1112

1213
<service id="form.type_extension.csrf" class="Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension">

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
</call>
4141
</service>
4242
</argument>
43+
<deprecated>The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0.</deprecated>
4344
</service>
4445

4546
<service id="validator.validator_factory" class="Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory" public="false">

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,8 @@ protected function normalizeValue($value)
303303
if (isset($this->children[$name])) {
304304
$normalized[$name] = $this->children[$name]->normalize($val);
305305
unset($value[$name]);
306-
} elseif (false === $this->removeExtraKeys) {
306+
} elseif (!$this->removeExtraKeys) {
307307
$normalized[$name] = $val;
308-
unset($value[$name]);
309308
}
310309
}
311310

src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Config\Tests\Definition;
1313

1414
use Symfony\Component\Config\Definition\ArrayNode;
15+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1516
use Symfony\Component\Config\Definition\ScalarNode;
1617

1718
class ArrayNodeTest extends \PHPUnit_Framework_TestCase
@@ -35,34 +36,30 @@ public function testExceptionThrownOnUnrecognizedChild()
3536
$node->normalize(array('foo' => 'bar'));
3637
}
3738

38-
/**
39-
* Tests that no exception is thrown for an unrecognized child if the
40-
* ignoreExtraKeys option is set to true.
41-
*
42-
* Related to testExceptionThrownOnUnrecognizedChild
43-
*/
44-
public function testIgnoreExtraKeysNoException()
39+
public function ignoreAndRemoveMatrixProvider()
4540
{
46-
$node = new ArrayNode('roo');
47-
$node->setIgnoreExtraKeys(true);
41+
$unrecognizedOptionException = new InvalidConfigurationException('Unrecognized option "foo" under "root"');
4842

49-
$node->normalize(array('foo' => 'bar'));
50-
$this->assertTrue(true, 'No exception was thrown when setIgnoreExtraKeys is true');
43+
return array(
44+
array(true, true, array(), 'no exception is thrown for an unrecognized child if the ignoreExtraKeys option is set to true'),
45+
array(true, false, array('foo' => 'bar'), 'extra keys are not removed when ignoreExtraKeys second option is set to false'),
46+
array(false, true, $unrecognizedOptionException),
47+
array(false, false, $unrecognizedOptionException),
48+
);
5149
}
5250

5351
/**
54-
* Tests that extra keys are not removed when
55-
* ignoreExtraKeys second option is set to false.
56-
*
57-
* Related to testExceptionThrownOnUnrecognizedChild
52+
* @dataProvider ignoreAndRemoveMatrixProvider
5853
*/
59-
public function testIgnoreExtraKeysNotRemoved()
54+
public function testIgnoreAndRemoveBehaviors($ignore, $remove, $expected, $message = '')
6055
{
61-
$node = new ArrayNode('roo');
62-
$node->setIgnoreExtraKeys(true, false);
63-
64-
$data = array('foo' => 'bar');
65-
$this->assertSame($data, $node->normalize($data));
56+
if ($expected instanceof \Exception) {
57+
$this->setExpectedException(get_class($expected), $expected->getMessage());
58+
}
59+
$node = new ArrayNode('root');
60+
$node->setIgnoreExtraKeys($ignore, $remove);
61+
$result = $node->normalize(array('foo' => 'bar'));
62+
$this->assertSame($expected, $result, $message);
6663
}
6764

6865
/**

src/Symfony/Component/CssSelector/CssSelector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\CssSelector;
1313

14-
@trigger_error('The '.__NAMESPACE__.'\CssSelector class is deprecated since version 2.8 and will be removed in 3.0. Use directly the \Symfony\Component\CssSelector\Converter class instead.', E_USER_DEPRECATED);
14+
@trigger_error('The '.__NAMESPACE__.'\CssSelector class is deprecated since version 2.8 and will be removed in 3.0. Use directly the \Symfony\Component\CssSelector\CssSelectorConverter class instead.', E_USER_DEPRECATED);
1515

1616
/**
1717
* CssSelector is the main entry point of the component and can convert CSS
@@ -57,7 +57,7 @@
5757
*
5858
* @author Fabien Potencier <[email protected]>
5959
*
60-
* @deprecated as of 2.8, will be removed in 3.0. Use the \Symfony\Component\CssSelector\Converter class instead.
60+
* @deprecated as of 2.8, will be removed in 3.0. Use the \Symfony\Component\CssSelector\CssSelectorConverter class instead.
6161
*/
6262
class CssSelector
6363
{
@@ -75,7 +75,7 @@ class CssSelector
7575
*/
7676
public static function toXPath($cssExpr, $prefix = 'descendant-or-self::')
7777
{
78-
$converter = new Converter(self::$html);
78+
$converter = new CssSelectorConverter(self::$html);
7979

8080
return $converter->toXPath($cssExpr, $prefix);
8181
}

src/Symfony/Component/CssSelector/Tests/ConverterTest.php renamed to src/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
namespace Symfony\Component\CssSelector\Tests;
1313

14-
use Symfony\Component\CssSelector\Converter;
14+
use Symfony\Component\CssSelector\CssSelectorConverter;
1515

16-
class ConverterTest extends \PHPUnit_Framework_TestCase
16+
class CssSelectorConverterTest extends \PHPUnit_Framework_TestCase
1717
{
1818
public function testCssToXPath()
1919
{
20-
$converter = new Converter();
20+
$converter = new CssSelectorConverter();
2121

2222
$this->assertEquals('descendant-or-self::*', $converter->toXPath(''));
2323
$this->assertEquals('descendant-or-self::h1', $converter->toXPath('h1'));
@@ -29,7 +29,7 @@ public function testCssToXPath()
2929

3030
public function testCssToXPathXml()
3131
{
32-
$converter = new Converter(false);
32+
$converter = new CssSelectorConverter(false);
3333

3434
$this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1'));
3535
}

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\DomCrawler;
1313

14-
use Symfony\Component\CssSelector\Converter;
14+
use Symfony\Component\CssSelector\CssSelectorConverter;
1515

1616
/**
1717
* Crawler eases navigation of a list of \DOMElement objects.
@@ -41,7 +41,7 @@ class Crawler extends \SplObjectStorage
4141
private $baseHref;
4242

4343
/**
44-
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath)
44+
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath).
4545
*
4646
* @var bool
4747
*/
@@ -659,11 +659,11 @@ public function filterXPath($xpath)
659659
*/
660660
public function filter($selector)
661661
{
662-
if (!class_exists('Symfony\\Component\\CssSelector\\Converter')) {
662+
if (!class_exists('Symfony\\Component\\CssSelector\\CssSelectorConverter')) {
663663
throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector 2.8+ is not installed (you can use filterXPath instead).');
664664
}
665665

666-
$converter = new Converter($this->isHtml);
666+
$converter = new CssSelectorConverter($this->isHtml);
667667

668668
// The CssSelector already prefixes the selector with descendant-or-self::
669669
return $this->filterRelativeXPath($converter->toXPath($selector));
@@ -1142,7 +1142,7 @@ private function findNamespacePrefixes($xpath)
11421142
}
11431143

11441144
/**
1145-
* Creates a crawler for some subnodes
1145+
* Creates a crawler for some subnodes.
11461146
*
11471147
* @param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes
11481148
*

src/Symfony/Component/HttpKernel/Tests/Profiler/FileProfilerStorageTest.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
class FileProfilerStorageTest extends AbstractProfilerStorageTest
1818
{
19-
protected static $tmpDir;
20-
protected static $storage;
19+
private $tmpDir;
20+
private $storage;
2121

22-
protected static function cleanDir()
22+
protected function cleanDir()
2323
{
2424
$flags = \FilesystemIterator::SKIP_DOTS;
25-
$iterator = new \RecursiveDirectoryIterator(self::$tmpDir, $flags);
25+
$iterator = new \RecursiveDirectoryIterator($this->tmpDir, $flags);
2626
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
2727

2828
foreach ($iterator as $file) {
@@ -32,31 +32,27 @@ protected static function cleanDir()
3232
}
3333
}
3434

35-
public static function setUpBeforeClass()
35+
protected function setUp()
3636
{
37-
self::$tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage';
38-
if (is_dir(self::$tmpDir)) {
37+
$this->tmpDir = sys_get_temp_dir().'/sf2_profiler_file_storage';
38+
if (is_dir($this->tmpDir)) {
3939
self::cleanDir();
4040
}
41-
self::$storage = new FileProfilerStorage('file:'.self::$tmpDir);
41+
$this->storage = new FileProfilerStorage('file:'.$this->tmpDir);
42+
$this->storage->purge();
4243
}
4344

44-
public static function tearDownAfterClass()
45+
protected function tearDown()
4546
{
4647
self::cleanDir();
4748
}
4849

49-
protected function setUp()
50-
{
51-
self::$storage->purge();
52-
}
53-
5450
/**
5551
* @return \Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface
5652
*/
5753
protected function getStorage()
5854
{
59-
return self::$storage;
55+
return $this->storage;
6056
}
6157

6258
public function testMultiRowIndexFile()
@@ -73,7 +69,7 @@ public function testMultiRowIndexFile()
7369
$storage->write($profile);
7470
}
7571

76-
$handle = fopen(self::$tmpDir.'/index.csv', 'r');
72+
$handle = fopen($this->tmpDir.'/index.csv', 'r');
7773
for ($i = 0; $i < $iteration; ++$i) {
7874
$row = fgetcsv($handle);
7975
$this->assertEquals('token'.$i, $row[0]);
@@ -85,7 +81,7 @@ public function testMultiRowIndexFile()
8581

8682
public function testReadLineFromFile()
8783
{
88-
$r = new \ReflectionMethod(self::$storage, 'readLineFromFile');
84+
$r = new \ReflectionMethod($this->storage, 'readLineFromFile');
8985

9086
$r->setAccessible(true);
9187

@@ -94,7 +90,7 @@ public function testReadLineFromFile()
9490
fwrite($h, "line1\n\n\nline2\n");
9591
fseek($h, 0, SEEK_END);
9692

97-
$this->assertEquals('line2', $r->invoke(self::$storage, $h));
98-
$this->assertEquals('line1', $r->invoke(self::$storage, $h));
93+
$this->assertEquals('line2', $r->invoke($this->storage, $h));
94+
$this->assertEquals('line1', $r->invoke($this->storage, $h));
9995
}
10096
}

src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
1919

20-
class DummyMongoDbProfilerStorage extends MongoDbProfilerStorage
21-
{
22-
public function getMongo()
23-
{
24-
return parent::getMongo();
25-
}
26-
}
27-
2820
class MongoDbProfilerStorageTestDataCollector extends DataCollector
2921
{
3022
public function setData($data)
@@ -52,27 +44,7 @@ public function getName()
5244
*/
5345
class MongoDbProfilerStorageTest extends AbstractProfilerStorageTest
5446
{
55-
protected static $storage;
56-
57-
public static function setUpBeforeClass()
58-
{
59-
if (extension_loaded('mongo')) {
60-
self::$storage = new DummyMongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400);
61-
try {
62-
self::$storage->getMongo();
63-
} catch (\MongoConnectionException $e) {
64-
self::$storage = null;
65-
}
66-
}
67-
}
68-
69-
public static function tearDownAfterClass()
70-
{
71-
if (self::$storage) {
72-
self::$storage->purge();
73-
self::$storage = null;
74-
}
75-
}
47+
private $storage;
7648

7749
public function getDsns()
7850
{
@@ -108,23 +80,23 @@ public function testCleanup()
10880
$profile = new Profile('time_'.$i);
10981
$profile->setTime($dt->getTimestamp());
11082
$profile->setMethod('GET');
111-
self::$storage->write($profile);
83+
$this->storage->write($profile);
11284
}
113-
$records = self::$storage->find('', '', 3, 'GET');
85+
$records = $this->storage->find('', '', 3, 'GET');
11486
$this->assertCount(1, $records, '->find() returns only one record');
11587
$this->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record');
116-
self::$storage->purge();
88+
$this->storage->purge();
11789
}
11890

11991
/**
12092
* @dataProvider getDsns
12193
*/
12294
public function testDsnParser($dsn, $expected)
12395
{
124-
$m = new \ReflectionMethod(self::$storage, 'parseDsn');
96+
$m = new \ReflectionMethod($this->storage, 'parseDsn');
12597
$m->setAccessible(true);
12698

127-
$this->assertEquals($expected, $m->invoke(self::$storage, $dsn));
99+
$this->assertEquals($expected, $m->invoke($this->storage, $dsn));
128100
}
129101

130102
public function testUtf8()
@@ -139,9 +111,9 @@ public function testUtf8()
139111

140112
$profile->setCollectors(array($collector));
141113

142-
self::$storage->write($profile);
114+
$this->storage->write($profile);
143115

144-
$readProfile = self::$storage->read('utf8_test_profile');
116+
$readProfile = $this->storage->read('utf8_test_profile');
145117
$collectors = $readProfile->getCollectors();
146118

147119
$this->assertCount(1, $collectors);
@@ -154,15 +126,31 @@ public function testUtf8()
154126
*/
155127
protected function getStorage()
156128
{
157-
return self::$storage;
129+
return $this->storage;
158130
}
159131

160132
protected function setUp()
161133
{
162-
if (self::$storage) {
163-
self::$storage->purge();
164-
} else {
134+
if (!extension_loaded('mongo')) {
165135
$this->markTestSkipped('MongoDbProfilerStorageTest requires the mongo PHP extension and a MongoDB server on localhost');
166136
}
137+
138+
$this->storage = new MongoDbProfilerStorage('mongodb://localhost/symfony_tests/profiler_data', '', '', 86400);
139+
$m = new \ReflectionMethod($this->storage, 'getMongo');
140+
$m->setAccessible(true);
141+
try {
142+
$m->invoke($this->storage);
143+
} catch (\MongoConnectionException $e) {
144+
$this->storage = null;
145+
}
146+
147+
$this->storage->purge();
148+
}
149+
150+
protected function tearDown()
151+
{
152+
if ($this->storage) {
153+
$this->storage->purge();
154+
}
167155
}
168156
}

0 commit comments

Comments
 (0)