8000 Merge branch '5.4' into 6.2 · symfony/symfony@749b304 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

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 749b304

Browse files
Merge branch '5.4' into 6.2
* 5.4: [FrameworkBundle] Fix Workflow without a marking store definition uses marking store definition of previously defined workflow [HttpFoundatio 8000 n] UrlHelper is now aware of RequestContext changes UrlHelper is now aware of RequestContext changes [Process] Stop the process correctly even if underlying input stream is not closed: [Notifier] Update AmazonSns url in doc from de to en [PropertyInfo] Fix `PhpStanExtractor` when constructor has no docblock
2 parents bf262b9 + 3856956 commit 749b304

File tree

12 files changed

+163
-22
lines changed

12 files changed

+163
-22
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
970970
$definitionDefinition->addArgument(new Reference(sprintf('%s.metadata_store', $workflowId)));
971971

972972
// Create MarkingStore
973+
$markingStoreDefinition = null;
973974
if (isset($workflow['marking_store']['type'])) {
974975
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
975976
$markingStoreDefinition->setArguments([
@@ -983,7 +984,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
983984
// Create Workflow
984985
$workflowDefinition = new ChildDefinition(sprintf('%s.abstract', $type));
985986
$workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition', $workflowId)));
986-
$workflowDefinition->replaceArgument(1, $markingStoreDefinition ?? null);
987+
$workflowDefinition->replaceArgument(1, $markingStoreDefinition);
987988
$workflowDefinition->replaceArgument(3, $name);
988989
$workflowDefinition->replaceArgument(4, $workflow['events_to_dispatch']);
989990

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES A3E2 : []
120120
->set('url_helper', UrlHelper::class)
121121
->args([
122122
service('request_stack'),
123-
service('router.request_context')->ignoreOnInvalid(),
123+
service('router')->ignoreOnInvalid(),
124124
])
125125
->alias(UrlHelper::class, 'url_helper')
126126

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,62 @@ public function testWorkflowValidationStateMachine()
8888
});
8989
}
9090

91+
public function testWorkflowDefaultMarkingStoreDefinition()
92+
{
93+
$container = $this->createContainerFromClosure(function ($container) {
94+
$container->loadFromExtension('framework', [
95+
'workflows' => [
96+
'workflow_a' => [
97+
'type' => 'state_machine',
98+
'marking_store' => [
99+
'type' => 'method',
100+
'property' => 'status',
101+
],
102+
'supports' => [
103+
__CLASS__,
104+
],
105+
'places' => [
106+
'a',
107+
'b',
108+
],
109+
'transitions' => [
110+
'a_to_b' => [
111+
'from' => ['a'],
112+
'to' => ['b'],
113+
],
114+
],
115+
],
116+
'workflow_b' => [
117+
'type' => 'state_machine',
118+
'supports' => [
119+
__CLASS__,
120+
],
121+
'places' => [
122+
'a',
123+
'b',
124+
],
125+
'transitions' => [
126+
'a_to_b' => [
127+
'from' => ['a'],
128+
'to' => ['b'],
129+
],
130+
],
131+
],
132+
],
133+
]);
134+
});
135+
136+
$workflowA = $container->getDefinition('state_machine.workflow_a');
137+
$argumentsA = $workflowA->getArguments();
138+
$this->assertArrayHasKey('index_1', $argumentsA, 'workflow_a has a marking_store argument');
139+
$this->assertNotNull($argumentsA['index_1'], 'workflow_a marking_store argument is not null');
140+
141+
$workflowB = $container->getDefinition('state_machine.workflow_b');
142+
$argumentsB = $workflowB->getArguments();
143+
$this->assertArrayHasKey('index_1', $argumentsB, 'workflow_b has a marking_store argument');
144+
$this->assertNull($argumentsB['index_1'], 'workflow_b marking_store argument is null');
145+
}
146+
91147
public function testRateLimiterWithLockFactory()
92148
{
93149
try {

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"symfony/deprecation-contracts": "^2.1|^3",
2626
"symfony/error-handler": "^6.1",
2727
"symfony/event-dispatcher": "^5.4|^6.0",
28-
"symfony/http-foundation": "^6.2",
28+
"symfony/http-foundation": "^6.2.11",
2929
"symfony/http-kernel": "^6.2.1",
3030
"symfony/polyfill-mbstring": "~1.0",
3131
"symfony/filesystem": "^5.4|^6.0",

src/Symfony/Component/HttpFoundation/Tests/UrlHelperTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\RequestStack;
1717
use Symfony\Component\HttpFoundation\UrlHelper;
1818
use Symfony\Component\Routing\RequestContext;
19+
use Symfony\Component\Routing\RequestContextAwareInterface;
1920

2021
class UrlHelperTest extends TestCase
2122
{
@@ -64,11 +65,46 @@ public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host
6465
}
6566

6667
$requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path);
68+
6769
$helper = new UrlHelper(new RequestStack(), $requestContext);
6870

6971
$this->assertEquals($expected, $helper->getAbsoluteUrl($path));
7072
}
7173

