8000 Merge branch '3.4' into 2.7-monolog-exclude-http-codes · symfony/symfony@33e4c94 · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 33e4c94

Browse files
authored
Merge branch '3.4' into 2.7-monolog-exclude-http-codes
2 parents 7beede2 + 531b294 commit 33e4c94

File tree

146 files changed

+2368
-1747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2368
-1747
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: php
22

3+
dist: precise
34
sudo: false
45

56
git:

UPGRADE-3.3.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Console
7272
have been deprecated in favor of the `console.error` event and the `ConsoleErrorEvent`
7373
class. The deprecated event and class will be removed in 4.0.
7474

75+
* The `SymfonyQuestionHelper::ask` default validation has been deprecated and will be removed in 4.0. Apply validation using `Question::setValidator` instead.
76+
7577
Debug
7678
-----
7779

@@ -365,16 +367,14 @@ Yaml
365367

366368
* Deprecated support for implicitly parsing non-string mapping keys as strings.
367369
Mapping keys that are no strings will lead to a `ParseException` in Symfony
368-
4.0. Use the `PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as
369-
strings.
370+
4.0. Use quotes to opt-in for keys to be parsed as strings.
370371

371372
Before:
372373

373374
```php
374375
$yaml = <<<YAML
375376
null: null key
376377
true: boolean true
377-
1: integer key
378378
2.0: float key
379379
YAML;
380380

@@ -386,13 +386,12 @@ Yaml
386386
```php
387387

388388
$yaml = <<<YAML
389-
null: null key
390-
true: boolean true
391-
1: integer key
392-
2.0: float key
389+
"null": null key
390+
"true": boolean true
391+
"2.0": float key
393392
YAML;
394393

395-
Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS);
394+
Yaml::parse($yaml);
396395
```
397396

398397
* Omitting the key of a mapping is deprecated and will throw a `ParseException` in Symfony 4.0.

UPGRADE-3.4.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@ SecurityBundle
7777

7878
* `FirewallContext::getListeners()` now returns `\Traversable|array`
7979

80+
TwigBridge
81+
----------
82+
83+
* deprecated the `Symfony\Bridge\Twig\Form\TwigRenderer` class, use the `FormRenderer`
84+
class from the Form component instead
85+
86+
* deprecated `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability
87+
to pass a command name as first argument
88+
89+
* deprecated `Symfony\Bridge\Twig\Command\LintCommand::set/getTwigEnvironment` and the ability
90+
to pass a command name as first argument
91+
92+
TwigBundle
93+
----------
94+
95+
* deprecated the `Symfony\Bundle\TwigBundle\Command\DebugCommand` class, use the `DebugCommand`
96+
class from the Twig bridge instead
97+
98+
* deprecated relying on the `ContainerAwareInterface` implementation for
99+
`Symfony\Bundle\TwigBundle\Command\LintCommand`
100+
80101
Validator
81102
---------
82103

UPGRADE-4.0.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Console
6161
* The `console.exception` event and the related `ConsoleExceptionEvent` class have
6262
been removed in favor of the `console.error` event and the `ConsoleErrorEvent` class.
6363

64+
* The `SymfonyQuestionHelper::ask` default validation has been removed in favor of `Question::setValidator`.
65+
6466
Debug
6567
-----
6668

@@ -334,15 +336,12 @@ FrameworkBundle
334336
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class
335337
has been removed. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass`
336338
class instead.
337-
339+
338340
* Using the `KERNEL_DIR` environment variable and the automatic guessing based
339341
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
340342
method implementation. Set the `KERNEL_CLASS` environment variable to the
341343
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
342344
or `KernelTestCase::getKernelClass()` method instead.
343-
344-
* The methods `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
345-
have been removed.
346345

347346
* The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed.
348347
Use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead.
@@ -511,9 +510,16 @@ TwigBundle
511510
* The `ContainerAwareRuntimeLoader` class has been removed. Use the
512511
Twig `Twig_ContainerRuntimeLoader` class instead.
513512

513+
* Removed `DebugCommand` in favor of `Symfony\Bridge\Twig\Command\DebugCommand`.
514+
515+
* Removed `ContainerAwareInterface` implementation in `Symfony\Bundle\TwigBundle\Command\LintCommand`.
516+
514517
TwigBridge
515518
----------
516519

520+
* removed the `Symfony\Bridge\Twig\Form\TwigRenderer` class, use the `FormRenderer`
521+
class from the Form component instead
522+
517523
* Removed the possibility to inject the Form `TwigRenderer` into the `FormExtension`.
518524
Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load
519525
the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead.
@@ -548,6 +554,12 @@ TwigBridge
548554
* The `TwigRendererEngine::setEnvironment()` method has been removed.
549555
Pass the Twig Environment as second argument of the constructor instead.
550556

557+
* Removed `Symfony\Bridge\Twig\Command\DebugCommand::set/getTwigEnvironment` and the ability
558+
to pass a command name as first argument.
559+
560+
* Removed `Symfony\Bridge\Twig\Command\LintCommand::set/getTwigEnvironment` and the ability
561+
to pass a command name as first argument.
562+
551563
Validator
552564
---------
553565

@@ -630,16 +642,15 @@ Yaml
630642
throws a `ParseException`.
631643

632644
* Removed support for implicitly parsing non-string mapping keys as strings.
633-
Mapping keys that are no strings will result in a `ParseException`. Use the
634-
`PARSE_KEYS_AS_STRINGS` flag to opt-in for keys to be parsed as strings.
645+
Mapping keys that are no strings will result in a `ParseException`. Use
646+
quotes to opt-in for keys to be parsed as strings.
635647

636648
Before:
637649

638650
```php
639651
$yaml = <<<YAML
640652
null: null key
641653
true: boolean true
642-
1: integer key
643654
2.0: float key
644655
YAML;
645656

