8000 Merge branch '3.1' · symfony/symfony@835176c · GitHub
[go: up one dir, main page]

Skip to content

Commit 835176c

Browse files
committed
Merge branch '3.1'
* 3.1: added a comment about a workaround [Finder] no PHP warning on empty directory iteration [HttpKernel] Fixed the nullable support for php 7.1 and below fixed CS [Form] Fix typo in doc comment Fix version constraint [Config] Handle open_basedir restrictions in FileLocator Fixed bad merge [DoctrineBridge][PropertyInfo] Treat Doctrine decimal type as string [bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level Use JSON_UNESCAPED_SLASHES for lint commands output Fixed collapsed ChoiceType options attributes [FrameworkBundle] Remove cache clearer default value in config Consider the umask setting when dumping a file. Fixed the nullable support for php 7.1 and below Make ReflectionExtractor compatible with ReflectionType changes in PHP 7.1
2 parents 47657e5 + ad7bc03 commit 835176c

File tree

32 files changed

+306
-38
lines changed

32 files changed

+306
-38
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ private function getPhpType($doctrineType)
178178
return Type::BUILTIN_TYPE_INT;
179179

180180
case DBALType::FLOAT:
181-
case DBALType::DECIMAL:
182181
return Type::BUILTIN_TYPE_FLOAT;
183182

184183
case DBALType::STRING:
185184
case DBALType::TEXT:
186185
case DBALType::GUID:
186+
case DBALType::DECIMAL:
187187
return Type::BUILTIN_TYPE_STRING;
188188

189189
case DBALType::BOOLEAN:

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public function testGetProperties()
4949
'time',
5050
'json',
5151
'simpleArray',
52+
'float',
53+
'decimal',
5254
'bool',
5355
'binary',
5456
'customFoo',
@@ -73,6 +75,8 @@ public function typesProvider()
7375
return array(
7476
array('id', array(new Type(Type::BUILTIN_TYPE_INT))),
7577
array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))),
78+
array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))),
79+
array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))),
7680
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),
7781
array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))),
7882
array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))),

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ class DoctrineDummy
6565
*/
6666
private $simpleArray;
6767

68+
/**
69+
* @Column(type="float")
70+
*/
71+
private $float;
72+
73+
/**
74+
* @Column(type="decimal", precision=10, scale=2)
75+
*/
76+
private $decimal;
77+
6878
/**
6979
* @Column(type="boolean")
7080
*/

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
202202
}
203203
});
204204

205-
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
205+
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
206206

207207
return min($errors, 1);
208208
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
680680
->scalarNode('provider')
681681
->info('The service name to use as provider when the specified adapter needs one.')
682682
->end()
683-
->scalarNode('clearer')->defaultValue('cache.default_clearer')->end()
683+
->scalarNode('clearer')->end()
684684
->end()
685685
->end()
686686
->validate()

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"
21
<?php if ($disabled): ?>disabled="disabled" <?php endif ?>
32
<?php foreach ($choice_attr as $k => $v): ?>
43
<?php if ($v === true): ?>

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,28 @@ public function doTestCachePools($options, $adapterClass)
6262
static::bootKernel($options);
6363
$container = static::$kernel->getContainer();
6464

65-
$pool = $container->get('cache.test');
66-
$this->assertInstanceOf($adapterClass, $pool);
65+
$pool1 = $container->get('cache.pool1');
66+
$this->assertInstanceOf($adapterClass, $pool1);
6767

6868
$key = 'foobar';
69-
$pool->deleteItem($key);
70-
$item = $pool->getItem($key);
69+
$pool1->deleteItem($key);
70+
$item = $pool1->getItem($key);
7171
$this->assertFalse($item->isHit());
7272

7373
$item->set('baz');
74-
$pool->save($item);
75-
$item = $pool->getItem($key);
74+
$pool1->save($item);
75+
$item = $pool1->getItem($key);
7676
$this->assertTrue($item->isHit());
7777

78+
$pool2 = $container->get('cache.pool2');
79+
$pool2->save($item);
80+
7881
$container->get('cache_clearer')->clear($container->getParameter('kernel.cache_dir'));
79-
$item = $pool->getItem($key);
82+
$item = $pool1->getItem($key);
8083
$this->assertFalse($item->isHit());
84+
85+
$item = $pool2->getItem($key);
86+
$this->assertTrue($item->isHit());
8187
}
8288