74+
/**
75+
* @dataProvider getGenerateAbsoluteUrlRequestContextData
76+
*/
77+
public function testGenerateAbsoluteUrlWithRequestContextAwareInterface($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected)
78+
{
79+
if (!class_exists(RequestContext::class)) {
80+
$this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.');
81+
}
82+
83+
$requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path);
84+
$contextAware = new class($requestContext) implements RequestContextAwareInterface {
85+
private $requestContext;
86+
87+
public function __construct($requestContext)
88+
{
89+
$this->requestContext = $requestContext;
90+
}
91+
92+
public function setContext(RequestContext $context)
93+
{
94+
$this->requestContext = $context;
95+
}
96+
97+
public function getContext()
98+
{
99+
return $this->requestContext;
100+
}
101+
};
102+
103+
$helper = new UrlHelper(new RequestStack(), $contextAware);
104+
105+
$this->assertEquals($expected, $helper->getAbsoluteUrl($path));
106+
}
107+
72108
/**
73109
* @dataProvider getGenerateAbsoluteUrlRequestContextData
74110
*/

src/Symfony/Component/HttpFoundation/UrlHelper.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpFoundation;
1313

1414
use Symfony\Component\Routing\RequestContext;
15+
use Symfony\Component\Routing\RequestContextAwareInterface;
1516