@@ -651,13 +662,12 @@ Yaml
651662
```php
652663

653664
$yaml = <<<YAML
654-
null: null key
655-
true: boolean true
656-
1: integer key
657-
2.0: float key
665+
"null": null key
666+
"true": boolean true
667+
"2.0": float key
658668
YAML;
659669

660-
Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS);
670+
Yaml::parse($yaml);
661671
```
662672

663673
* Omitting the key of a mapping is not supported anymore and throws a `ParseException`.

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ public function getProperties($class, array $context = array())
5050
return;
5151
}
5252

53-
return array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
53+
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
54+
55+
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) {
56+
$properties = array_filter($properties, function ($property) {
57+
return false === strpos($property, '.');
58+
});
59+
60+
$properties = array_merge($properties, array_keys($metadata->embeddedClasses));
61+
}
62+
63+
return $properties;
5464
}
5565

5666
/**
@@ -105,6 +115,10 @@ public function getTypes($class, $property, array $context = array())
105115
));
106116
}
107117

118+
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) {
119+
return array(new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class']));
120+
}
121+
108122
if ($metadata->hasField($property)) {
109123
$typeOfField = $metadata->getTypeOfField($property);
110124
$nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ public function testGetProperties()
6666
);
6767
}
6868

69+
public function testGetPropertiesWithEmbedded()
70+
{
71+
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) {
72+
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
73+
}
74+
75+
$this->assertEquals(
76+
array(
77+
'id',
78+
'embedded',
79+
),
80+
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded')
81+
);
82+
}
83+
6984
/**
7085
* @dataProvider typesProvider
7186
*/
@@ -74,6 +89,27 @@ public function testExtract($property, array $type = null)
7489
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array()));
7590
}
7691

92+
public function testExtractWithEmbedded()
93+
{
94+
if (!class_exists('Doctrine\ORM\Mapping\Embedded')) {
95+
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
96+
}
97+
98+
$expectedTypes = array(new Type(
99+
Type::BUILTIN_TYPE_OBJECT,
100+
false,
101+
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable'
102+
));
103+
104+
$actualTypes = $this->extractor->getTypes(
105+
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded',
106+
'embedded',
107+
array()
108+
);
109+
110+
$this->assertEquals($expectedTypes, $actualTypes);
111+
}
112+
77113
public function typesProvider()
78114
{
79115
return array(
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Embeddable;
16+
17+
/**
18+
* @Embeddable
19+
*
20+
* @author Udaltsov Valentin <udaltsov.valentin@gmail.com>
21+
*/
22+
class DoctrineEmbeddable
23+
{
24+
/**
25+
* @Column(type="string")
26+
*/
27+
protected $field;
28+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Entity;
16+
use Doctrine\ORM\Mapping\Id;
17+
use Doctrine\ORM\Mapping\Embedded;
18+
19+
/**
20+
* @Entity
21+
*
22+
* @author Udaltsov Valentin <udaltsov.valentin@gmail.com>
23+
*/
24+
class DoctrineWithEmbedded
25+
{
26+
/**
27+
* @Id
28+
* @Column(type="smallint")
29+
*/
30+
public $id;
31+
32+
/**
33+
* @Embedded(class="DoctrineEmbeddable")
34+
*/
35+
protected $embedded;
36+
}

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,20 @@ public function isProxyCandidate(Definition $definition)
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
public function getProxyFactoryCode(Definition $definition, $id, $methodName = null)
68+
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null)
6969
{
7070
$instantiation = 'return';
7171

7272
if ($definition->isShared()) {
7373
$instantiation .= " \$this->services['$id'] =";
7474
}
7575

76-
if (func_num_args() >= 3) {
77-
$methodName = func_get_arg(2);
78-
} else {
79-
@trigger_error(sprintf('You must use the third argument of %s to define the method to call to construct your service since version 3.1, not using it won\'t be supported in 4.0.', __METHOD__), E_USER_DEPRECATED);
80-
$methodName = 'get'.Container::camelize($id).'Service';
76+
if (null === $factoryCode) {
77+
@trigger_error(sprintf('The "%s()" method expects a third argument defining the code to execute to construct your service since version 3.4, providing it will be required in 4.0.', __METHOD__), E_USER_DEPRECATED);
78+
$factoryCode = '$this->get'.Container::camelize($id).'Service(false)';
79+
} elseif (false === strpos($factoryCode, '(')) {
80+
@trigger_error(sprintf('The "%s()" method expects its third argument to define the code to execute to construct your service since version 3.4, providing it will be required in 4.0.', __METHOD__), E_USER_DEPRECATED);
81+
$factoryCode = "\$this->$factoryCode(false)";
8182
}
8283
$proxyClass = $this->getProxyClassName($definition);
8384

@@ -92,7 +93,7 @@ public function getProxyFactoryCode(Definition $definition, $id, $methodName = n
9293
9394
$instantiation $constructorCall(
9495
function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) {
95-
\$wrappedInstance = \$this->$methodName(false);
96+
\$wrappedInstance = $factoryCode;
9697
9798
\$proxy->setProxyInitializer(null);
9899

0 commit comments

Comments
 (0)
0