8389
protected static function createKernel(array $options = array())

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ imports:
44
framework:
55
cache:
66
pools:
7-
cache.test:
7+
cache.pool1:
88
public: true
9+
cache.pool2:
10+
public: true
11+
adapter: cache.pool3
12+
cache.pool3:
13+
clearer: ~

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ framework:
55
cache:
66
app: cache.adapter.redis
77
pools:
8-
cache.test:
8+
cache.pool1:
99
public: true
10+
cache.pool2:
11+
public: true
12+
clearer: ~

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CachePools/redis_custom_config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ services:
1717
framework:
1818
cache:
1919
pools:
20-
cache.test:
20+
cache.pool1:
2121
public: true
22+
cache.pool2:
23+
public: true
24+
clearer: ~

src/Symfony/Component/Config/FileLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function locate($name, $currentPath = null, $first = true)
5959
$filepaths = array();
6060

6161
foreach ($paths as $path) {
62-
if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
62+
if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
6363
if (true === $first) {
6464
return $file;
6565
}

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public function register($name)
365365
* Adds an array of command objects.
366366
*
367367
* If a Command is not enabled it will not be added.
368-
*
368+
*
369369
* @param Command[] $commands An array of commands
370370
*/
371371
public function addCommands(array $commands)
@@ -791,6 +791,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
791791

792792
if (true === $input->hasParameterOption(array('--quiet', '-q'), true)) {
793793
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
794+
$input->setInteractive(false);
794795
} else {
795796
if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || $input->getParameterOption('--verbose', false, true) === 3) {
796797
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,11 @@ public function testRun()
631631

632632
$tester->run(array('command' => 'list', '--quiet' => true));
633633
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
634+
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed');
634635

635636
$tester->run(array('command' => 'list', '-q' => true));
636637
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
638+
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed');
637639

638640
$tester->run(array('command' => 'list', '--verbose' => true));
639641
$this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');

src/Symfony/Component/Console/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/polyfill-mbstring": "~1.0",
21-
"symfony/debug": "~2.7,>=2.7.2"
21+
"symfony/debug": "~2.8|~3.0"
2222
},
2323
"require-dev": {
2424
"symfony/event-dispatcher": "~2.8|~3.0",

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,7 @@ public function dumpFile($filename, $content)
640640
throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
641641
}
642642

643-
// Ignore for filesystems that do not support umask
644-
@chmod($tmpFile, 0666);
643+
@chmod($tmpFile, 0666 & ~umask());
645644
$this->rename($tmpFile, $filename, true);
646645
}
647646

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,13 +1350,19 @@ public function testDumpFile()
13501350
{
13511351
$fi 4E34 lename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
13521352

1353+
// skip mode check on Windows
1354+
if ('\\' !== DIRECTORY_SEPARATOR) {
1355+
$oldMask = umask(0002);
1356+
}
1357+
13531358
$this->filesystem->dumpFile($filename, 'bar');
13541359
$this->assertFileExists($filename);
13551360
$this->assertSame('bar', file_get_contents($filename));
13561361

13571362
// skip mode check on Windows
13581363
if ('\\' !== DIRECTORY_SEPARATOR) {
1359-
$this->assertFilePermissions(666, $filename);
1364+
$this->assertFilePermissions(664, $filename);
1365+
umask($oldMask);
13601366
}
13611367
}
13621368

src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ public function isRewindable()
137137
return $this->rewindable;
138138
}
139139

