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

Skip to content

Commit ac88f9a

Browse files
Merge branch '6.1' into 6.2
* 6.1: [Messenger] cs fix [Messenger] Fix time-limit check exception [Console] Fix console `ProgressBar::override()` after manual `ProgressBar::cleanup()` [FrameworkBundle] typo default_lifetime example [HttpClient] Handle Amp HTTP client v5 incompatibility gracefully [HttpKernel] Don’t try to wire Response argument with controller.service_arguments [PhpUnitBridge] Fix language deprecations incorrectly marked as direct [FrameworkBundle] Removed unused $willBeAvailable params on Configuration [Cache] Remove extra type condition in MemcachedAdapter::createConnection() Tell about messenger:consume invalid limit options [Messenger] Do not throw 'no handlers' exception when skipping due to duplicate handling
2 parents cc454cc + 636ad0d commit ac88f9a

File tree

18 files changed

+255
-33
lines changed

18 files changed

+255
-33
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function handleError($type, $msg, $file, $line, $context = [])
132132
$msg = $trace[1]['args'][0];
133133
}
134134

135-
$deprecation = new Deprecation($msg, $trace, $file);
135+
$deprecation = new Deprecation($msg, $trace, $file, \E_DEPRECATED === $type);
136136
if ($deprecation->isMuted()) {
137137
return null;
138138
}

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Deprecation
3636

