Skip to content

Commit 330c09b

Browse files
committed
Merge branch '3.0' into 3.1
* 3.0: [Yaml] fix exception contexts People - person singularization [Yaml] properly handle unindented collections [Serializer] Add test for ignored attributes during denormalization chomp newlines only at the end of YAML documents Fixed server status command when port has been omitted Update UPGRADE FROM 2.x to 3.0 fix removed commands wording in upgrade file Catch \Throwable Catch \Throwable [DependencyInjection] Avoid generating call_user_func in more cases [Validator] Support for DateTimeImmutable [FrameworkBundle] update upgrade instructions Use levenshtein level for better Bundle matching [WebProfilerBundle] Fix CORS ajax security issues remove methods that were needed for PHP 5.3 [DX][DI] Make Autowiring exceptions more future friendly
2 parents 55d9a7a + 90dcd92 commit 330c09b

File tree

24 files changed

+290
-67
lines changed

24 files changed

+290
-67
lines changed

UPGRADE-3.0.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,11 @@ UPGRADE FROM 2.x to 3.0
398398
</service>
399399
```
400400

401-
* The `ChoiceToBooleanArrayTransformer`, `ChoicesToBooleanArrayTransformer`,
402-
`FixRadioInputListener`, and `FixCheckboxInputListener` classes were removed.
401+
* The `max_length` option was removed. Use the `attr` option instead by setting it to
402+
an `array` with a `maxlength` key.
403+
404+
* The `ChoiceToBooleanArrayTransformer`, `ChoicesToBooleanArrayTransformer`,
405+
`FixRadioInputListener`, and `FixCheckboxInputListener` classes were removed.
403406

404407
* The `choice_list` option of `ChoiceType` was removed.
405408

@@ -636,6 +639,11 @@ UPGRADE FROM 2.x to 3.0
636639
be removed in Symfony 3.0. Use the `debug:config`, `debug:container`,
637640
`debug:router`, `debug:translation` and `lint:yaml` commands instead.
638641

642+
* The base `Controller`class is now abstract.
643+
644+
* The visibility of all methods of the base `Controller` class has been changed from
645+
`public` to `protected`.
646+
639647
* The `getRequest` method of the base `Controller` class has been deprecated
640648
since Symfony 2.4 and must be therefore removed in 3.0. The only reliable
641649
way to get the `Request` object is to inject it in the action method.
@@ -1737,8 +1745,7 @@ UPGRADE FROM 2.x to 3.0
17371745

17381746
### WebProfiler
17391747

1740-
* The `profiler:import` and `profiler:export` commands have been deprecated and
1741-
will be removed in 3.0.
1748+
* The `profiler:import` and `profiler:export` commands have been removed.
17421749

17431750
* All the profiler storages different than `FileProfilerStorage` have been
17441751
removed. The removed classes are:

src/Symfony/Bundle/FrameworkBundle/Command/ServerStatusCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Console\Input\InputArgument;
1515
use Symfony\Component\Console\Input\InputInterface;
16+
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Style\SymfonyStyle;
1819

@@ -32,6 +33,7 @@ protected function configure()
3233
$this
3334
->setDefinition(array(
3435
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
36+
new InputOption('port', 'p', InputOption::VALUE_REQUIRED, 'Address port number', '8000'),
3537
))
3638
->setName('server:status')
3739
->setDescription('Outputs the status of the built-in web server for the given address')
@@ -46,6 +48,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
4648
$io = new SymfonyStyle($input, $output);
4749
$address = $input->getArgument('address');
4850

51+
if (false === strpos($address, ':')) {
52+
$address = $address.':'.$input->getOption('port');
53+
}
54+
4955
// remove an orphaned lock file
5056
if (file_exists($this->getLockFile($address)) && !$this->isServerRunning($address)) {
5157
unlink($this->getLockFile($address));

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ private function findAlternative($nonExistentBundleName)
142142
$lev = levenshtein($nonExistentBundleName, $bundleName);
143143
if ($lev <= strlen($nonExistentBundleName) / 3 && ($alternative === null || $lev < $shortest)) {
144144
$alternative = $bundleName;
145+
$shortest = $lev;
145146
}
146147
}
147148

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function testBuild()
5959
{
6060
$parser = $this->createParser();
6161

62-
$this->assertEquals('FooBundle:Default:index', $parser->build('TestBundle\FooBundle\Controller\DefaultController::indexAction'), '->parse() converts a class::method string to a short a:b:c notation string');
63-
$this->assertEquals('FooBundle:Sub\Default:index', $parser->build('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction'), '->parse() converts a class::method string to a short a:b:c notation string');
62+
$this->assertEquals('FoooooBundle:Default:index', $parser->build('TestBundle\FooBundle\Controller\DefaultController::indexAction'), '->parse() converts a class::method string to a short a:b:c notation string');
63+
$this->assertEquals('FoooooBundle:Sub\Default:index', $parser->build('TestBundle\FooBundle\Controller\Sub\DefaultController::indexAction'), '->parse() converts a class::method string to a short a:b:c notation string');
6464

6565
try {
6666
$parser->build('TestBundle\FooBundle\Controller\DefaultController::index');
@@ -132,8 +132,9 @@ public function testInvalidBundleName($bundleName, $suggestedBundleName)
132132
public function getInvalidBundleNameTests()
133133
{
134134
return array(
135-
array('FoodBundle:Default:index', 'FooBundle:Default:index'),
136-
array('CrazyBundle:Default:index', false),
135+
'Alternative will be found using levenshtein' => array('FoodBundle:Default:index', 'FooBundle:Default:index'),
136+
'Alternative will be found using partial match' => array('FabpotFooBund:Default:index', 'FabpotFooBundle:Default:index'),
137+
'Bundle does not exist at all' => array('CrazyBundle:Default:index', false),
137138
);
138139
}
139140

@@ -162,6 +163,7 @@ private function createParser()
162163
$bundles = array(
163164
'SensioFooBundle' => $this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'),
164165
'SensioCmsFooBundle' => $this->getBundle('TestBundle\Sensio\Cms\FooBundle', 'SensioCmsFooBundle'),
166+
'FoooooBundle' => $this->getBundle('TestBundle\FooBundle', 'FoooooBundle'),
165167
'FooBundle' => $this->getBundle('TestBundle\FooBundle', 'FooBundle'),
166168
'FabpotFooBundle' => $this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'),
167169
);

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@
8282
8383
requestStack = [],
8484
85+
extractHeaders = function(xhr, stackElement) {
86+
// Here we avoid to call xhr.getResponseHeader in order to
87+
// prevent polluting the console with CORS security errors
88+
var allHeaders = xhr.getAllResponseHeaders();
89+
var ret;
90+
91+
if (ret = allHeaders.match(/^x-debug-token:\s+(.*)$/im)) {
92+
stackElement.profile = ret[1];
93+
}
94+
if (ret = allHeaders.match(/^x-debug-token-link:\s+(.*)$/im)) {
95+
stackElement.profilerUrl = ret[1];
96+
}
97+
},
98+
8599
renderAjaxRequests = function() {
86100
var requestCounter = document.querySelectorAll('.sf-toolbar-ajax-requests');
87101
if (!requestCounter.length) {
@@ -255,8 +269,7 @@
255269
stackElement.loading = false;
256270
stackElement.error = self.status < 200 || self.status >= 400;
257271
stackElement.statusCode = self.status;
258-
stackElement.profile = self.getResponseHeader("X-Debug-Token");
259-
stackElement.profilerUrl = self.getResponseHeader("X-Debug-Token-Link");
272+
extractHeaders(self, stackElement);
260273
261274
Sfjs.renderAjaxRequests();
262275
}

src/Symfony/Component/Console/Helper/ProgressIndicator.php

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -76,42 +76,6 @@ public function setMessage($message)
7676
$this->display();
7777
}
7878

79-
/**
80-
* Gets the current indicator message.
81-
*
82-
* @return string|null
83-
*
84-
* @internal for PHP 5.3 compatibility
85-
*/
86-
public function getMessage()
87-
{
88-
return $this->message;
89-
}
90-
91-
/**
92-
* Gets the progress bar start time.
93-
*
94-
* @return int The progress bar start time
95-
*
96-
* @internal for PHP 5.3 compatibility
97-
*/
98-
public function getStartTime()
99-
{
100-
return $this->startTime;
101-
}
102-
103-
/**
104-
* Gets the current animated indicator character.
105-
*
106-
* @return string
107-
*
108-
* @internal for PHP 5.3 compatibility
109-
*/
110-
public function getCurrentValue()
111-
{
112-
return $this->indicatorValues[$this->indicatorCurrent % count($this->indicatorValues)];
113-
}
114-
11579
/**
11680
* Starts the indicator output.
11781
*
@@ -294,13 +258,13 @@ private static function initPlaceholderFormatters()
294258
{
295259
return array(
296260
'indicator' => function (ProgressIndicator $indicator) {
297-
return $indicator->getCurrentValue();
261+
return $indicator->indicatorValues[$indicator->indicatorCurrent % count($indicator->indicatorValues)];
298262
},
299263
'message' => function (ProgressIndicator $indicator) {
300-
return $indicator->getMessage();
264+
return $indicator->message;
301265
},
302266
'elapsed' => function (ProgressIndicator $indicator) {
303-
return Helper::formatTime(time() - $indicator->getStartTime());
267+
return Helper::formatTime(time() - $indicator->startTime);
304268
},
305269
'memory' => function () {
306270
return Helper::formatMemory(memory_get_usage(true));

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ public static function handleFatalError(array $error = null)
580580
}
581581
} catch (\Exception $exception) {
582582
// Handled below
583+
} catch (\Throwable $exception) {
584+
// Handled below
583585
}
584586

585587
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {

src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function process(ContainerBuilder $container)
4545
$this->completeDefinition($id, $definition);
4646
}
4747
}
48-
} catch (\Error $e) {
4948
} catch (\Exception $e) {
49+
} catch (\Throwable $e) {
5050
}
5151

5252
spl_autoload_unregister($throwingAutoloader);
@@ -283,7 +283,7 @@ private function createAutowiredDefinition(\ReflectionClass $typeHint, $id)
283283

284284
try {
285285
$this->completeDefinition($argumentId, $argumentDefinition);
286-
} catch (\RuntimeException $e) {
286+
} catch (RuntimeException $e) {
287287
$classOrInterface = $typeHint->isInterface() ? 'interface' : 'class';
288288
$message = sprintf('Unable to autowire argument of type "%s" for the service "%s". No services were found matching this %s and it cannot be auto-registered.', $typeHint->name, $id, $classOrInterface);
289289
throw new RuntimeException($message, 0, $e);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ private function addServiceConfigurator($id, $definition, $variableName = 'insta
542542
return sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
543543
}
544544

545+
if (0 === strpos($class, 'new ')) {
546+
return sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
547+
}
548+
545549
return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
546550
}
547551

@@ -723,6 +727,10 @@ private function addNewInstance(Definition $definition, $return, $instantiation,
723727
return sprintf(" $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : '');
724728
}
725729

730+
if (0 === strpos($class, 'new ')) {
731+
return sprintf(" $return{$instantiation}(%s)->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
732+
}
733+
726734
return sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
727735
}
728736

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@
7878
->register('configured_service', 'stdClass')
7979
->setConfigurator(array(new Reference('configurator_service'), 'configureStdClass'))
8080
;
81+
$container
82+
->register('configurator_service_simple', 'ConfClass')
83+
->addArgument('bar')
84+
->setPublic(false)
85+
;
86+
$container
87+
->register('configured_service_simple', 'stdClass')
88+
->setConfigurator(array(new Reference('configurator_service_simple'), 'configureStdClass'))
89+
;
8190
$container
8291
->register('decorated', 'stdClass')
8392
;
@@ -111,5 +120,14 @@
111120
->register('service_from_static_method', 'Bar\FooClass')
112121
->setFactory(array('Bar\FooClass', 'getInstance'))
113122
;
123+
$container
124+
->register('factory_simple', 'SimpleFactoryClass')
125+
->addArgument('foo')
126+
->setPublic(false)
127+
;
128+
$container
129+
->register('factory_service_simple', 'Bar')
130+
->setFactory(array(new Reference('factory_simple'), 'getInstance'))
131+
;
114132

115133
return $container;

src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ digraph sc {
1414
node_request [label="request\nRequest\n", shape=record, fillcolor="#eeeeee", style="filled"];
1515
node_configurator_service [label="configurator_service\nConfClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
1616
node_configured_service [label="configured_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
17+
node_configurator_service_simple [label="configurator_service_simple\nConfClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
18+
node_configured_service_simple [label="configured_service_simple\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
1719
node_decorated [label="decorated\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
1820
node_decorator_service [label="decorator_service\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
1921
node_decorator_service_with_name [label="decorator_service_with_name\nstdClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
@@ -22,6 +24,8 @@ digraph sc {
2224
node_factory_service [label="factory_service\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
2325
node_new_factory_service [label="new_factory_service\nFooBarBaz\n", shape=record, fillcolor="#eeeeee", style="filled"];
2426
node_service_from_static_method [label="service_from_static_method\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
27+
node_factory_simple [label="factory_simple\nSimpleFactoryClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
28+
node_factory_service_simple [label="factory_service_simple\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"];
2529
node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"];
2630
node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"];
2731
node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"];

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct()
4040
*/
4141
protected function getServiceFromAnonymousFactoryService()
4242
{
43-
return $this->services['service_from_anonymous_factory'] = call_user_func(array(new \Bar\FooClass(), 'getInstance'));
43+
return $this->services['service_from_anonymous_factory'] = (new \Bar\FooClass())->getInstance();
4444
}
4545

4646
/**

0 commit comments

Comments
 (0)