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

Skip to content

Commit f309c09

Browse files
committed
Merge branch '3.4'
* 3.4: [FrameworkBundle] removed doctrine/cache as a dependency drop hard dependency on the Stopwatch component Fix the conditional definition of the SymfonyTestsListener [DI] Fix keys resolution in ResolveParameterPlaceHoldersPass [FrameworkBundle] Fix colliding service ids [FrameworkBundle] deprecated validator.mapping.cache.doctrine.apc remove now useless condition Lazy load security listeners [EventDispatcher] Remove dead code in WrappedListener [Process] Deprecate ProcessBuilder Fix non-dumped voters in security panel search case insensitive [VarDumper] Cyclic searching dumps [Yaml] Remove line number in deprecation notices [SecurityBundle] Made 2 service aliases private Automatically enable the routing annotation loader [FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS
2 parents 77639e2 + cc2363f commit f309c09

File tree

34 files changed

+289
-108
lines changed

34 files changed

+289
-108
lines changed

UPGRADE-3.4.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UPGRADE FROM 3.3 to 3.4
44
DependencyInjection
55
-------------------
66

7-
* Top-level anonymous services in XML are deprecated and will throw an exception in Symfony 4.0.
7+
* Top-level anonymous services in XML are deprecated and will throw an exception in Symfony 4.0.
88

99
Finder
1010
------
@@ -13,6 +13,38 @@ Finder
1313
deprecated and will be removed in 4.0 as it used to fix a bug which existed
1414
before version 5.5.23/5.6.7.
1515

16+
FrameworkBundle
17+
---------------
18+
19+
* The `doctrine/cache` dependency has been removed; require it via `composer
20+
require doctrine/cache` if you are using Doctrine cache in your project.
21+
22+
* The `validator.mapping.cache.doctrine.apc` service has been deprecated.
23+
24+
* The `symfony/stopwatch` dependency has been removed, require it via `composer
25+
require symfony/stopwatch` in your `dev` environment.
26+
27+
* Using the `KERNEL_DIR` environment variable or the automatic guessing based
28+
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
29+
Set the `KERNEL_CLASS` environment variable to the fully-qualified class name
30+
of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable
31+
will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()`
32+
or `KernelTestCase::getKernelClass()` method.
33+
34+
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
35+
methods are deprecated since 3.4 and will be removed in 4.0.
36+
37+
Process
38+
-------
39+
40+
* The `Symfony\Component\Process\ProcessBuilder` class has been deprecated,
41+
use the `Symfony\Component\Process\Process` class directly instead.
42+
43+
SecurityBundle
44+
--------------
45+
46+
* `FirewallContext::getListeners()` now returns `\Traversable|array`
47+
1648
Validator
1749
---------
1850

UPGRADE-4.0.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ Form
227227
FrameworkBundle
228228
---------------
229229

230+
* The `validator.mapping.cache.doctrine.apc` service has been removed.
231+
230232
* The `cache:clear` command does not warmup the cache anymore. Warmup should
231233
be done via the `cache:warmup` command.
232234

@@ -330,6 +332,15 @@ FrameworkBundle
330332
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class
331333
has been removed. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass`
332334
class instead.
335+
336+
* Using the `KERNEL_DIR` environment variable and the automatic guessing based
337+
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
338+
method implementation. Set the `KERNEL_CLASS` environment variable to the
339+
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
340+
or `KernelTestCase::getKernelClass()` method instead.
341+
342+
* The methods `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
343+
have been removed.
333344

334345
* The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed.
335346
Use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead.
@@ -411,6 +422,9 @@ Ldap
411422
Process
412423
-------
413424

425+
* The `Symfony\Component\Process\ProcessBuilder` class has been removed,
426+
use the `Symfony\Component\Process\Process` class directly instead.
427+
414428
* The `ProcessUtils::escapeArgument()` method has been removed, use a command line array or give env vars to the `Process::start/run()` method instead.
415429

416430
* Environment variables are always inherited in sub-processes.

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@
9494
"symfony/phpunit-bridge": "~3.2",
9595
"symfony/polyfill-apcu": "~1.1",
9696
"symfony/security-acl": "~2.8|~3.0",
97-
"phpdocumentor/reflection-docblock": "^3.0",
98-
"sensio/framework-extra-bundle": "^3.0.2"
97+
"phpdocumentor/reflection-docblock": "^3.0"
9998
},
10099
"conflict": {
101100
"phpdocumentor/reflection-docblock": "<3.0",

src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,53 @@
1818

1919
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
2020
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
21-
22-
return;
23-
}
24-
25-
/**
26-
* Collects and replays skipped tests.
27-
*
28-
* @author Nicolas Grekas <[email protected]>
29-
*
30-
* @final
31-
*/
32-
class SymfonyTestsListener extends BaseTestListener
33-
{
34-
private $trait;
35-
36-
public function __construct(array $mockedNamespaces = array())
21+
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
22+
// gets defined without executing the code before it and so the definition is not properly conditional)
23+
} else {
24+
/**
25+
* Collects and replays skipped tests.
26+
*
27+
* @author Nicolas Grekas <[email protected]>
28+
*
29+
* @final
30+
*/
31+
class SymfonyTestsListener extends BaseTestListener
3732
{
38-
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
39-
}
33+
private $trait;
4034

41-
public function globalListenerDisabled()
42-
{
43-
$this->trait->globalListenerDisabled();
44-
}
35+
public function __construct(array $mockedNamespaces = array())
36+
{
37+
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
38+
}
4539

46-
public function startTestSuite(TestSuite $suite)
47-
{
48-
return $this->trait->startTestSuite($suite);
49-
}
40+
public function globalListenerDisabled()
41+
{
42+
$this->trait->globalListenerDisabled();
43+
}
5044

51-
public function addSkippedTest(Test $test, \Exception $e, $time)
52-
{
53-
return $this->trait->addSkippedTest($test, $e, $time);
54-
}
45+
public function startTestSuite(TestSuite $suite)
46+
{
47+
return $this->trait->startTestSuite($suite);
48+
}
5549

56-
public function startTest(Test $test)
57-
{
58-
return $this->trait->startTest($test);
59-
}
50+
public function addSkippedTest(Test $test, \Exception $e, $time)
51+
{
52+
return $this->trait->addSkippedTest($test, $e, $time);
53+
}
6054

61-
public function addWarning(Test $test, Warning $e, $time)
62-
{
63-
return $this->trait->addWarning($test, $e, $time);
64-
}
55+
public function startTest(Test $test)
56+
{
57+
return $this->trait->startTest($test);
58+
}
6559

66-
public function endTest(Test $test, $time)
67-
{
68-
return $this->trait->endTest($test, $time);
60+
public function addWarning(Test $test, Warning $e, $time)
61+
{
62+
return $this->trait->addWarning($test, $e, $time);
63+
}
64+
65+
public function endTest(Test $test, $time)
66+
{
67+
return $this->trait->endTest($test, $time);
68+
}
6969
}
7070
}

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ CHANGELOG
1818
* Removed class parameters related to routing
1919
* Removed absolute template paths support in the template name parser
2020

21+
3.4.0
22+
-----
23+
24+
* Removed `doctrine/cache` from the list of required dependencies in `composer.json`
25+
* Deprecated `validator.mapping.cache.doctrine.apc` service
26+
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
27+
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
28+
* The `symfony/stopwatch` dependency has been removed, require it via `composer
29+
require symfony/stopwatch` in your `dev` environment.
30+
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
31+
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
32+
2133
3.3.0
2234
-----
2335

@@ -65,7 +77,7 @@ CHANGELOG
6577
`Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass` instead
6678
* Deprecated `ValidateWorkflowsPass`, use
6779
`Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass` instead
68-
* Deprecated `ConstraintValidatorFactory`, use
80+
* Deprecated `ConstraintValidatorFactory`, use
6981
`Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead.
7082

7183
3.2.0

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,18 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
628628
->info('validation configuration')
629629
->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
630630
->children()
631-
->scalarNode('cache')->end()
631+
->scalarNode('cache')
632+
->beforeNormalization()
633+
// Can be removed in 4.0, when validator.mapping.cache.doctrine.apc is removed
634+
->ifString()->then(function ($v) {
635+
if ('validator.mapping.cache.doctrine.apc' === $v && !class_exists('Doctrine\Common\Cache\ApcCache')) {
636+
throw new LogicException('Doctrine APC cache for the validator cannot be enabled as the Doctrine Cache package is not installed.');
637+
}
638+
639+
return $v;
640+
})
641+
->end()
642+
->end()
632643
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
633644
->arrayNode('static_method')
634645
->defaultValue(array('loadValidatorMetadata'))

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
1616
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1717
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
18+
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
1819
use Symfony\Component\Cache\Adapter\AdapterInterface;
1920
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2021
use Symfony\Component\Config\FileLocator;
@@ -46,6 +47,8 @@
4647
use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface;
4748
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
4849
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
50+
use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
51+
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
4952
use Symfony\Component\Serializer\Encoder\CsvEncoder;
5053
use Symfony\Component\Serializer\Encoder\DecoderInterface;
5154
use Symfony\Component\Serializer\Encoder\EncoderInterface;
@@ -56,6 +59,7 @@
5659
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
5760
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
5861
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
62+
use Symfony\Component\Stopwatch\Stopwatch;
5963
use Symfony\Component\Validator\ConstraintValidatorInterface;
6064
use Symfony\Component\Validator\ObjectInitializerInterface;
6165
use Symfony\Component\WebLink\HttpHeaderSerializer;
@@ -571,9 +575,14 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con
571575
{
572576
$loader->load('debug_prod.xml');
573577

578+
if (class_exists(Stopwatch::class)) {
579+
$container->register('debug.stopwatch', Stopwatch::class);
580+
$container->setAlias(Stopwatch::class, 'debug.stopwatch');
581+
}
582+
574583
$debug = $container->getParameter('kernel.debug');
575584

576-
if ($debug) {
585+
if ($debug && class_exists(Stopwatch::class)) {
577586
$loader->load('debug.xml');
578587
}
579588

@@ -620,6 +629,29 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
620629

621630
$container->setParameter('request_listener.http_port', $config['http_port']);
622631
$container->setParameter('request_listener.https_port', $config['https_port']);
632+
633+
if ($this->annotationsConfigEnabled) {
634+
$container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class)
635+
->setPublic(false)
636+
->addTag('routing.loader', array('priority' => -10))
637+
->addArgument(new Reference('annotation_reader'));
638+
639+
$container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class)
640+
->setPublic(false)
641+
->addTag('routing.loader', array('priority' => -10))
642+
->setArguments(array(
643+
new Reference('file_locator'),
644+
new Reference('routing.loader.annotation'),
645+
));
646+
647+
$container->register('routing.loader.annotation.file', AnnotationFileLoader::class)
648+
->setPublic(false)
649+
->addTag('routing.loader', array('priority' => -10))
650+
->setArguments(array(
651+
new Reference('file_locator'),
652+
new Reference('routing.loader.annotation'),
653+
));
654+
}
623655
}
624656