3737
private $trace = [];
3838
private $message;
39+
private $languageDeprecation;
3940
private $originClass;
4041
private $originMethod;
4142
private $triggeringFile;
@@ -55,8 +56,9 @@ class Deprecation
5556
/**
5657
* @param string $message
5758
* @param string $file
59+
* @param bool $languageDeprecation
5860
*/
59-
public function __construct($message, array $trace, $file)
61+
public function __construct($message, array $trace, $file, $languageDeprecation = false)
6062
{
6163
if (isset($trace[2]['function']) && 'trigger_deprecation' === $trace[2]['function']) {
6264
$file = $trace[2]['file'];
@@ -65,6 +67,7 @@ public function __construct($message, array $trace, $file)
6567

6668
$this->trace = $trace;
6769
$this->message = $message;
70+
$this->languageDeprecation = $languageDeprecation;
6871

6972
$i = \count($trace);
7073
while (1 < $i && $this->lineShouldBeSkipped($trace[--$i])) {
@@ -238,7 +241,12 @@ public function isMuted()
238241
*/
239242
public function getType()
240243
{
241-
if (self::PATH_TYPE_SELF === $pathType = $this->getPathType($this->triggeringFile)) {
244+
$pathType = $this->getPathType($this->triggeringFile);
245+
if ($this->languageDeprecation && self::PATH_TYPE_VENDOR === $pathType) {
246+
// the triggering file must be used for language deprecations
247+
return self::TYPE_INDIRECT;
248+
}
249+
if (self::PATH_TYPE_SELF === $pathType) {
242250
return self::TYPE_SELF;
243251
}
244252
if (self::PATH_TYPE_UNDETERMINED === $pathType) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace acme\lib;
4+
5+
class PhpDeprecation implements \Serializable
6+
{
7+
public function serialize(): string
8+
{
9+
return serialize([]);
10+
}
11+
12+
public function unserialize($data): void
13+
{
14+
}
15+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Test that a PHP deprecation from a vendor class autoload is considered indirect.
3+
--SKIPIF--
4+
<?php if (\PHP_VERSION_ID < 80100) echo 'skip'; ?>
5+
--FILE--
6+
<?php
7+
8+
$k = 'SYMFONY_DEPRECATIONS_HELPER';
9+
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[total]=0');
10+
putenv('ANSICON');
11+
putenv('ConEmuANSI');
12+
putenv('TERM');
13+
14+
$vendor = __DIR__;
15+
while (!file_exists($vendor.'/vendor')) {
16+
$vendor = dirname($vendor);
17+
}
18+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
19+
require PHPUNIT_COMPOSER_INSTALL;
20+
require_once __DIR__.'/../../bootstrap.php';
21+
eval(<<<'EOPHP'
22+
namespace PHPUnit\Util;
23+
24+
class Test
25+
{
26+
public static function getGroups()
27+
{
28+
return array();
29+
}
30+
}
31+
EOPHP
32+
);
33+
require __DIR__.'/fake_vendor/autoload.php';
34+
35+
\Symfony\Component\ErrorHandler\DebugClassLoader::enable();
36+
new \acme\lib\PhpDeprecation();
37+
38+
?>
39+
--EXPECTF--
40+
Remaining indirect deprecation notices (1)
41+
42+
1x: acme\lib\PhpDeprecation implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary)
43+
1x in DebugClassLoader::loadClass from Symfony\Component\ErrorHandler

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ public function getConfigTreeBuilder(): TreeBuilder
161161
$this->addRequestSection($rootNode);
162162
$this->addAssetsSection($rootNode, $enableIfStandalone);
163163
$this->addTranslatorSection($rootNode, $enableIfStandalone);
164-
$this->addValidationSection($rootNode, $enableIfStandalone, $willBeAvailable);
164+
$this->addValidationSection($rootNode, $enableIfStandalone);
165165
$this->addAnnotationsSection($rootNode, $willBeAvailable);
166-
$this->addSerializerSection($rootNode, $enableIfStandalone, $willBeAvailable);
166+
$this->addSerializerSection($rootNode, $enableIfStandalone);
167167
$this->addPropertyAccessSection($rootNode, $willBeAvailable);
168168
$this->addPropertyInfoSection($rootNode, $enableIfStandalone);
169169
$this->addCacheSection($rootNode, $willBeAvailable);
@@ -872,7 +872,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode, callable $e
872872
;
873873
}
874874

875-
private function addValidationSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone, callable $willBeAvailable)
875+
private function addValidationSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
876876
{
877877
$rootNode
878878
->children()
@@ -982,7 +982,7 @@ private function addAnnotationsSection(ArrayNodeDefinition $rootNode, callable $
982982
;
983983
}
984984

985-
private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone, callable $willBeAvailable)
985+
private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone)
986986
{
987987
$rootNode
988988
->children()
@@ -1116,7 +1116,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode, callable $willBe
11161116
->booleanNode('public')->defaultFalse()->end()
11171117
->scalarNode('default_lifetime')
11181118
->info('Default lifetime of the pool')
1119-
->example('"600" for 5 minutes expressed in seconds, "PT5M" for five minutes expressed as ISO 8601 time interval, or "5 minutes" as a date expression')
1119+
->example('"300" for 5 minutes expressed in seconds, "PT5M" for five minutes expressed as ISO 8601 time interval, or "5 minutes" as a date expression')
11201120
->end()
11211121
->scalarNode('provider')
11221122
->info('Overwrite the setting from the default provider for this adapter.')

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ public static function createConnection(array|string $servers, array $options =
9696
{
9797
if (\is_string($servers)) {
9898
$servers = [$servers];
99-
} elseif (!\is_array($servers)) {
100-
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, "%s" given.', get_debug_type($servers)));
10199
}
102100
if (!static::isSupported()) {
103101
throw new CacheException('Memcached > 3.1.5 is required.');

src/Symfony/Component/Console/Exception/InvalidOptionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Console\Exception;
1313

1414
/**
15-
* Represents an incorrect option name typed in the console.
15+
* Represents an incorrect option name or value typed in the console.
1616
*
1717
* @author Jérôme Tamarelle <[email protected]>
1818
*/

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,13 @@ private function overwrite(string $message): void
470470
}
471471
$this->output->clear($lineCount);
472472
} else {
473-
for ($i = 0; $i < $this->formatLineCount; ++$i) {
474-
$this->cursor->moveToColumn(1);
475-
$this->cursor->clearLine();
476-
$this->cursor->moveUp();
473+
if ('' !== $this->previousMessage) {
474+
// only clear upper lines when last call was not a clear
475+
for ($i = 0; $i < $this->formatLineCount; ++$i) {
476+
$this->cursor->moveToColumn(1);
477+
$this->cursor->clearLine();
478+
$this->cursor->moveUp();
479+
}
477480
}
478481

479482
$this->cursor->moveToColumn(1);

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,10 @@ public function testMultilineFormat()
875875
$this->assertEquals(
876876
">---------------------------\nfoobar".
877877
$this->generateOutput("=========>------------------\nfoobar").
878-
"\x1B[1G\x1B[2K\x1B[1A\x1B[1G\x1B[2K".
879-
$this->generateOutput("============================\nfoobar"),
878+
"\x1B[1G\x1B[2K\x1B[1A".
879+
$this->generateOutput('').
880+
$this->generateOutput('============================').
881+
"\nfoobar",
880882
stream_get_contents($output->getStream())
881883
);
882884
}
@@ -1187,4 +1189,29 @@ public function testMultiLineFormatIsFullyCleared()
11871189
stream_get_contents($output->getStream())
11881190
);
11891191
}
1192+
1193+
public function testMultiLineFormatIsFullyCorrectlyWithManuallyCleanup()
1194+
{
1195+
ProgressBar::setFormatDefinition('normal_nomax', "[%bar%]\n%message%");
1196+
$bar = new ProgressBar($output = $this->getOutputStream());
1197+
$bar->setMessage('Processing "foobar"...');
1198+
$bar->start();
1199+
$bar->clear();
1200+
$output->writeln('Foo!');
1201+
$bar->display();
1202+
$bar->finish();
1203+
1204+
rewind($output->getStream());
1205+
$this->assertEquals(
1206+
"[>---------------------------]\n".
1207+
'Processing "foobar"...'.
1208+
"\x1B[1G\x1B[2K\x1B[1A".
1209+
$this->generateOutput('').
1210+
'Foo!'.\PHP_EOL.
1211+
$this->generateOutput('[--->------------------------]').
1212+
"\nProcessing \"foobar\"...".
1213+
$this->generateOutput("[----->----------------------]\nProcessing \"foobar\"..."),
1214+
stream_get_contents($output->getStream())
1215+
);
1216+
}
11901217
}

src/Symfony/Component/HttpClient/AmpHttpClient.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Amp\Http\Client\PooledHttpClient;
1818
use Amp\Http\Client\Request;
1919
use Amp\Http\Tunnel\Http1TunnelConnector;
20+
use Amp\Promise;
2021
use Psr\Log\LoggerAwareInterface;
2122
use Psr\Log\LoggerAwareTrait;
2223
use Symfony\Component\HttpClient\Exception\TransportException;
@@ -29,7 +30,11 @@
2930
use Symfony\Contracts\Service\ResetInterface;
3031

3132
if (!interface_exists(DelegateHttpClient::class)) {
32-
throw new \LogicException('You cannot use "Symfony\Component\HttpClient\AmpHttpClient" as the "amphp/http-client" package is not installed. Try running "composer require amphp/http-client".');
33+
throw new \LogicException('You cannot use "Symfony\Component\HttpClient\AmpHttpClient" as the "amphp/http-client" package is not installed. Try running "composer require amphp/http-client:^4.2.1".');
34+
}
35+
36+
if (!interface_exists(Promise::class)) {
37+
throw new \LogicException('You cannot use "Symfony\Component\HttpClient\AmpHttpClient" as the installed "amphp/http-client" is not compatible with this version of "symfony/http-client". Try downgrading "amphp/http-client" to "^4.2.1".');
3338
}
3439

3540
/**

0 commit comments

Comments
 (0)