Skip to content

Commit 726c567

Browse files
committed
Merge branch '2.8' into 3.3
* 2.8: [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 a2d80ca + d3692ce commit 726c567

File tree

13 files changed

+139
-40
lines changed

13 files changed

+139
-40
lines changed

.travis.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,38 @@ before_install:
5656
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5757
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
5858
59+
nanoseconds() {
60+
local cmd="date"
61+
local format="+%s%N"
62+
local os=$(uname)
63+
if hash gdate > /dev/null 2>&1; then
64+
cmd="gdate"
65+
elif [[ "$os" = Darwin ]]; then
66+
format="+%s000000000"
67+
fi
68+
$cmd -u $format
69+
}
70+
export -f nanoseconds
71+
5972
# tfold is a helper to create folded reports
6073
tfold () {
61-
title=$1
62-
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
74+
local title=$1
75+
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
6376
shift
64-
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
65-
bash -xc "$*" 2>&1 &&
77+
local id=$(printf %08x $(( RANDOM * RANDOM )))
78+
local start=$(nanoseconds)
79+
echo -e "travis_fold:start:$fold"
80+
echo -e "travis_time:start:$id"
81+
echo -e "\\e[1;34m$title\\e[0m"
82+
83+
bash -xc "$*" 2>&1
84+
local ok=$?
85+
local end=$(nanoseconds)
86+
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
87+
(exit $ok) &&
6688
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
67-
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
89+
echo -e "\\e[41mKO\\e[0m $title\\n"
90+
(exit $ok)
6891
}
6992
export -f tfold
7093

src/Symfony/Component/Console/Application.php

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Application
7272
private $terminal;
7373
private $defaultCommand;
7474
private $singleCommand;
75+
private $initialized;
7576

7677
/**
7778
* @param string $name The name of the application
@@ -83,12 +84,6 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
8384
$this->version = $version;
8485
$this->terminal = new Terminal();
8586
$this->defaultCommand = 'list';
86-
$this->helperSet = $this->getDefaultHelperSet();
87-
$this->definition = $this->getDefaultInputDefinition();
88-
89-
foreach ($this->getDefaultCommands() as $command) {
90-
$this->add($command);
91-
}
9287
}
9388

9489
public function setDispatcher(EventDispatcherInterface $dispatcher)
@@ -195,10 +190,11 @@ public function doRun(InputInterface $input, OutputInterface $output)
195190

196191
if (!$name) {
197192
$name = $this->defaultCommand;
198-
$this->definition->setArguments(array_merge(
199-
$this->definition->getArguments(),
193+
$definition = $this->getDefinition();
194+
$definition->setArguments(array_merge(
195+
$definition->getArguments(),
200196
array(
201-
'command' => new InputArgument('command', InputArgument::OPTIONAL, $this->definition->getArgument('command')->getDescription(), $name),
197+
'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
202198
)
203199
));
204200
}
@@ -248,6 +244,10 @@ public function setHelperSet(HelperSet $helperSet)
248244
*/
249245
public function getHelperSet()
250246
{
247+
if (!$this->helperSet) {
248+
$this->helperSet = $this->getDefaultHelperSet();
249+
}
250+
251251
return $this->helperSet;
252252
}
253253

@@ -268,6 +268,10 @@ public function setDefinition(InputDefinition $definition)
268268
*/
269269
public function getDefinition()
270270
{
271+
if (!$this->definition) {
272+
$this->definition = $this->getDefaultInputDefinition();
273+
}
274+
271275
if ($this->singleCommand) {
272276
$inputDefinition = $this->definition;
273277
$inputDefinition->setArguments();
@@ -424,6 +428,8 @@ public function addCommands(array $commands)
424428
*/
425429
public function add(Command $command)
426430
{
431+
$this->init();
432+
427433
$command->setApplication($this);
428434

429435
if (!$command->isEnabled()) {
@@ -456,6 +462,8 @@ public function add(Command $command)
456462
*/
457463
public function get($name)
458464
{
465+
$this->init();
466+
459467
if (!isset($this->commands[$name])) {
460468
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
461469
}
@@ -483,6 +491,8 @@ public function get($name)
483491
*/
484492
public function has($name)
485493
{
494+
$this->init();
495+
486496
return isset($this->commands[$name]);
487497
}
488498

@@ -560,6 +570,8 @@ public function findNamespace($namespace)
560570
*/
561571
public function find($name)
562572
{
573+
$this->init();
574+
563575
$allCommands = array_keys($this->commands);
564576
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
565577
$commands = preg_grep('{^'.$expr.'}', $allCommands);
@@ -626,6 +638,8 @@ public function find($name)
626638
*/
627639
public function all($namespace = null)
628640
{
641+
$this->init();
642+
629643
if (null === $namespace) {
630644
return $this->commands;
631645
}
@@ -1139,4 +1153,16 @@ private function extractAllNamespaces($name)
11391153

11401154
return $namespaces;
11411155
}
1156+
1157+
private function init()
1158+
{
1159+
if ($this->initialized) {
1160+
return;
1161+
}
1162+
$this->initialized = true;
1163+
1164+
foreach ($this->getDefaultCommands() as $command) {
1165+
$this->add($command);
1166+
}
1167+
}
11421168
}

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 4 additions & 2 deletions
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 static $caseCheck;
3031
private static $final = array();
3132
private static $finalMethods = array();
@@ -139,9 +140,10 @@ public function loadClass($class)
139140
ErrorHandler::stackErrors();
140141

141142
try {
142-
if ($this->isFinder) {
143+
if ($this->isFinder && !isset($this->loaded[$class])) {
144+
$this->loaded[$class] = true;
143145
if ($file = $this->classLoader[0]->findFile($class)) {
144-
require_once $file;
146+
require $file;
145147
}
146148
} else {
147149
call_user_func($this->classLoader, $class);

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

Lines changed: 19 additions & 0 deletions
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) {
@@ -124,6 +141,7 @@ class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
124141

125142
/**
126143
* @expectedException \RuntimeException
144+
* @expectedExceptionMessage Case mismatch between loaded and declared class names
127145
*/
128146
public function testNameCaseMismatch()
129147
{
@@ -145,6 +163,7 @@ class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true);
145163

146164
/**
147165
* @expectedException \RuntimeException
166+
* @expectedExceptionMessage Case mismatch between loaded and declared class names
148167
*/
149168
public function testPsr4CaseMismatch()
150169
{
Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 0 deletions
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 <[email protected]>
2224
*/
2325
class File extends Constraint

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ public function addGetterMethodConstraints($property, $method, array $constraint
339339
*/
340340
public function mergeConstraints(ClassMetadata $source)
341341
{
342+
if ($source->isGroupSequenceProvider()) {
343+
$this->setGroupSequenceProvider(true);
344+
}
345+
342346
foreach ($source->getConstraints() as $constraint) {
343347
$this->addConstraint(clone $constraint);
344348
}

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

Lines changed: 4 additions & 4 deletions
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>
Lines changed: 16 additions & 0 deletions
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 <[email protected]>
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+
}

0 commit comments

Comments
 (0)