Skip to content

Commit d3692ce

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [VarDumper] Enhance docblock to tell about AbstractDumper::dumpLine(-1) [Debug] Remove false-positive check in DebugClassLoader [Validator] Fix use of GroupSequenceProvider in child classes Change number PHPDoc type to int|float [VarDumper] Strengthen dumped JS [travis] Add timing info [Validator] Fix Greek translation [Console] Initialize lazily to render exceptions properly [Validator] Add a property tag for File::$maxSize
2 parents 6434a00 + c6ffdcf commit d3692ce

File tree

13 files changed

+139
-41
lines changed

13 files changed

+139
-41
lines changed

.travis.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,38 @@ before_install:
5151
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5252
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
5353
54+
nanoseconds() {
55+
local cmd="date"
56+
local format="+%s%N"
57+
local os=$(uname)
58+
if hash gdate > /dev/null 2>&1; then
59+
cmd="gdate"
60+
elif [[ "$os" = Darwin ]]; then
61+
format="+%s000000000"
62+
fi
63+
$cmd -u $format
64+
}
65+
export -f nanoseconds
66+
5467
# tfold is a helper to create folded reports
5568
tfold () {
56-
title=$1
57-
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
69+
local title=$1
70+
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
5871
shift
59-
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
60-
bash -xc "$*" 2>&1 &&
72+
local id=$(printf %08x $(( RANDOM * RANDOM )))
73+
local start=$(nanoseconds)
74+
echo -e "travis_fold:start:$fold"
75+
echo -e "travis_time:start:$id"
76+
echo -e "\\e[1;34m$title\\e[0m"
77+
78+
bash -xc "$*" 2>&1
79+
local ok=$?
80+
local end=$(nanoseconds)
81+
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
82+
(exit $ok) &&
6183
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
62-
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
84+
echo -e "\\e[41mKO\\e[0m $title\\n"
85+
(exit $ok)
6386
}
6487
export -f tfold
6588

src/Symfony/Component/Console/Application.php

+35-9
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Application
7575
private $dispatcher;
7676
private $terminalDimensions;
7777
private $defaultCommand;
78+
private $initialized;
7879

7980
/**
8081
* Constructor.
@@ -87,12 +88,6 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
8788
$this->name = $name;
8889
$this->version = $version;
8990
$this->defaultCommand = 'list';
90-
$this->helperSet = $this->getDefaultHelperSet();
91-
$this->definition = $this->getDefaultInputDefinition();
92-
93-
foreach ($this->getDefaultCommands() as $command) {
94-
$this->add($command);
95-
}
9691
}
9792

9893
public function setDispatcher(EventDispatcherInterface $dispatcher)
@@ -192,10 +187,11 @@ public function doRun(InputInterface $input, OutputInterface $output)
192187

193188
if (!$name) {
194189
$name = $this->defaultCommand;
195-
$this->definition->setArguments(array_merge(
196-
$this->definition->getArguments(),
190+
$definition = $this->getDefinition();
191+
$definition->setArguments(array_merge(
192+
$definition->getArguments(),
197193
array(
198-
'command' => new InputArgument('command', InputArgument::OPTIONAL, $this->definition->getArgument('command')->getDescription(), $name),
194+
'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
199195
)
200196
));
201197
}
@@ -228,6 +224,10 @@ public function setHelperSet(HelperSet $helperSet)
228224
*/
229225
public function getHelperSet()
230226
{
227+
if (!$this->helperSet) {
228+
$this->helperSet = $this->getDefaultHelperSet();
229+
}
230+
231231
return $this->helperSet;
232232
}
233233

@@ -248,6 +248,10 @@ public function setDefinition(InputDefinition $definition)
248248
*/
249249
public function getDefinition()
250250
{
251+
if (!$this->definition) {
252+
$this->definition = $this->getDefaultInputDefinition();
253+
}
254+
251255
return $this->definition;
252256
}
253257

