Skip to content

Commit 781c584

Browse files
Merge branch '7.4' into 8.0
* 7.4: [Mime] Deprecate implementing `__sleep/wakeup()` on `AbstractPart` implementations [Validator] Deprecate implementing `__sleep/wakeup()` on GenericMetadata implementations [String] Deprecate implementing `__sleep/wakeup()` on string implementations More cleanups related to internal sleep/wakeup usages [HttpKernel] Deprecate `__sleep/wakeup()` on kernels and data collectors and make `Profile` final [Serializer] Make `AttributeMetadata` and `ClassMetadata` final Replace __sleep/wakeup() by __(un)serialize() when BC isn't a concern chore: PHP CS Fixer - simplify config
2 parents a8585b1 + 32db679 commit 781c584

File tree

69 files changed

+968
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+968
-174
lines changed

.php-cs-fixer.dist.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
'@PHPUnit91Migration:risky' => true, // take version from src/Symfony/Bridge/PhpUnit/phpunit.xml.dist#L4
3535
'@Symfony' => true,
3636
'@Symfony:risky' => true,
37-
'phpdoc_var_annotation_correct_order' => true,
3837
'protected_to_private' => false,
3938
'header_comment' => [
4039
'header' => implode('', $fileHeaderParts),
@@ -47,9 +46,6 @@
4746
]),
4847
],
4948
'php_unit_attributes' => true,
50-
'method_argument_space' => ['after_heredoc' => true, 'on_multiline' => 'ignore'],
51-
'no_trailing_whitespace_in_string' => false,
52-
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
5349
])
5450
->setRiskyAllowed(true)
5551
->setFinder(

UPGRADE-7.4.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,35 @@ HttpFoundation
5252

5353
* Deprecate using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
5454

55+
HttpKernel
56+
----------
57+
58+
* Deprecate implementing `__sleep/wakeup()` on kernels; use `__(un)serialize()` instead
59+
* Deprecate implementing `__sleep/wakeup()` on data collectors; use `__(un)serialize()` instead
60+
* Make `Profile` final and `Profiler::__sleep()` internal
61+
62+
Mime
63+
----
64+
65+
* Deprecate implementing `__sleep/wakeup()` on `AbstractPart` implementations; use `__(un)serialize()` instead
66+
5567
Security
5668
--------
5769

5870
* Deprecate callable firewall listeners, extend `AbstractListener` or implement `FirewallListenerInterface` instead
5971
* Deprecate `AbstractListener::__invoke`
6072
* Deprecate `LazyFirewallContext::__invoke()`
6173

74+
Serializer
75+
----------
76+
77+
* Make `AttributeMetadata` and `ClassMetadata` final
78+
79+
String
80+
------
81+
82+
* Deprecate implementing `__sleep/wakeup()` on string implementations
83+
6284
Translation
6385
-----------
6486

@@ -67,6 +89,7 @@ Translation
6789
Validator
6890
---------
6991

92+
* Deprecate implementing `__sleep/wakeup()` on `GenericMetadata` implementations; use `__(un)serialize()` instead
7093
* Deprecate passing a list of choices to the first argument of the `Choice` constraint. Use the `choices` option instead
7194
* Deprecate `getRequiredOptions()` and `getDefaultOption()` methods of the `All`, `AtLeastOneOf`, `CardScheme`, `Collection`,
7295
`CssColor`, `Expression`, `Regex`, `Sequentially`, `Type`, and `When` constraints

src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ private function sendToElasticsearch(array $records): void
138138
$this->wait(false);
139139
}
140140

141-
public function __sleep(): array
141+
public function __serialize(): array
142142
{
143143
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
144144
}
145145

146-
public function __wakeup(): void
146+
public function __unserialize(array $data): void
147147
{
148148
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
149149
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ public function __construct(array $mockedNamespaces = [])
9292
}
9393
}
9494

95-
public function __sleep()
95+
public function __serialize(): array
9696
{
9797
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
9898
}
9999

