8000 Fix some deprecations on PHP 8.2 · symfony/symfony@b169934 · GitHub
[go: up one dir, main page]

Skip to content

Commit b169934

Browse files
Fix some deprecations on PHP 8.2
1 parent 75bf7fa commit b169934

File tree

18 files changed

+41
-19
lines changed

18 files changed

+41
-19
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Doctrine\DBAL\Types\Type;
1616
use Doctrine\ORM\Tools\SchemaTool;
1717
use Doctrine\Persistence\ManagerRegistry;
18-
use Doctrine\Persistence\Mapping\ClassMetadata;
18+
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1919
use Doctrine\Persistence\ObjectManager;
2020
use Doctrine\Persistence\ObjectRepository;
2121
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
@@ -111,7 +111,7 @@ protected function createEntityManagerMock($repositoryMock)
111111
->willReturn($repositoryMock)
112112
;
113113

114-
$classMetadata = $this->createMock(ClassMetadata::class);
114+
$classMetadata = $this->createMock(ClassMetadataInfo::class);
115115
$classMetadata
116116
->expects($this->any())
117117
->method('hasField')

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ function ($definition) {
194194
}
195195
}
196196

197+
#[\AllowDynamicProperties]
197198
final class DummyClass implements DummyInterface, SunnyInterface
198199
{
199200
private $ref;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddAnnotationsCachedReaderPass.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617

@@ -28,14 +29,18 @@ public function process(ContainerBuilder $container)
2829
// "annotation_reader" at build time don't get any cache
2930
foreach ($container->findTaggedServiceIds('annotations.cached_reader') as $id => $tags) {
3031
$reader = $container->getDefinition($id);
32+
$reader->setPublic(false);
3133
$properties = $reader->getProperties();
3234

3335
if (isset($properties['cacheProviderBackup'])) {
3436
$provider = $properties['cacheProviderBackup']->getValues()[0];
3537
unset($properties['cacheProviderBackup']);
3638
$reader->setProperties($properties);
37-
$container->set($id, null);
38-
$container->setDefinition($id, $reader->replaceArgument(1, $provider));
39+
$reader->replaceArgument(1, $provider);
40+
} elseif (4 <= \count($arguments = $reader->getArguments()) && $arguments[3] instanceof ServiceClosureArgument) {
41+
$arguments[1] = $arguments[3]->getValues()[0];
42+
unset($arguments[3]);
43+
$reader->setArguments($arguments);
3944
}
4045
}
4146
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,9 +1463,10 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
14631463

14641464
$container
14651465
->getDefinition('annotations.cached_reader')
1466+
->setPublic(true) // set to false in AddAnnotationsCachedReaderPass
14661467
->replaceArgument(2, $config['debug'])
1467-
// temporary property to lazy-reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
1468-
->setProperty('cacheProviderBackup', new ServiceClosureArgument(new Reference($cacheService)))
1468+
// reference the cache provider without using it until AddAnnotationsCachedReaderPass runs
1469+
->addArgument(new ServiceClosureArgument(new Reference($cacheService)))
14691470
->addTag('annotations.cached_reader')
14701471
;
14711472

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static function configureStatic1()
5656

5757
class BarUserClass
5858
{
59+
public $foo;
5960
public $bar;
6061

6162
public function __construct(BarClass $bar)

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
class FooClass
66
{
7+
public $qux;
78
public $foo;
89
public $moo;
910

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,11 @@ private function convertToHtmlEntities(string $htmlContent, string $charset = 'U
12141214
set_error_handler(function () { throw new \Exception(); });
12151215

12161216
try {
1217-
return mb_convert_encoding($htmlContent, 'HTML-ENTITIES', $charset);
1217+
return mb_encode_numericentity($htmlContent, [0x80, 0xffff, 0, 0xffff], $charset);
12181218
} catch (\Exception|\ValueError $e) {
12191219
try {
12201220
$htmlContent = iconv($charset, 'UTF-8', $htmlContent);
1221-
$htmlContent = mb_convert_encoding($htmlContent, 'HTML-ENTITIES', 'UTF-8');
1221+
$htmlContent = mb_encode_numericentity($htmlContent, [0x80, 0xffff, 0, < F438 /span>0xffff], 'UTF-8');
12221222
} catch (\Exception|\ValueError $e) {
12231223
}
12241224

src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
class MockStream
1919
{
20+
public $context;
21+
2022
/**
2123
* Opens file or URL.
2224
*

src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectDummy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\Component\Serializer\Tests\Normalizer\Features;
44

5+
#[\AllowDynamicProperties]
56
class ObjectDummy
67
{
78
protected $foo;

src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ImageValidatorTest extends ConstraintValidatorTestCase
3333
protected $imageLandscape;
3434
protected $imagePortrait;
3535
protected $image4By3;
36+
protected $image16By9;
3637
protected $imageCorrupted;
3738

3839
protected function createValidator()

src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ protected function dumpLine($depth, $endOfValue = false)
978978
}
979979
$this->lastDepth = $depth;
980980

981-
$this->line = mb_convert_encoding($this->line, 'HTML-ENTITIES', 'UTF-8');
981+
$this->line = mb_encode_numericentity($this->line, [0x80, 0xffff, 0, 0xffff], 'UTF-8');
982982

983983
if (-1 === $depth) {
984984
AbstractDumper::dumpLine(0);

src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function testHtmlDump()
175175
<span class=sf-dump-meta>trace</span>: {<samp>
176176
<span class=sf-dump-meta title="%sExceptionCasterTest.php
177177
Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%e</span>Tests%eCaster%eExceptionCasterTest.php</span>:<span class=sf-dump-num>%d</span>
178-
&hellip;%d
178+
&#8230;%d
179179
</samp>}
180180
</samp>}
181181
</bar>

src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,13 @@ public function testCastObjectStorageDumpsInfo()
166166

167167
public function testCastArrayObject()
168168
{
169-
$var = new \ArrayObject([123]);
169+
$var = new
170+
#[\AllowDynamicProperties]
171+
class([123]) extends \ArrayObject {};
170172
$var->foo = 234;
171173

172174
$expected = <<<EOTXT
173-
ArrayObject {
175+
ArrayObject@anonymous {
174176
+"foo": 234
175177
-storage: array:1 [
176178
0 => 123

src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testGet()
6666
<span class=sf-dump-key>6</span> => <span class=sf-dump-num>{$intMax}</span>
6767
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;<span class="sf-dump-default sf-dump-ns">\\n</span></span>"
6868
<span class=sf-dump-key>7</span> => b"""
69-
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">&eacute;<span class="sf-dump-default">\\x00</span>test<span class="sf-dump-default">\\t</span><span class="sf-dump-default sf-dump-ns">\\n</span></span>
69+
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">&#233;<span class="sf-dump-default">\\x00</span>test<span class="sf-dump-default">\\t</span><span class="sf-dump-default sf-dump-ns">\\n</span></span>
7070
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">ing</span>
7171
"""
7272
"<span class=sf-dump-key>[]</span>" => []

src/Symfony/Component/VarDumper/Tests/Fixtures/dumb-var.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Symfony\Component\VarDumper\Tests\Fixture;
44

55
if (!class_exists(\Symfony\Component\VarDumper\Tests\Fixture\DumbFoo::class)) {
6+
#[\AllowDynamicProperties]
67
class DumbFoo
78
{
89
public $foo = 'foo';

src/Symfony/Component/VarExporter/Tests/Fixtures/array-object.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
return \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
44
$o = [
5-
clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['ArrayObject'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('ArrayObject')),
6-
clone $p['ArrayObject'],
5+
clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['Symfony\\Component\\VarExporter\\Tests\\ArrayObject'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('Symfony\\Component\\VarExporter\\Tests\\ArrayObject')),
6+
clone ($p['ArrayObject'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('ArrayObject')),
77
],
88
null,
99
[],

src/Symfony/Component/VarExporter/Tests/InstantiatorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ public function testInstantiate()
5353
$expected = [
5454
"\0".__NAMESPACE__."\Bar\0priv" => 123,
5555
"\0".__NAMESPACE__."\Foo\0priv" => 234,
56+
'dyn' => 345,
5657
];
5758

58-
$actual = (array) Instantiator::instantiate(Bar::class, ['priv' => 123], [Foo::class => ['priv' => 234]]);
59+
$actual = (array) Instantiator::instantiate(Bar::class, ['dyn' => 345, 'priv' => 123], [Foo::class => ['priv' => 234]]);
5960
ksort($actual);
6061

6162
$this->assertSame($expected, $actual);
6263

63-
$e = Instantiator::instantiate('Exception', ['foo' => 123, 'trace' => [234]]);
64+
$e = Instantiator::instantiate('Exception', ['trace' => [234]]);
6465

65-
$this->assertSame(123, $e->foo);
6666
$this->assertSame([234], $e->getTrace());
6767
}
6868
}
@@ -72,6 +72,7 @@ class Foo
7272
private $priv;
7373
}
7474

75+
#[\AllowDynamicProperties]
7576
class Bar extends Foo
7677
{
7778
private $priv;

src/Symfony/Component/VarExporter/Tests/VarExporterTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function provideExport()
129129
yield ['partially-indexed-array', [5 => true, 1 => true, 2 => true, 6 => true], true];
130130
yield ['datetime', \DateTime::createFromFormat('U', 0)];
131131

132-
$value = new \ArrayObject();
132+
$value = new ArrayObject();
133133
$value[0] = 1;
134134
$value->foo = new \ArrayObject();
135135
$value[1] = $value;
@@ -436,3 +436,8 @@ public function unserialize($ser)
436436
throw new \BadMethodCallException();
437437
}
438438
}
439+
440+
#[\AllowDynamicProperties]
441+
class ArrayObject extends \ArrayObject
442+
{
443+
}

0 commit comments

Comments
 (0)
0