Skip to content

Commit e54b62c

Browse files
Merge branch '4.3' into 4.4
* 4.3: add back possibility to use form themes without translations [HttpClient] fix Psr18Client handling of non-200 response codes [WebProfilerBundle] fix FC with HttpFoundation v5 [OptionsResolver] fix adding $triggerDeprecation to Options::offsetGet() [Form] test case is not legacy Fix reporting unsilenced deprecations from insulated tests fix handling nested embeddables Added FormInterface to @return Form::getClickedButton docblock
2 parents dc7f6f7 + bde8204 commit e54b62c

File tree

12 files changed

+65
-13
lines changed

12 files changed

+65
-13
lines changed

src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEmbed.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ class DoctrineLoaderEmbed
2222
* @ORM\Column(length=25)
2323
*/
2424
public $embeddedMaxLength;
25+
26+
/**
27+
* @ORM\Embedded(class=DoctrineLoaderNestedEmbed::class)
28+
*/
29+
public $nestedEmbedded;
2530
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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\Fixtures;
13+
14+
use Doctrine\ORM\Mapping as ORM;
15+
16+
/**
17+
* @ORM\Embeddable()
18+
*/
19+
class DoctrineLoaderNestedEmbed
20+
{
21+
/**
22+
* @ORM\Column(length=27)
23+
*/
24+
public $nestedEmbeddedMaxLength;
25+
}

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser;
1717
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEmbed;
1818
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEntity;
19+
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderNestedEmbed;
1920
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderParentEntity;
2021
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
2122
use Symfony\Bridge\Doctrine\Validator\DoctrineLoader;
@@ -109,6 +110,20 @@ public function testLoadClassMetadata()
109110
$this->assertInstanceOf(Length::class, $embeddedMaxLengthConstraints[0]);
110111
$this->assertSame(25, $embeddedMaxLengthConstraints[0]->max);
111112

113+
$nestedEmbeddedMetadata = $embeddedClassMetadata->getPropertyMetadata('nestedEmbedded');
114+
$this->assertCount(1, $nestedEmbeddedMetadata);
115+
$this->assertSame(CascadingStrategy::CASCADE, $nestedEmbeddedMetadata[0]->getCascadingStrategy());
116+
$this->assertSame(TraversalStrategy::IMPLICIT, $nestedEmbeddedMetadata[0]->getTraversalStrategy());
117+
118+
$nestedEmbeddedClassMetadata = $validator->getMetadataFor(new DoctrineLoaderNestedEmbed());
119+
120+
$nestedEmbeddedMaxLengthMetadata = $nestedEmbeddedClassMetadata->getPropertyMetadata('nestedEmbeddedMaxLength');
121+
$this->assertCount(1, $nestedEmbeddedMaxLengthMetadata);
122+
$nestedEmbeddedMaxLengthConstraints = $nestedEmbeddedMaxLengthMetadata[0]->getConstraints();
123+
$this->assertCount(1, $nestedEmbeddedMaxLengthConstraints);
124+
$this->assertInstanceOf(Length::class, $nestedEmbeddedMaxLengthConstraints[0]);
125+
$this->assertSame(27, $nestedEmbeddedMaxLengthConstraints[0]->max);
126+
112127
$this->assertCount(0, $classMetadata->getPropertyMetadata('guidField'));
113128
$this->assertCount(0, $classMetadata->getPropertyMetadata('simpleArrayField'));
114129

src/Symfony/Bridge/Doctrine/Validator/DoctrineLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function loadClassMetadata(ClassMetadata $metadata): bool
7979