100-
public function __wakeup()
100+
public function __unserialize(array $data): void
101101
{
102102
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
103103
}

src/Symfony/Bridge/PhpUnit/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"php": ">=8.1.0"
2424
},
2525
"require-dev": {
26-
"symfony/deprecation-contracts": "^2.5|^3.0",
26+
"symfony/deprecation-contracts": "^2.5|^3",
2727
"symfony/error-handler": "^6.4.3|^7.0.3|^8.0"
2828
},
2929
"autoload": {

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,16 @@ protected function build(ContainerBuilder $container): void
8989
$container->registerExtension(new TestDumpExtension());
9090
}
9191

92-
public function __sleep(): array
92+
public function __serialize(): array
9393
{
94-
return ['varDir', 'testCase', 'rootConfig', 'environment', 'debug'];
94+
return [$this->varDir, $this->testCase, $this->rootConfig, $this->environment, $this->debug];
9595
}
9696

97-
public function __wakeup(): void
97+
public function __unserialize(array $data): void
9898
{
99-
foreach ($this as $k => $v) {
99+
[$this->varDir, $this->testCase, $this->rootConfig, $this->environment, $this->debug] = $data;
100+
101+
foreach ($this as $v) {
100102
if (\is_object($v)) {
101103
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
102104
}

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/ConcreteMicroKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public function getLogDir(): string
5555
return $this->cacheDir;
5656
}
5757

58-
public function __sleep(): array
58+
public function __serialize(): array
5959
{
6060
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
6161
}
6262

63-
public function __wakeup(): void
63+
public function __unserialize(array $data): void
6464
{
6565
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
6666
}

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/flex-style/src/FlexStyleMicroKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public function getProjectDir(): string
6464
return \dirname((new \ReflectionObject($this))->getFileName(), 2);
6565
}
6666

67-
public function __sleep(): array
67+
public function __serialize(): array
6868
{
6969
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
7070
}
7171

72-
public function __wakeup(): void
72+
public function __unserialize(array $data): void
7373
{
7474
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
7575
}

src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
1515
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
16+
use Symfony\Component\HttpFoundation\Request;
17+
use Symfony\Component\HttpFoundation\Response;
18+
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1619
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1720
use Symfony\Component\HttpKernel\Profiler\Profile;
1821
use Symfony\Component\HttpKernel\Profiler\Profiler;
@@ -57,7 +60,10 @@ public function testGetNameValidTemplate()
5760
->withAnyParameters()
5861
->willReturnCallback($this->profilerHasCallback(...));
5962

60-
$this->assertEquals('@Foo/Collector/foo.html.twig', $this->templateManager->getName(new ProfileDummy(), 'foo'));
63+
$profile = new Profile('token');
64+
$profile->addCollector(new DummyCollector('foo'));
65+
$profile->addCollector(new DummyCollector('bar'));
66+
$this->assertEquals('@Foo/Collector/foo.html.twig', $this->templateManager->getName($profile, 'foo'));
6167
}
6268

6369
public function profilerHasCallback($panel)
@@ -94,19 +100,18 @@ protected function mockTwigEnvironment()
94100
}
95101
}
96102

97-
class ProfileDummy extends Profile
103+
class DummyCollector extends DataCollector
98104
{
99-
public function __construct()
105+
public function __construct(private string $name)
100106
{
101-
parent::__construct('token');
102107
}
103108

104-
public function hasCollector(string $name): bool
109+
public function getName(): string
110+
{
111+
return $this->name;
112+
}
113+
114+
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
105115
{
106-
return match ($name) {
107-
'foo',
108-
'bar' => true,
109-
default => false,
110-
};
111116
}
112117
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ public function reset(): void
309309
$this->tags instanceof ResettableInterface && $this->tags->reset();
310310
}
311311

312-
public function __sleep(): array
312+
public function __serialize(): array
313313
{
314314
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
315315
}
316316

317-
public function __wakeup(): void
317+
public function __unserialize(array $data): void
318318
{
319319
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
320320
}

0 commit comments

Comments
 (0)