140+
// workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed
141+
if ('' === $this->getPath()) {
142+
return $this->rewindable = false;
143+
}
144+
140145
if (false !== $stream = @opendir($this->getPath())) {
141146
$infos = stream_get_meta_data($stream);
142147
closedir($stream);

src/Symfony/Component/Form/PreloadedExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Form\Exception\InvalidArgumentException;
1515

1616
/**
17-
* A form extension with preloaded types, type exceptions and type guessers.
17+
* A form extension with preloaded types, type extensions and type guessers.
1818
*
1919
* @author Bernhard Schussek <bschussek@gmail.com>
2020
*/

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,8 @@ public function testSingleChoiceAttributesWithMainAttributes()
620620
[@class="bar&baz"]
621621
[not(@required)]
622622
[
623-
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
624-
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"]
623+
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"][not(@id)][not(@name)]
624+
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"][not(@id)][not(@name)]
625625
]
626626
[count(./option)=2]
627627
'

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getArguments(Request $request, $controller)
7474
$representative = get_class($representative);
7575
}
7676

77-
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $representative, $metadata->getName()));
77+
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.', $representative, $metadata->getName()));
7878
}
7979

8080
return $arguments;

src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/DefaultValueResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface
2727
*/
2828
public function supports(Request $request, ArgumentMetadata $argument)
2929
{
30-
return $argument->hasDefaultValue();
30+
return $argument->hasDefaultValue() || $argument->isNullable();
3131
}
3232

3333
/**
3434
* {@inheritdoc}
3535
*/
3636
public function resolve(Request $request, ArgumentMetadata $argument)
3737
{
38-
yield $argument->getDefaultValue();
38+
yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null;
3939
}
4040
}

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
2727
{
2828
private $logger;
2929

30+
/**
31+
* If the ...$arg functionality is available.
32+
*
33+
* Requires at least PHP 5.6.0 or HHVM 3.9.1
34+
*
35+
* @var bool
36+
*/
37+
private $supportsVariadic;
38+
3039
/**
3140
* Constructor.
3241
*
@@ -35,6 +44,8 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
3544
public function __construct(LoggerInterface $logger = null)
3645
{
3746
$this->logger = $logger;
47+
48+
$this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic');
3849
}
3950

4051
/**
@@ -104,6 +115,12 @@ public function getArguments(Request $request, $controller)
104115
}
105116

106117
/**
118+
* @param Request $request
119+
* @param callable $controller
120+
* @param \ReflectionParameter[] $parameters
121+
*
122+
* @return array The arguments to use when calling the action
123+
*
107124
* @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.
108125
*/
109126
protected function doGetArguments(Request $request, $controller, array $parameters)
@@ -114,7 +131,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete
114131
$arguments = array();
115132
foreach ($parameters as $param) {
116133
if (array_key_exists($param->name, $attributes)) {
117-
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
134+
if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) {
118135
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
119136
} else {
120137
$arguments[] = $attributes[$param->name];
@@ -123,6 +140,8 @@ protected function doGetArguments(Request $request, $controller, array $paramete
123140
$arguments[] = $request;
124141
} elseif ($param->isDefaultValueAvailable()) {
125142
$arguments[] = $param->getDefaultValue();
143+
} elseif ($param->allowsNull()) {
144+
$arguments[] = null;
126145
} else {
127146
if (is_array($controller)) {
128147
$repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);

src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ class ArgumentMetadata
2323
private $isVariadic;
2424
private $hasDefaultValue;
2525
private $defaultValue;
26+
private $isNullable;
2627

2728
/**
2829
* @param string $name
2930
* @param string $type
3031
* @param bool $isVariadic
3132
* @param bool $hasDefaultValue
3233
* @param mixed $defaultValue
34+
* @param bool $isNullable
3335
*/
34-
public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue)
36+
public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue, $isNullable = false)
3537
{
3638
$this->name = $name;
3739
$this->type = $type;
3840
$this->isVariadic = $isVariadic;
3941
$this->hasDefaultValue = $hasDefaultValue;
4042
$this->defaultValue = $defaultValue;
43+
$this->isNullable = (bool) $isNullable;
4144
}
4245

4346
/**
@@ -84,6 +87,16 @@ public function hasDefaultValue()
8487
return $this->hasDefaultValue;
8588
}
8689

90+
/**
91+
* Returns whether the argument is nullable in PHP 7.1 or higher.
92+
*
93+
* @return bool
94+
*/
95+
public function isNullable()
96+
{
97+
return $this->isNullable;
98+
}
99+
87100
/**
88101
* Returns the default value of the argument.
89102
*

0 commit comments

Comments
 (0)
0