8080
$constraint = $this->getLengthConstraint($metadata, $mapping['fieldName']);
8181
if (null === $constraint) {
82-
if (isset($mapping['originalClass'])) {
82+
if (isset($mapping['originalClass']) && false === strpos($mapping['declaredField'], '.')) {
8383
$metadata->addPropertyConstraint($mapping['declaredField'], new Valid());
8484
} elseif (property_exists($className, $mapping['fieldName'])) {
8585
$metadata->addPropertyConstraint($mapping['fieldName'], new Length(['max' => $mapping['length']]));

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ public function endTest($test, $time)
284284
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
285285
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
286286
if ($deprecation[0]) {
287-
@trigger_error($error, E_USER_DEPRECATED);
287+
// unsilenced on purpose
288+
trigger_error($error, E_USER_DEPRECATED);
288289
} else {
289290
@trigger_error($error, E_USER_DEPRECATED);
290291
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^7.1.3",
20+
"symfony/translation-contracts": "^1.1",
2021
"twig/twig": "^1.41|^2.10"
2122
},
2223
"require-dev": {

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ protected function doRequestInProcess($request)
459459
unlink($deprecationsFile);
460460
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
461461
if ($deprecation[0]) {
462-
@trigger_error($deprecation[1], E_USER_DEPRECATED);
462+
// unsilenced on purpose
463+
trigger_error($deprecation[1], E_USER_DEPRECATED);
463464
} else {
464465
@trigger_error($deprecation[1], E_USER_DEPRECATED);
465466
}

src/Symfony/Component/Form/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
9595
private $submitted = false;
9696

9797
/**
98-
* @var ClickableInterface|null The button that was used to submit the form
98+
* @var FormInterface|ClickableInterface|null The button that was used to submit the form
9999
*/
100100
private $clickedButton;
101101

@@ -753,7 +753,7 @@ public function isValid()
753753
/**
754754
* Returns the button that was used to submit the form.
755755
*
756-
* @return ClickableInterface|null
756+
* @return FormInterface|ClickableInterface|null
757757
*/
758758
public function getClickedButton()
759759
{

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,7 @@ public function testSubmitMultipleChoiceExpandedWithEmptyDataAndInitialData()
725725
$this->assertSame(['test'], $form->getData());
726726
}
727727

728-
/**
729-
* @group legacy
730-
*/
731-
public function testLegacyNullChoices()
728+
public function testNullChoices()
732729
{
733730
$form = $this->factory->create(static::TESTED_TYPE, null, [
734731
'multiple' => false,

src/Symfony/Component/HttpClient/Psr18Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ public function sendRequest(RequestInterface $request): ResponseInterface
8686

8787
$psrResponse = $this->responseFactory->createResponse($response->getStatusCode());
8888

89-
foreach ($response->getHeaders() as $name => $values) {
89+
foreach ($response->getHeaders(false) as $name => $values) {
9090
foreach ($values as $value) {
9191
$psrResponse = $psrResponse->withAddedHeader($name, $value);
9292
}
9393
}
9494

95-
return $psrResponse->withBody($this->streamFactory->createStream($response->getContent()));
95+
return $psrResponse->withBody($this->streamFactory->createStream($response->getContent(false)));
9696
} catch (TransportExceptionInterface $e) {
9797
if ($e instanceof \InvalidArgumentException) {
9898
throw new Psr18RequestException($e, $request);

src/Symfony/Component/HttpClient/Tests/Psr18ClientTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,13 @@ public function testRequestException()
7474
$this->expectException(Psr18RequestException::class);
7575
$client->sendRequest($factory->createRequest('BAD.METHOD', 'http://localhost:8057'));
7676
}
77+
78+
public function test404()
79+
{
80+
$factory = new Psr17Factory();
81+
$client = new Psr18Client(new NativeHttpClient());
82+
83+
$response = $client->sendRequest($factory->createRequest('GET', 'http://localhost:8057/404'));
84+
$this->assertSame(404, $response->getStatusCode());
85+
}
7786
}

src/Symfony/Component/OptionsResolver/Options.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*
1717
* @author Bernhard Schussek <bschussek@gmail.com>
1818
* @author Tobias Schultze <http://tobion.de>
19-
*
20-
* @method mixed offsetGet(string $option, bool $triggerDeprecation = true)
2119
*/
2220
interface Options extends \ArrayAccess, \Countable
2321
{

0 commit comments

Comments
 (0)