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

Skip to content

Commit 48aa3e1

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Locale] Add missing @group legacy annotations Fix security-acl deps Fix doctrine mapping validation type error Remove skipping of tests based on ICU data version whenever possible Fix the handling of null as locale in the stub intl classes do not dump leading backslashes in class names fix issue #15377 Skip ::class constant [Config] type specific check for emptiness Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/SecurityBundle/composer.json src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
2 parents 9fdf314 + 07fb308 commit 48aa3e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+444
-140
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, $object
252252
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
253253
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
254254
'You can register them by adding a new driver to the '.
255-
'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'.metadata_driver')
255+
'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')
256256
));
257257
}
258258
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"symfony/translation": "~2.7|~3.0.0",
3232
"symfony/yaml": "~2.0,>=2.0.5|~3.0.0",
3333
"symfony/security": "~2.6|~3.0.0",
34+
"symfony/security-acl": "~2.6|~3.0.0",
3435
"symfony/stopwatch": "~2.2|~3.0.0",
3536
"symfony/console": "~2.7|~3.0.0",
3637
"symfony/var-dumper": "~2.6|~3.0.0",

src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function collect(Request $request, Response $response, \Exception $except
7171
if (null !== $this->roleHierarchy) {
7272
$allRoles = $this->roleHierarchy->getReachableRoles($assignedRoles);
7373
foreach ($allRoles as $role) {
74-
if (!in_array($role, $assignedRoles)) {
74+
if (!in_array($role, $assignedRoles, true)) {
7575
$inheritedRoles[] = $role;
7676
}
7777
}

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"require": {
1919
"php": ">=5.3.9",
2020
"symfony/security": "~2.8|~3.0.0",
21-
"symfony/http-kernel": "~2.2|~3.0.0",
22-
"symfony/security-acl": "~2.8|~3.0.0"
21+
"symfony/security-acl": "~2.8|~3.0.0",
22+
"symfony/http-kernel": "~2.2|~3.0.0"
2323
},
2424
"require-dev": {
2525
"symfony/phpunit-bridge": "~2.7|~3.0.0",

src/Symfony/Component/ClassLoader/ClassMapGenerator.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,25 @@ private static function findClasses($path)
118118
case T_CLASS:
119119
case T_INTERFACE:
120120
case SYMFONY_TRAIT:
121+
// Skip usage of ::class constant
122+
$isClassConstant = false;
123+
for ($j = $i - 1; $j > 0; --$j) {
124+
if (is_string($tokens[$j])) {
125+
break;
126+
}
127+
128+
if (T_DOUBLE_COLON === $tokens[$j][0]) {
129+
$isClassConstant = true;
130+
break;
131+
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
132+
break;
133+
}
134+
}
135+
136+
if ($isClassConstant) {
137+
continue;
138+
}
139+
121140
// Find the classname
122141
while (($t = $tokens[++$i]) && is_array($t)) {
123142
if (T_STRING === $t[0]) {

src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private function clean($file)
4747
/**
4848
* @dataProvider getTestCreateMapTests
4949
*/
50-
public function testDump($directory, $expected)
50+
public function testDump($directory)
5151
{
5252
$this->prepare_workspace();
5353

@@ -115,6 +115,12 @@ public function getTestCreateMapTests()
115115
));
116116
}
117117

118+
if (PHP_VERSION_ID >= 50500) {
119+
$data[] = array(__DIR__.'/Fixtures/php5.5', array(
120+
'ClassCons\\Foo' => __DIR__.'/Fixtures/php5.5/class_cons.php',
121+
));
122+
}
123+
118124
return $data;
119125
}
120126

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace ClassCons;
4+
5+
class Foo
6+
{
7+
public function __construct()
8+
{
9+
\Foo\TBar/* foo */::class;
10+
}
11+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,13 @@ protected function validateType($value)
3939
throw $ex;
4040
}
4141
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
protected function isValueEmpty($value)
47+
{
48+
// a boolean value cannot be empty
49+
return false;
50+
}
4251
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@ protected function finalizeValue($value)
5252

5353
return $value;
5454
}
55+
56+
/**
57+
* {@inheritdoc}
58+
*/
59+
protected function isValueEmpty($value)
60+
{
61+
// a numeric value cannot be empty
62+
return false;
63+
}
5564
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,12 @@ protected function validateType($value)
4646
throw $ex;
4747
}
4848
}
49+
50+
/**
51+
* {@inheritdoc}
52+
*/
53+
protected function isValueEmpty($value)
54+
{
55+
return null === $value || '' === $value;
56+
}
4957
}

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function validateType($value)
8484
*/
8585
protected function finalizeValue($value)
8686
{
87-
if (!$this->allowEmptyValue && empty($value)) {
87+
if (!$this->allowEmptyValue && $this->isValueEmpty($value)) {
8888
$ex = new InvalidConfigurationException(sprintf(
8989
'The path "%s" cannot contain an empty value, but got %s.',
9090
$this->getPath(),
@@ -116,4 +116,20 @@ protected function mergeValues($leftSide, $rightSide)
116116
{
117117
return $rightSide;
118118
}
119+
120+
/**
121+
* Evaluates if the given value is to be treated as empty.
122+
*
123+
* By default, PHP's empty() function is used to test for emptiness. This
124+
* method may be overridden by subtypes to better match their understanding
125+
* of empty data.
126+
*
127+
* @param mixed $value
128+
*
129+
* @return bool
130+
*/
131+
protected function isValueEmpty($value)
132+
{
133+
return empty($value);
134+
}
119135
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ public function testNormalize($value)
2424
$this->assertSame($value, $node->normalize($value));
2525
}
2626

27+
/**
28+
* @dataProvider getValidValues
29+
*
30+
* @param bool $value
31+
*/
32+
public function testValidNonEmptyValues($value)
33+
{
34+
$node = new BooleanNode('test');
35+
$node->setAllowEmptyValue(false);
36+
37+
$this->assertSame($value, $node->finalize($value));
38+
}
39+
2740
public function getValidValues()
2841
{
2942
return array(

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ public function testNormalize($value)
2424
$this->assertSame($value, $node->normalize($value));
2525
}
2626

27+
/**
28+
* @dataProvider getValidValues
29+
*
30+
* @param int $value
31+
*/
32+
public function testValidNonEmptyValues($value)
33+
{
34+
$node = new FloatNode('test');
35+
$node->setAllowEmptyValue(false);
36+
37+
$this->assertSame($value, $node->finalize($value));
38+
}
39+
2740
public function getValidValues()
2841
{
2942
return array(

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ public function testNormalize($value)
2424
$this->assertSame($value, $node->normalize($value));
2525
}
2626

27+
/**
28+
* @dataProvider getValidValues
29+
*
30+
* @param int $value
31+
*/
32+
public function testValidNonEmptyValues($value)
33+
{
34+
$node = new IntegerNode('test');
35+
$node->setAllowEmptyValue(false);
36+
37+
$this->assertSame($value, $node->finalize($value));
38+
}
39+
2740
public function getValidValues()
2841
{
2942
return array(

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,51 @@ public function testNormalizeThrowsExceptionWithErrorMessage()
7676

7777
$node->normalize(array());
7878
}
79+
80+
/**
81+
* @dataProvider getValidNonEmptyValues
82+
*
83+
* @param mixed $value
84+
*/
85+
public function testValidNonEmptyValues($value)
86+
{
87+
$node = new ScalarNode('test');
88+
$node->setAllowEmptyValue(false);
89+
90+
$this->assertSame($value, $node->finalize($value));
91+
}
92+
93+
public function getValidNonEmptyValues()
94+
{
95+
return array(
96+
array(false),
97+
array(true),
98+
array('foo'),
99+
array(0),
100+
array(1),
101+
array(0.0),
102+
array(0.1),
103+
);
104+
}
105+
106+
/**
107+
* @dataProvider getEmptyValues
108+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
109+
*
110+
* @param mixed $value
111+
*/
112+
public function testNotAllowedEmptyValuesThrowException($value)
113+
{
114+
$node = new ScalarNode('test');
115+
$node->setAllowEmptyValue(false);
116+
$node->finalize($value);
117+
}
118+
119+
public function getEmptyValues()
120+
{
121+
return array(
122+
array(null),
123+
array(''),
124+
);
125+
}
79126
}

src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,18 @@ private function findNodes()
166166
$container = $this->cloneContainer();
167167

168168
foreach ($container->getDefinitions() as $id => $definition) {
169-
$className = $definition->getClass();
169+
$class = $definition->getClass();
170+
171+
if ('\\' === substr($class, 0, 1)) {
172+
$class = substr($class, 1);
173+
}
170174

171175
try {
172-
$className = $this->container->getParameterBag()->resolveValue($className);
176+
$class = $this->container->getParameterBag()->resolveValue($class);
173177
} catch (ParameterNotFoundException $e) {
174178
}
175179

176-
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $className), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted')));
180+
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => array_merge($this->options['node.definition'], array('style' => $definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope(false) ? 'filled' : 'dotted')));
177181
$container->setDefinition($id, new Definition('stdClass'));
178182
}
179183

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,13 @@ private function addServiceReturn($id, $definition)
372372
*/
373373
private function addServiceInstance($id, $definition)
374374
{
375-
$class = $this->dumpValue($definition->getClass());
375+
$class = $definition->getClass();
376+
377+
if ('\\' === substr($class, 0, 1)) {
378+
$class = substr($class, 1);
379+
}
380+
381+
$class = $this->dumpValue($class);
376382

377383
if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
378384
throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
@@ -560,7 +566,7 @@ private function addService($id, $definition)
560566
if ($definition->isSynthetic()) {
561567
$return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
562568
} elseif ($class = $definition->getClass()) {
563-
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.$class, $class);
569+
$return[] = sprintf('@return %s A %s instance.', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
564570
} elseif ($definition->getFactory()) {
565571
$factory = $definition->getFactory();
566572
if (is_string($factory)) {

src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ private function addService($definition, $id, \DOMElement $parent)
114114
if (null !== $id) {
115115
$service->setAttribute('id', $id);
116116
}
117-
if ($definition->getClass()) {
118-
$service->setAttribute('class', $definition->getClass());
117+
if ($class = $definition->getClass()) {
118+
if ('\\' === substr($class, 0, 1)) {
119+
$class = substr($class, 1);
120+
}
121+
122+
$service->setAttribute('class', $class);
119123
}
120124
if ($definition->getFactoryMethod(false)) {
121125
$service->setAttribute('factory-method', $definition->getFactoryMethod(false));

src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ public function dump(array $options = array())
6464
private function addService($id, $definition)
6565
{
6666
$code = " $id:\n";
67-
if ($definition->getClass()) {
68-
$code .= sprintf(" class: %s\n", $definition->getClass());
67+
if ($class = $definition->getClass()) {
68+
if ('\\' === substr($class, 0, 1)) {
69+
$class = substr($class, 1);
70+
}
71+
72+
$code .= sprintf(" class: %s\n", $class);
6973
}
7074

7175
if (!$definition->isPublic()) {

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php

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

1111
$container = new ContainerBuilder();
1212
$container
13-
->register('foo', 'Bar\FooClass')
13+
->register('foo', '\Bar\FooClass')
1414
->addTag('foo', array('foo' => 'foo'))
1515
->addTag('foo', array('bar' => 'bar', 'baz' => 'baz'))
1616
->setFactory(array('Bar\\FooClass', 'getInstance'))

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ public function testTransformWrapsIntlErrors()
170170
{
171171
$transformer = new DateTimeToLocalizedStringTransformer();
172172

173+
$this->markTestIncomplete('Checking for intl errors needs to be reimplemented');
174+
173175
// HOW TO REPRODUCE?
174176
175-
//$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\Transdate_formationFailedException');
177+
//$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\TransformationFailedException');
176178

177179
//$transformer->transform(1.5);
178180
}

0 commit comments

Comments
 (0)