Skip to content

Commit 25c15db

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: [Console] Fix division by 0 error [ErrorHandler] Fix error message with PHP 8.5 add test covering associated entities referenced by their primary key Add an experimental CI job for PHP 8.5 Fix change log to mentioned thrown exception [HttpClient] Always set CURLOPT_CUSTOMREQUEST to the correct HTTP method in CurlHttpClient evaluate access flags for properties with asymmetric visibility [Mime] Fix wrong PHPDoc in `FormDataPart` constructor
2 parents ffbd444 + c7b2cbc commit 25c15db

File tree

14 files changed

+143
-11
lines changed

14 files changed

+143
-11
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
mode: low-deps
3434
- php: '8.3'
3535
- php: '8.4'
36+
- php: '8.5'
3637
#mode: experimental
3738
fail-fast: false
3839

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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\Bridge\Doctrine\Tests\Fixtures;
13+
14+
class AssociatedEntityDto
15+
{
16+
public $singleId;
17+
}

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Doctrine\Persistence\ObjectManager;
2222
use PHPUnit\Framework\MockObject\MockObject;
2323
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
24+
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociatedEntityDto;
2425
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
2526
use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
2627
use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity;
@@ -609,6 +610,40 @@ public function testAssociatedEntityWithNull()
609610
$this->assertNoViolation();
610611
}
611612

613+
public function testAssociatedEntityReferencedByPrimaryKey()
614+
{
615+
$this->registry = $this->createRegistryMock($this->em);
616+
$this->registry->expects($this->any())
617+
->method('getManagerForClass')
618+
->willReturn($this->em);
619+
$this->validator = $this->createValidator();
620+
$this->validator->initialize($this->context);
621+
622+
$entity = new SingleIntIdEntity(1, 'foo');
623+
$associated = new AssociationEntity();
624+
$associated->single = $entity;
625+
626+
$this->em->persist($entity);
627+
$this->em->persist($associated);
628+
$this->em->flush();
629+
630+
$dto = new AssociatedEntityDto();
631+
$dto->singleId = 1;
632+
633+
$this->validator->validate($dto, new UniqueEntity(
634+
fields: ['singleId' => 'single'],
635+
entityClass: AssociationEntity::class,
636+
));
637+
638+
$this->buildViolation('This value is already used.')
639+
->atPath('property.path.single')
640+
->setParameter('{{ value }}', 1)
641+
->setInvalidValue(1)
642+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
643+
->setCause([$associated])
644+
->assertRaised();
645+
}
646+
612647
public function testValidateUniquenessWithArrayValue()
613648
{
614649
$repository = $this->createRepositoryMock(SingleIntIdEntity::class);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function getEstimated(): float
229229

230230
public function getRemaining(): float
231231
{
232-
if (!$this->step) {
232+
if (0 === $this->step || $this->step === $this->startingStep) {
233233
return 0;
234234
}
235235

src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ public function testRegularTimeEstimation()
110110
);
111111
}
112112

113+
public function testRegularTimeRemainingWithDifferentStartAtAndCustomDisplay()
114+
{
115+
ProgressBar::setFormatDefinition('custom', ' %current%/%max% [%bar%] %percent:3s%% %remaining% %estimated%');
116+
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);
117+
$bar->setFormat('custom');
118+
$bar->start(1_200, 600);
119+
}
120+
113121
public function testResumedTimeEstimation()
114122
{
115123
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);

src/Symfony/Component/ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var_dump([
2424
$eHandler[0]->setExceptionHandler('print_r');
2525

2626
if (true) {
27-
class Broken implements \JsonSerializable
27+
class Broken implements \Iterator
2828
{
2929
}
3030
}
@@ -37,14 +37,14 @@ array(1) {
3737
}
3838
object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
3939
["message":protected]=>
40-
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
40+
string(209) "Error: Class Symfony\Component\ErrorHandler\Broken contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Iterator::current, Iterator::next, Iterator::key, ...)"
4141
%a
4242
["error":"Symfony\Component\ErrorHandler\Error\FatalError":private]=>
4343
array(4) {
4444
["type"]=>
4545
int(1)
4646
["message"]=>
47-
string(179) "Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
47+
string(202) "Class Symfony\Component\ErrorHandler\Broken contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Iterator::current, Iterator::next, Iterator::key, ...)"
4848
["file"]=>
4949
string(%d) "%s"
5050
["line"]=>

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,12 @@ public function request(string $method, string $url, array $options = []): Respo
197197
$curlopts[\CURLOPT_RESOLVE] = $resolve;
198198
}
199199

200+
$curlopts[\CURLOPT_CUSTOMREQUEST] = $method;
200201
if ('POST' === $method) {
201202
// Use CURLOPT_POST to have browser-like POST-to-GET redirects for 301, 302 and 303
202203
$curlopts[\CURLOPT_POST] = true;
203204
} elseif ('HEAD' === $method) {
204205
$curlopts[\CURLOPT_NOBODY] = true;
205-
} else {
206-
$curlopts[\CURLOPT_CUSTOMREQUEST] = $method;
207206
}
208207

209208
if ('\\' !== \DIRECTORY_SEPARATOR && $options['timeout'] < 1) {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,4 +656,26 @@ public function testDefaultContentType()
656656

657657
$this->assertSame(['abc' => 'def', 'content-type' => 'application/json', 'REQUEST_METHOD' => 'POST'], $response->toArray());
658658
}
659+
660+
public function testHeadRequestWithClosureBody()
661+
{
662+
$p = TestHttpServer::start(8067);
663+
664+
try {
665+
$client = $this->getHttpClient(__FUNCTION__);
666+
667+
$response = $client->request('HEAD', 'http://localhost:8057/head', [
668+
'body' => fn () => '',
669+
]);
670+
$headers = $response->getHeaders();
671+
} finally {
672+
$p->stop();
673+
}
674+
675+
$this->assertArrayHasKey('x-request-vars', $headers);
676+
677+
$vars = json_decode($headers['x-request-vars'][0], true);
678+
$this->assertIsArray($vars);
679+
$this->assertSame('HEAD', $vars['REQUEST_METHOD']);
680+
}
659681
}

src/Symfony/Component/HttpClient/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": ">=8.2",
2626
"psr/log": "^1|^2|^3",
2727
"symfony/deprecation-contracts": "^2.5|^3",
28-
"symfony/http-client-contracts": "~3.4.3|^3.5.1",
28+
"symfony/http-client-contracts": "~3.4.4|^3.5.2",
2929
"symfony/service-contracts": "^2.5|^3"
3030
},
3131
"require-dev": {

src/Symfony/Component/Mime/Part/Multipart/FormDataPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
final class FormDataPart extends AbstractMultipartPart
2525
{
2626
/**
27-
* @param array<string|array|DataPart> $fields
27+
* @param array<string|array|TextPart> $fields
2828
*/
2929
public function __construct(
3030
private array $fields = [],

0 commit comments

Comments
 (0)