@@ -377,6 +381,8 @@ public function addCommands(array $commands)
377381
*/
378382
public function add(Command $command)
379383
{
384+
$this->init();
385+
380386
$command->setApplication($this);
381387

382388
if (!$command->isEnabled()) {
@@ -409,6 +415,8 @@ public function add(Command $command)
409415
*/
410416
public function get($name)
411417
{
418+
$this->init();
419+
412420
if (!isset($this->commands[$name])) {
413421
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
414422
}
@@ -436,6 +444,8 @@ public function get($name)
436444
*/
437445
public function has($name)
438446
{
447+
$this->init();
448+
439449
return isset($this->commands[$name]);
440450
}
441451

@@ -513,6 +523,8 @@ public function findNamespace($namespace)
513523
*/
514524
public function find($name)
515525
{
526+
$this->init();
527+
516528
$allCommands = array_keys($this->commands);
517529
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
518530
$commands = preg_grep('{^'.$expr.'}', $allCommands);
@@ -568,6 +580,8 @@ public function find($name)
568580
*/
569581
public function all($namespace = null)
570582
{
583+
$this->init();
584+
571585
if (null === $namespace) {
572586
return $this->commands;
573587
}
@@ -1157,4 +1171,16 @@ private function extractAllNamespaces($name)
11571171

11581172
return $namespaces;
11591173
}
1174+
1175+
private function init()
1176+
{
1177+
if ($this->initialized) {
1178+
return;
1179+
}
1180+
$this->initialized = true;
1181+
1182+
foreach ($this->getDefaultCommands() as $command) {
1183+
$this->add($command);
1184+
}
1185+
}
11601186
}

src/Symfony/Component/Debug/DebugClassLoader.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class DebugClassLoader
2626
{
2727
private $classLoader;
2828
private $isFinder;
29+
private $loaded = array();
2930
private $wasFinder;
3031
private static $caseCheck;
3132
private static $deprecated = array();
@@ -164,9 +165,10 @@ public function loadClass($class)
164165
ErrorHandler::stackErrors();
165166

166167
try {
167-
if ($this->isFinder) {
168+
if ($this->isFinder && !isset($this->loaded[$class])) {
169+
$this->loaded[$class] = true;
168170
if ($file = $this->classLoader[0]->findFile($class)) {
169-
require_once $file;
171+
require $file;
170172
}
171173
} else {
172174
call_user_func($this->classLoader, $class);

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ public function testIdempotence()
5959
$this->fail('DebugClassLoader did not register');
6060
}
6161

62+
/**
63+
* @expectedException \Exception
64+
* @expectedExceptionMessage boo
65+
*/
66+
public function testThrowingClass()
67+
{
68+
try {
69+
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
70+
$this->fail('Exception expected');
71+
} catch (\Exception $e) {
72+
$this->assertSame('boo', $e->getMessage());
73+
}
74+
75+
// the second call also should throw
76+
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
77+
}
78+
6279
public function testUnsilencing()
6380
{
6481
if (\PHP_VERSION_ID >= 70000) {
@@ -128,6 +145,7 @@ class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
128145

129146
/**
130147
* @expectedException \RuntimeException
148+
* @expectedExceptionMessage Case mismatch between loaded and declared class names
131149
*/
132150
public function testNameCaseMismatch()
133151
{
@@ -149,6 +167,7 @@ class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true);
149167

150168
/**
151169
* @expectedException \RuntimeException
170+
* @expectedExceptionMessage Case mismatch between loaded and declared class names
152171
*/
153172
public function testPsr4CaseMismatch()
154173
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
throw new \Exception('boo');

src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ public function formatCurrency($value, $currency)
357357
/**
358358
* Format a number.
359359
*
360-
* @param number $value The value to format
361-
* @param int $type Type of the formatting, one of the format type constants
362-
* Only type NumberFormatter::TYPE_DEFAULT is currently supported.
360+
* @param int|float $value The value to format
361+
* @param int $type Type of the formatting, one of the format type constants
362+
* Only type NumberFormatter::TYPE_DEFAULT is currently supported.
363363
*
364364
* @return bool|string The formatted value or false on error
365365
*

src/Symfony/Component/Validator/Constraints/File.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @Annotation
1919
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
2020
*
21+
* @property int $maxSize
22+
*
2123
* @author Bernhard Schussek <bschussek@gmail.com>
2224
*/
2325
class File extends Constraint

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

+4
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ public function addGetterMethodConstraints($property, $method, array $constraint
381381
*/
382382
public function mergeConstraints(ClassMetadata $source)
383383
{
384+
if ($source->isGroupSequenceProvider()) {
385+
$this->setGroupSequenceProvider(true);
386+
}
387+
384388
foreach ($source->getConstraints() as $constraint) {
385389
$this->addConstraint(clone $constraint);
386390
}

src/Symfony/Component/Validator/Resources/translations/validators.el.xlf

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
</trans-unit>
101101
<trans-unit id="25">
102102
<source>This value is not valid.</source>
103-
<target>Αυτή η τιμή δεν είναι έκγυρη.</target>
103+
<target>Αυτή η τιμή δεν είναι έγκυρη.</target>
104104
</trans-unit>
105105
<trans-unit id="26">
106106
<source>This value is not a valid time.</source>
@@ -136,19 +136,19 @@
136136
</trans-unit>
137137
<trans-unit id="37">
138138
<source>This is not a valid IP address.</source>
139-
<target>Αυτό δεν είναι μια έκγυρη διεύθυνση IP.</target>
139+
<target>Αυτό δεν είναι μια έγκυρη διεύθυνση IP.</target>
140140
</trans-unit>
141141
<trans-unit id="38">
142142
<source>This value is not a valid language.</source>
143-
<target>Αυτή η τιμή δεν αντιστοιχεί σε μια έκγυρη γλώσσα.</target>
143+
<target>Αυτή η τιμή δεν αντιστοιχεί σε μια έγκυρη γλώσσα.</target>
144144
</trans-unit>
145145
<trans-unit id="39">
146146
<source>This value is not a valid locale.</source>
147147
<target>Αυτή η τιμή δεν αντιστοιχεί σε έκγυρο κωδικό τοποθεσίας.</target>
148148
</trans-unit>
149149
<trans-unit id="40">
150150
<source>This value is not a valid country.</source>
151-
<target>Αυτή η τιμή δεν αντιστοιχεί σε μια έκγυρη χώρα.</target>
151+
<target>Αυτή η τιμή δεν αντιστοιχεί σε μια έγκυρη χώρα.</target>
152152
</trans-unit>
153153
<trans-unit id="41">
154154
<source>This value is already used.</source>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Fixtures;
13+
14+
class GroupSequenceProviderChildEntity extends GroupSequenceProviderEntity
15+
{
16+
}

src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ClassMetadataTest extends TestCase
2424
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
2525
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
2626
const PROVIDERCLASS = 'Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity';
27+
const PROVIDERCHILDCLASS = 'Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderChildEntity';
2728

2829
protected $metadata;
2930

@@ -301,6 +302,17 @@ public function testGroupSequenceProvider()
301302
$this->assertTrue($metadata->isGroupSequenceProvider());
302303
}
303304

305+
public function testMergeConstraintsMergesGroupSequenceProvider()
306+
{
307+
$parent = new ClassMetadata(self::PROVIDERCLASS);
308+
$parent->setGroupSequenceProvider(true);
309+
310+
$metadata = new ClassMetadata(self::PROVIDERCHILDCLASS);
311+
$metadata->mergeConstraints($parent);
312+
313+
$this->assertTrue($metadata->isGroupSequenceProvider());
314+
}
315+
304316
/**
305317
* https://github.com/symfony/symfony/issues/11604.
306318
*/
@@ -309,13 +321,3 @@ public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadat
309321
$this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property');
310322
}
311323
}
312-
313-
class ParentClass
314-
{
315-
public $example = 0;
316-
}
317-
318-
class ChildClass extends ParentClass
319-
{
320-
public $example = 1; // overrides parent property of same name
321-
}

src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public function dump(Data $data, $output = null)
139139
/**
140140
* Dumps the current line.
141141
*
142-
* @param int $depth The recursive depth in the dumped structure for the line being dumped
142+
* @param int $depth The recursive depth in the dumped structure for the line being dumped,
143+
* or -1 to signal the end-of-dump to the line dumper callable
143144
*/
144145
protected function dumpLine($depth)
145146
{

0 commit comments

Comments
 (0)