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

Skip to content

Commit 414c78b

Browse files
Merge branch '5.2' into 5.3
* 5.2: [HttpClient] fix compat with cURL <= 7.37 Remove Debug component from patch-types.php [Config] fix tracking attributes in ReflectionClassResource [Process] Fix incorrect parameter type [HttpFoundation] Handle tentative return types
2 parents f640e6c + 8b2ee31 commit 414c78b

File tree

12 files changed

+89
-13
lines changed

12 files changed

+89
-13
lines changed

.github/patch-types.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):
2020
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
2121
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'):
22-
case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'):
2322
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
2423
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'):
2524
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'):

src/Symfony/Component/Config/Resource/ReflectionClassResource.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ private function computeHash(): string
121121

122122
private function generateSignature(\ReflectionClass $class): iterable
123123
{
124+
if (\PHP_VERSION_ID >= 80000) {
125+
$attributes = [];
126+
foreach ($class->getAttributes() as $a) {
127+
$attributes[] = [$a->getName(), $a->getArguments()];
128+
}
129+
yield print_r($attributes, true);
130+
$attributes = [];
131+
}
132+
124133
yield $class->getDocComment();
125134
yield (int) $class->isFinal();
126135
yield (int) $class->isAbstract();
@@ -137,6 +146,14 @@ private function generateSignature(\ReflectionClass $class): iterable
137146
$defaults = $class->getDefaultProperties();
138147

139148
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
149+
if (\PHP_VERSION_ID >= 80000) {
150+
foreach ($p->getAttributes() as $a) {
151+
$attributes[] = [$a->getName(), $a->getArguments()];
152+
}
153+
yield print_r($attributes, true);
154+
$attributes = [];
155+
}
156+
140157
yield $p->getDocComment();
141158
yield $p->isDefault() ? '<default>' : '';
142159
yield $p->isPublic() ? 'public' : 'protected';
@@ -147,9 +164,25 @@ private function generateSignature(\ReflectionClass $class): iterable
147164
}
148165