1617
/**
1718
* A helper service for manipulating URLs within and outside the request scope.
@@ -20,13 +21,11 @@
2021
*/
2122
final class UrlHelper
2223
{
23-
private RequestStack $requestStack;
24-
private ?RequestContext $requestContext;
2524

26-
public function __construct(RequestStack $requestStack, RequestContext $requestContext = null)
27-
{
28-
$this->requestStack = $requestStack;
29-
$this->requestContext = $requestContext;
25+
public function __construct(
26+
private RequestStack $requestStack,
27+
private RequestContextAwareInterface|RequestContext|null $requestContext = null,
28+
) {
3029
}
3130

3231
public function getAbsoluteUrl(string $path): string
@@ -73,28 +72,36 @@ public function getRelativePath(string $path): string
7372

7473
private function getAbsoluteUrlFromContext(string $path): string
7574
{
76-
if (null === $this->requestContext || '' === $host = $this->requestContext->getHost()) {
75+
if (null === $context = $this->requestContext) {
76+
return $path;
77+
}
78+
79+
if ($context instanceof RequestContextAwareInterface) {
80+
$context = $context->getContext();
81+
}
82+
83+
if ('' === $host = $context->getHost()) {
7784
return $path;
7885
}
7986

80-
$scheme = $this->requestContext->getScheme();
87+
$scheme = $context->getScheme();
8188
$port = '';
8289

83-
if ('http' === $scheme && 80 !== $this->requestContext->getHttpPort()) {
84-
$port = ':'.$this->requestContext->getHttpPort();
85-
} elseif ('https' === $scheme && 443 !== $this->requestContext->getHttpsPort()) {
86-
$port = ':'.$this->requestContext->getHttpsPort();
90+
if ('http' === $scheme && 80 !== $context->getHttpPort()) {
91+
$port = ':'.$context->getHttpPort();
92+
} elseif ('https' === $scheme && 443 !== $context->getHttpsPort()) {
93+
$port = ':'.$context->getHttpsPort();
8794
}
8895

8996
if ('#' === $path[0]) {
90-
$queryString = $this->requestContext->getQueryString();
91-
$path = $this->requestContext->getPathInfo().($queryString ? '?'.$queryString : '').$path;
97+
$queryString = $context->getQueryString();
98+
$path = $context->getPathInfo().($queryString ? '?'.$queryString : '').$path;
9299
} elseif ('?' === $path[0]) {
93-
$path = $this->requestContext->getPathInfo().$path;
100+
$path = $context->getPathInfo().$path;
94101
}
95102

96103
if ('/' !== $path[0]) {
97-
$path = rtrim($this->requestContext->getBaseUrl(), '/').'/'.$path;
104+
$path = rtrim($context->getBaseUrl(), '/').'/'.$path;
98105
}
99106

100107
return $scheme.'://'.$host.$port.$path;

src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Amazon Notifier
22
===============
33

4-
Provides [Amazon SNS](https://aws.amazon.com/de/sns/) integration for Symfony Notifier.
4+
Provides [Amazon SNS](https://aws.amazon.com/en/sns/) integration for Symfony Notifier.
55

66
DSN example
77
-----------

src/Symfony/Component/Process/Process.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public function wait(callable $callback = null): int
421421

422422
do {
423423
$this->checkTimeout();
424-
$running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
424+
$running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
425425
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
426426
} while ($running);
427427

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,16 @@ public function testEnvCaseInsensitiveOnWindows()
15361536
}
15371537
}
15381538

1539+
public function testNotTerminableInputPipe()
1540+
{
1541+
$process = $this->getProcess('echo foo');
1542+
$process->setInput(\STDIN);
1543+
$process->start();
1544+
$process->setTimeout(2);
1545+
$process->wait();
1546+
$this->assertFalse($process->isRunning());
1547+
}
1548+
15391549
/**
15401550
* @param string|array $commandline
15411551
* @param mixed $input

src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ private function getDocBlockFromConstructor(string $class, string $property): ?P
179179
return null;
180180
}
181181

182-
$rawDocNode = $reflectionConstructor->getDocComment();
182+
if (!$rawDocNode = $reflectionConstructor->getDocComment()) {
183+
return null;
184+
}
185+
183186
$tokens = new TokenIterator($this->lexer->tokenize($rawDocNode));
184187
$phpDocNode = $this->phpDocParser->parse($tokens);
185188
$tokens->consumeTokenType(Lexer::TOKEN_END);

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1616
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
17+
use Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummyWithoutDocBlock;
1718
use Symfony\Component\PropertyInfo\Tests\Fixtures\DefaultValue;
1819
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
1920
use Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy;
@@ -355,6 +356,14 @@ public function testExtractConstructorTypes($property, array $type = null)
355356
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
356357
}
357358

359+
/**
360+
* @dataProvider constructorTypesProvider
361+
*/
362+
public function testExtractConstructorTypesReturnNullOnEmptyDocBlock($property)
363+
{
364+
$this->assertNull($this->extractor->getTypesFromConstructor(ConstructorDummyWithoutDocBlock::class, $property));
365+
}
366+
358367
public static function constructorTypesProvider()
359368
{
360369
return [
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\Component\PropertyInfo\Tests\Fixtures;
13+
14+
class ConstructorDummyWithoutDocBlock
15+
{
16+
public function __construct(\DateTimeZone $timezone, $date, $dateObject, \DateTimeImmutable $dateTime, $mixed)
17+
{
18+
}
19+
}

0 commit comments

Comments
 (0)
0