8000 minor #59980 Various cleanups (nicolas-grekas) · symfony/symfony@6211084 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6211084

Browse files
minor #59980 Various cleanups (nicolas-grekas)
This PR was merged into the 7.3 branch. Discussion ---------- Various cleanups | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Found while working on #59890 Commits ------- 18390f1 Various cleanups
2 parents d768193 + 18390f1 commit 6211084

File tree

8 files changed

+87
-92
lines changed

8 files changed

+87
-92
lines changed

.github/expected-missing-return-types.diff

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -593,23 +593,6 @@ diff --git a/src/Symfony/Component/VarDumper/Dumper/DataDumperInterface.php b/sr
593593
- public function dump(Data $data);
594594
+ public function dump(Data $data): ?string;
595595
}
596-
diff --git a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php
597-
--- a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php
598-
+++ b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php
599-
@@ -172,5 +172,5 @@ class ProxyHelperTest extends TestCase
600-
{
601-
yield 'not type hinted __unserialize method' => [new class {
602-
- public function __unserialize($array)
603-
+ public function __unserialize($array): void
604-
{
605-
}
606-
@@ -192,5 +192,5 @@ class ProxyHelperTest extends TestCase
607-
608-
yield 'type hinted __unserialize method' => [new class {
609-
- public function __unserialize(array $array)
610-
+ public function __unserialize(array $array): void
611-
{
612-
}
613596
diff --git a/src/Symfony/Contracts/Translation/LocaleAwareInterface.php b/src/Symfony/Contracts/Translation/LocaleAwareInterface.php
614597
--- a/src/Symfony/Contracts/Translation/LocaleAwareInterface.php
615598
+++ b/src/Symfony/Contracts/Translation/LocaleAwareInterface.php

UPGRADE-7.3.md

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,10 @@ Read more about this in the [Symfony documentation](https://symfony.com/doc/7.3/
88

99
If you're upgrading from a version below 7.2, follow the [7.2 upgrade guide](UPGRADE-7.2.md) first.
1010

11-
Ldap
12-
----
13-
14-
* Deprecate `LdapUser::eraseCredentials()` in favor of `__serialize()`
15-
16-
Security
17-
--------
18-
19-
* Deprecate `UserInterface::eraseCredentials()` and `TokenInterface::eraseCredentials()`;
20-
erase credentials e.g. using `__serialize()` instead
21-
22-
Before:
23-
24-
```php
25-
public function eraseCredentials(): void
26-
{
27-
}
28-
```
29-
30-
After:
31-
32-
```php
33-
#[\Deprecated]
34-
public function eraseCredentials(): void
35-
{
36-
}
37-
38-
// If your eraseCredentials() method was used to empty a "password" property:
39-
public function __serialize(): array
40-
{
41-
$data = (array) $this;
42-
unset($data["\0".self::class."\0password"]);
43-
44-
return $data;
45-
}
46-
```
47-
48-
* Add argument `$vote` to `VoterInterface::vote()` and to `Voter::voteOnAttribute()`;
49-
it should be used to report the reason of a vote. E.g:
50-
51-
```php
52-
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
53-
{
54-
$vote ??= new Vote();
55-
56-
$vote->reasons[] = 'A brief explanation of why access is granted or denied, as appropriate.';
57-
}
58-
```
59-
60-
* Add argument `$accessDecision` to `AccessDecisionManagerInterface::decide()` and `AuthorizationCheckerInterface::isGranted()`;
61-
it should be used to report the reason of a decision, including all the related votes.
11+
AssetMapper
12+
-----------
6213

63-
* Add discovery support to `OidcTokenHandler` and `OidcUserInfoTokenHandler`
14+
* `ImportMapRequireCommand` now takes `projectDir` as a required third constructor argument
6415

6516
Console
6617
-------
@@ -96,10 +47,15 @@ FrameworkBundle
9647
* Deprecate the `--show-arguments` option of the `container:debug` command, as arguments are now always shown
9748
* Deprecate the `framework.validation.cache` config option
9849

50+
Ldap
51+
----
52+
53+
* Deprecate `LdapUser::eraseCredentials()` in favor of `__serialize()`
54+
9955
OptionsResolver
10056
---------------
10157

102-
* Deprecate defining nested options via `setDefault()`, use `setOptions()` instead
58+
* Deprecate defining nested options via `setDefault()`, use `setOptions()` instead
10359

10460
*Before*
10561
```php
@@ -115,6 +71,55 @@ OptionsResolver
11571
});
11672
```
11773

74+
Security
75+
--------
76+
77+
* Deprecate `UserInterface::eraseCredentials()` and `TokenInterface::eraseCredentials()`;
78+
erase credentials e.g. using `__serialize()` instead
79+
80+
Before:
81+
82+
```php
83+
public function eraseCredentials(): void
84+
{
85+
}
86+
```
87+
88+
After:
89+
90+
```php
91+
#[\Deprecated]
92+
public function eraseCredentials(): void
93+
{
94+
}
95+
96+
// If your eraseCredentials() method was used to empty a "password" property:
97+
public function __serialize(): array
98+
{
99+
$data = (array) $this;
100+
unset($data["\0".self::class."\0password"]);
101+
102+
return $data;
103+
}
104+
```
105+
106+
* Add argument `$vote` to `VoterInterface::vote()` and to `Voter::voteOnAttribute()`;
107+
it should be used to report the reason of a vote. E.g:
108+
109+
```php
110+
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
111+
{
112+
$vote ??= new Vote();
113+
114+
$vote->reasons[] = 'A brief explanation of why access is granted or denied, as appropriate.';
115+
}
116+
```
117+
118+
* Add argument `$accessDecision` to `AccessDecisionManagerInterface::decide()` and `AuthorizationCheckerInterface::isGranted()`;
119+
it should be used to report the reason of a decision, including all the related votes.
120+
121+
* Add discovery support to `OidcTokenHandler` and `OidcUserInfoTokenHandler`
122+
118123
SecurityBundle
119124
--------------
120125

@@ -191,8 +196,3 @@ VarDumper
191196

192197
* Deprecate `ResourceCaster::castCurl()`, `ResourceCaster::castGd()` and `ResourceCaster::castOpensslX509()`
193198
* Mark all casters as `@internal`
194-
195-
AssetMapper
196-
-----------
197-
198-
* `ImportMapRequireCommand` now takes `projectDir` as a required third constructor argument

src/Symfony/Component/Cache/Tests/Traits/RedisProxiesTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Cache\Traits\RedisProxyTrait;
1818
use Symfony\Component\Cache\Traits\RelayClusterProxy;
1919
use Symfony\Component\Cache\Traits\RelayProxy;
20-
use Symfony\Component\VarExporter\LazyProxyTrait;
2120
use Symfony\Component\VarExporter\ProxyHelper;
2221

2322
class RedisProxiesTest extends TestCase
@@ -37,7 +36,7 @@ public function testRedisProxy($class)
3736
$methods = [];
3837

3938
foreach ((new \ReflectionClass(\sprintf('Symfony\Component\Cache\Traits\\%s%dProxy', $class, $version)))->getMethods() as $method) {
40-
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name)) {
39+
if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name)) {
4140
continue;
4241
}
4342
$return = '__construct' === $method->name || $method->getReturnType() instanceof \ReflectionNamedType && 'void' === (string) $method->getReturnType() ? '' : 'return ';
@@ -89,7 +88,7 @@ public function testRelayProxy()
8988
$expectedMethods = [];
9089

9190
foreach ((new \ReflectionClass(RelayProxy::class))->getMethods() as $method) {
92-
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) {
91+
if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name) || $method->isStatic()) {
9392
continue;
9493
}
9594

@@ -136,7 +135,7 @@ public function testRelayClusterProxy()
136135
$expectedMethods = [];
137136

138137
foreach ((new \ReflectionClass(RelayClusterProxy::class))->getMethods() as $method) {
139-
if ('reset' === $method->name || method_exists(LazyProxyTrait::class, $method->name) || $method->isStatic()) {
138+
if ('reset' === $method->name || method_exists(RedisProxyTrait::class, $method->name) || $method->isStatic()) {
140139
continue;
141140
}
142141

src/Symfony/Component/HttpKernel/DependencyInjection/ServicesResetter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function reset(): void
4646
continue;
4747
}
4848

49+
if (\PHP_VERSION_ID >= 80400 && (new \ReflectionClass($service))->isUninitializedLazyObject($service)) {
50+
continue;
51+
}
52+
4953
foreach ((array) $this->resetMethods[$id] as $resetMethod) {
5054
if ('?' === $resetMethod[0] && !method_exists($service, $resetMethod = substr($resetMethod, 1))) {
5155
continue;

src/Symfony/Component/JsonStreamer/CacheWarmer/LazyGhostCacheWarmer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*
2323
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
2424
*
25+
* @deprecated since Symfony 7.3, native lazy objects will be used instead
26+
*
2527
* @internal
2628
*/
2729
final class LazyGhostCacheWarmer extends CacheWarmer

src/Symfony/Component/JsonStreamer/Tests/CacheWarmer/LazyGhostCacheWarmerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\JsonStreamer\CacheWarmer\LazyGhostCacheWarmer;
1616
use Symfony\Component\JsonStreamer\Tests\Fixtures\Model\ClassicDummy;
1717

18+
/**
19+
* @group legacy
20+
*/
1821
class LazyGhostCacheWarmerTest extends TestCase
1922
{
2023
private string $lazyGhostsDir;

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,21 +1032,25 @@ public function testIsReadableWithMissingPropertyAndLazyGhost()
10321032

10331033
private function createUninitializedObjectPropertyGhost(): UninitializedObjectProperty
10341034
{
1035-
if (!class_exists(ProxyHelper::class)) {
1036-
$this->markTestSkipped(\sprintf('Class "%s" is required to run this test.', ProxyHelper::class));
1037-
}
1035+
if (\PHP_VERSION_ID < 80400) {
1036+
if (!class_exists(ProxyHelper::class)) {
1037+
$this->markTestSkipped(\sprintf('Class "%s" is required to run this test.', ProxyHelper::class));
1038+
}
10381039

1039-
$class = 'UninitializedObjectPropertyGhost';
1040+
$class = 'UninitializedObjectPropertyGhost';
10401041

1041-
if (!class_exists($class)) {
1042-
eval('class '.$class.ProxyHelper::generateLazyGhost(new \ReflectionClass(UninitializedObjectProperty::class)));
1043-
}
1042+
if (!class_exists($class)) {
1043+
eval('class '.$class.ProxyHelper::generateLazyGhost(new \ReflectionClass(UninitializedObjectProperty::class)));
1044+
}
10441045

1045-
$this->assertTrue(class_exists($class));
1046+
$this->assertTrue(class_exists($class));
10461047

1047-
return $class::createLazyGhost(initializer: function ($instance) {
1048-
});
1049-
}
1048+
return $class::createLazyGhost(initializer: function ($instance) {
1049+
});
1050+
}
1051+
1052+
return (new \ReflectionClass(UninitializedObjectProperty::class))->newLazyGhost(fn () => null);
1053+
}
10501054

10511055
/**
10521056
* @requires PHP 8.4

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function testGenerateLazyProxyForClassWithUnserializeMagicMethod(object $
172172
public static function classWithUnserializeMagicMethodProvider(): iterable
173173
{
174174
yield 'not type hinted __unserialize method' => [new class {
175-
public function __unserialize($array)
175+
public function __unserialize($array): void
176176
{
177177
}
178178
}, <<<'EOPHP'
@@ -192,7 +192,7 @@ public function __unserialize($data): void
192192
EOPHP];
193193
194194
yield 'type hinted __unserialize method' => [new class {
195-
public function __unserialize(array $array)
195+
public function __unserialize(array $array): void
196196
{
197197
}
198198
}, <<<'EOPHP'

0 commit comments

Comments
 (0)
0