149166
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
167+
if (\PHP_VERSION_ID >= 80000) {
168+
foreach ($m->getAttributes() as $a) {
169+
$attributes[] = [$a->getName(), $a->getArguments()];
170+
}
171+
yield print_r($attributes, true);
172+
$attributes = [];
173+
}
174+
150175
$defaults = [];
151176
$parametersWithUndefinedConstants = [];
152177
foreach ($m->getParameters() as $p) {
178+
if (\PHP_VERSION_ID >= 80000) {
179+
foreach ($p->getAttributes() as $a) {
180+
$attributes[] = [$a->getName(), $a->getArguments()];
181+
}
182+
yield print_r($attributes, true);
183+
$attributes = [];
184+
}
185+
153186
if (!$p->isDefaultValueAvailable()) {
154187
$defaults[$p->name] = null;
155188

src/Symfony/Component/Config/Tests/Resource/ReflectionClassResourceTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ public function provideHashedSignature(): iterable
121121
{
122122
yield [false, 0, "// line change\n\n"];
123123
yield [true, 0, '/** class docblock */'];
124+
125+
if (\PHP_VERSION_ID >= 80000) {
126+
yield [true, 0, '#[Foo]'];
127+
}
128+
124129
yield [true, 1, 'abstract class %s'];
125130
yield [true, 1, 'final class %s'];
126131
yield [true, 1, 'class %s extends Exception'];
@@ -140,6 +145,12 @@ public function provideHashedSignature(): iterable
140145
yield [false, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"];
141146
yield [true, 12, '/** prot docblock */'];
142147
yield [true, 13, 'protected function prot($a = [123]) {}'];
148+
149+
if (\PHP_VERSION_ID >= 80000) {
150+
yield [true, 13, '#[Foo] protected function prot($a = []) {}'];
151+
yield [true, 13, 'protected function prot(#[Foo] $a = []) {}'];
152+
}
153+
143154
yield [false, 14, '/** priv docblock */'];
144155
yield [false, 15, ''];
145156

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function request(string $method, string $url, array $options = []): Respo
311311
}
312312

313313
foreach ($curlopts as $opt => $value) {
314-
if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt) {
314+
if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt && (!\defined('CURLOPT_HEADEROPT') || \CURLOPT_HEADEROPT !== $opt)) {
315315
$constantName = $this->findConstantName($opt);
316316
throw new TransportException(sprintf('Curl option "%s" is not supported.', $constantName ?? $opt));
317317
}
@@ -552,7 +552,6 @@ private function validateExtraCurlOptions(array $options): void
552552
\CURLOPT_HEADER,
553553
\CURLOPT_CONNECTTIMEOUT,
554554
\CURLOPT_CONNECTTIMEOUT_MS,
555-
\CURLOPT_HEADEROPT,
556555
\CURLOPT_HTTP_VERSION,
557556
\CURLOPT_PORT,
558557
\CURLOPT_DNS_USE_GLOBAL_CACHE,
@@ -566,6 +565,10 @@ private function validateExtraCurlOptions(array $options): void
566565
$curloptsToCheck[] = \CURLOPT_HTTP09_ALLOWED;
567566
}
568567

568+
if (\defined('CURLOPT_HEADEROPT')) {
569+
$curloptsToCheck[] = \CURLOPT_HEADEROPT;
570+
}
571+
569572
$methodOpts = [
570573
\CURLOPT_POST,
571574
\CURLOPT_PUT,

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function __construct(\SessionHandlerInterface $currentHandler, \SessionHa
4141
/**
4242
* @return bool
4343
*/
44+
#[\ReturnTypeWillChange]
4445
public function close()
4546
{
4647
$result = $this->currentHandler->close();
@@ -52,6 +53,7 @@ public function close()
5253
/**
5354
* @return bool
5455
*/
56+
#[\ReturnTypeWillChange]
5557
public function destroy($sessionId)
5658
{
5759
$result = $this->currentHandler->destroy($sessionId);
@@ -63,6 +65,7 @@ public function destroy($sessionId)
6365
/**
6466
* @return bool
6567
*/
68+
#[\ReturnTypeWillChange]
6669
public function gc($maxlifetime)
6770
{
6871
$result = $this->currentHandler->gc($maxlifetime);
@@ -74,6 +77,7 @@ public function gc($maxlifetime)
7477
/**
7578
* @return bool
7679
*/
80+
#[\ReturnTypeWillChange]
7781
public function open($savePath, $sessionName)
7882
{
7983
$result = $this->currentHandler->open($savePath, $sessionName);
@@ -85,6 +89,7 @@ public function open($savePath, $sessionName)
8589
/**
8690
* @return string
8791
*/
92+
#[\ReturnTypeWillChange]
8893
public function read($sessionId)
8994
{
9095
// No reading from new handler until switch-over
@@ -94,6 +99,7 @@ public function read($sessionId)
9499
/**
95100
* @return bool
96101
*/
102+
#[\ReturnTypeWillChange]
97103
public function write($sessionId, $sessionData)
98104
{
99105
$result = $this->currentHandler->write($sessionId, $sessionData);
@@ -105,6 +111,7 @@ public function write($sessionId, $sessionData)
105111
/**
106112
* @return bool
107113
*/
114+
#[\ReturnTypeWillChange]
108115
public function validateId($sessionId)
109116
{
110117
// No reading from new handler until switch-over
@@ -114,6 +121,7 @@ public function validateId($sessionId)
114121
/**
115122
* @return bool
116123
*/
124+
#[\ReturnTypeWillChange]
117125
public function updateTimestamp($sessionId, $sessionData)
118126
{
119127
$result = $this->currentHandler->updateTimestamp($sessionId, $sessionData);

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class NullSessionHandler extends AbstractSessionHandler
2121
/**
2222
* @return bool
2323
*/
24+
#[\ReturnTypeWillChange]
2425
public function close()
2526
{
2627
return true;
@@ -29,6 +30,7 @@ public function close()
2930
/**
3031
* @return bool
3132
*/
33+
#[\ReturnTypeWillChange]
3234
public function validateId($sessionId)
3335
{
3436
return true;
@@ -45,6 +47,7 @@ protected function doRead(string $sessionId)
4547
/**
4648
* @return bool
4749
*/
50+
#[\ReturnTypeWillChange]
4851
public function updateTimestamp($sessionId, $data)
4952
{
5053
return true;
@@ -69,6 +72,7 @@ protected function doDestroy(string $sessionId)
6972
/**
7073
* @return bool
7174
*/
75+
#[\ReturnTypeWillChange]
7276
public function gc($maxlifetime)
7377
{
7478
return true;

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public function isSessionExpired()
262262
/**
263263
* @return bool
264264
*/
265+
#[\ReturnTypeWillChange]
265266
public function open($savePath, $sessionName)
266267
{
267268
$this->sessionExpired = false;
@@ -276,6 +277,7 @@ public function open($savePath, $sessionName)
276277
/**
277278
* @return string
278279
*/
280+
#[\ReturnTypeWillChange]
279281
public function read($sessionId)
280282
{
281283
try {
@@ -290,6 +292,7 @@ public function read($sessionId)
290292
/**
291293
* @return bool
292294
*/
295+
#[\ReturnTypeWillChange]
293296
public function gc($maxlifetime)
294297
{
295298
// We delay gc() to close() so that it is executed outside the transactional and blocking read-write process.
@@ -369,6 +372,7 @@ protected function doWrite(string $sessionId, string $data)
369372
/**
370373
* @return bool
371374
*/
375+
#[\ReturnTypeWillChange]
372376
public function updateTimestamp($sessionId, $data)
373377
{
374378
$expiry = time() + (int) ini_get('session.gc_maxlifetime');
@@ -393,6 +397,7 @@ public function updateTimestamp($sessionId, $data)
393397
/**
394398
* @return bool
395399
*/
400+
#[\ReturnTypeWillChange]
396401
public function close()
397402
{
398403
$this->commit();

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ public function testGc()
7575
$this->currentHandler->expects($this->once())
7676
->method('gc')
7777
->with($maxlifetime)
78-
->willReturn(true);
78+
->willReturn(1);
7979

8080
$this->writeOnlyHandler->expects($this->once())
8181
->method('gc')
8282
->with($maxlifetime)
8383
->willReturn(false);
8484

85-
$result = $this->dualHandler->gc($maxlifetime);
86-
$this->assertTrue($result);
85+
$this->assertSame(1, $this->dualHandler->gc($maxlifetime));
8786
}
8887

8988
public function testOpen()

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ public function __construct(string $driverName = null, int $errorMode = null)
373373
$this->errorMode = null !== $errorMode ?: \PDO::ERRMODE_EXCEPTION;
374374
}
375375

376+
/**
377+
* @return mixed
378+
*/
379+
#[\ReturnTypeWillChange]
376380
public function getAttribute($attribute)
377381
{
378382
if (\PDO::ATTR_ERRMODE === $attribute) {
@@ -386,18 +390,24 @@ public function getAttribute($attribute)
386390
return parent::getAttribute($attribute);
387391
}
388392

393+
/**
394+
* @return false|\PDOStatement
395+
*/
396+
#[\ReturnTypeWillChange]
389397
public function prepare($statement, $driverOptions = [])
390398
{
391399
return \is_callable($this->prepareResult)
392400
? ($this->prepareResult)($statement, $driverOptions)
393401
: $this->prepareResult;
394402
}
395403

396-
public function beginTransaction()
404+
public function beginTransaction(): bool
397405
{
406+
return true;
398407
}
399408

400-
public function rollBack()
409+
public function rollBack(): bool
401410
{
411+
return true;
402412
}
403413
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public function testGc()
181181
{
182182
$handler = $this->createMock(\SessionHandlerInterface::class);
183183
$handler->expects($this->once())->method('gc')
184-
->with(123)->willReturn(true);
184+
->with(123)->willReturn(1);
185185
$proxy = new StrictSessionHandler($handler);
186186

187-
$this->assertTrue($proxy->gc(123));
187+
$this->assertSame(1, $proxy->gc(123));
188188
}
189189
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public function testCloseFalse()
9393
public function testRead()
9494
{
9595
$this->mock->expects($this->once())
96-
->method('read');
96+
->method('read')
97+
->willReturn('foo')
98+
;
9799

98100
$this->proxy->read('id');
99101
}
@@ -117,7 +119,9 @@ public function testDestroy()
117119
public function testGc()
118120
{
119121
$this->mock->expects($this->once())
120-
->method('gc');
122+
->method('gc')
123+
->willReturn(1)
124+
;
121125

122126
$this->proxy->gc(86400);
123127
}

src/Symfony/Component/Process/Pipes/WindowsPipes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct($input, bool $haveReadSupport)
7171
}
7272
$this->lockHandles[$pipe] = $h;
7373

74-
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
74+
if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) {
7575
flock($this->lockHandles[$pipe], \LOCK_UN);
7676
fclose($this->lockHandles[$pipe]);
7777
unset($this->lockHandles[$pipe]);

0 commit comments

Comments
 (0)