625657
/**
@@ -753,7 +785,7 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder
753785

754786
$container->setParameter('templating.helper.form.resources', $config['form']['resources']);
755787

756-
if ($container->getParameter('kernel.debug')) {
788+
if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) {
757789
$loader->load('templating_debug.xml');
758790

759791
$container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php'));
@@ -1084,6 +1116,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
10841116
$loader->load('annotations.xml');
10851117

10861118
if ('none' !== $config['cache']) {
1119+
if (!class_exists('Doctrine\Common\Cache\CacheProvider')) {
1120+
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
1121+
}
1122+
10871123
$cacheService = $config['cache'];
10881124

10891125
if ('php_array' === $config['cache']) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
<argument>true</argument>
2424
</service>
2525

26-
<service id="debug.stopwatch" class="Symfony\Component\Stopwatch\Stopwatch" public="true" />
27-
<service id="Symfony\Component\Stopwatch\Stopwatch" alias="debug.stopwatch" />
28-
2926
<service id="debug.file_link_formatter" class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter">
3027
<argument>%debug.file_link_format%</argument>
3128
</service>

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
</call>
5858
</service>
5959
</argument>
60+
<deprecated>The "%service_id%" service is deprecated since Symfony 3.4 and will be removed in 4.0. Use a Psr6 cache like "validator.mapping.cache.symfony" instead.</deprecated>
6061
</service>
6162

6263
<service id="validator.validator_factory" class="Symfony\Component\Validator\ContainerConstraintValidatorFactory">
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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\Bundle\FrameworkBundle\Routing;
13+
14+
use Symfony\Component\Routing\Loader\AnnotationClassLoader;
15+
use Symfony\Component\Routing\Route;
16+
17+
/**
18+
* AnnotatedRouteControllerLoader is an implementation of AnnotationClassLoader
19+
* that sets the '_controller' default based on the class and method names.
20+
*
21+
* @author Fabien Potencier <[email protected]>
22+
*/
23+
class AnnotatedRouteControllerLoader extends AnnotationClassLoader
24+
{
25+
/**
26+
* Configures the _controller default parameter of a given Route instance.
27+
*
28+
* @param mixed $annot The annotation class instance
29+
*/
30+
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
31+
{
32+
$route->setDefault('_controller', $class->getName().'::'.$method->getName());
33+
}
34+
35+
/**
36+
* Makes the default route name more sane by removing common keywords.
37+
*
38+
* @return string
39+
*/
40+
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
41+
{
42+
return preg_replace(array(
43+
'/(bundle|controller)_/',
44+
'/action(_\d+)?$/',
45+
'/__/',
46+
), array(
47+
'_',
48+
'\\1',
49+
'_',
50+
), parent::getDefaultRouteName($class, $method));
51+
}
52+
}

0 commit comments

Comments
 (0)