Skip to content

Commit 43e5867

Browse files
Merge branch '6.4' into 7.0
* 6.4: fix typo Add types to private and internal properties [Workflow] Cleaning code [Scheduler] Fix NPE in debug:scheduler command
2 parents 0823b51 + 42d9d7c commit 43e5867

File tree

145 files changed

+601
-746
lines changed

Some content is hidden

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

145 files changed

+601
-746
lines changed

src/Symfony/Bridge/Doctrine/Messenger/AbstractDoctrineMiddleware.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
abstract class AbstractDoctrineMiddleware implements MiddlewareInterface
2727
{
28-
protected $managerRegistry;
29-
protected $entityManagerName;
28+
protected ManagerRegistry $managerRegistry;
29+
protected ?string $entityManagerName;
3030

3131
public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null)
3232
{

src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Doctrine\ORM\EntityManagerInterface;
1515
use Doctrine\Persistence\ManagerRegistry;
1616
use Psr\Log\LoggerInterface;
17-
use Psr\Log\NullLogger;
1817
use Symfony\Component\Messenger\Envelope;
1918
use Symfony\Component\Messenger\Middleware\StackInterface;
2019

@@ -25,13 +24,13 @@
2524
*/
2625
class DoctrineOpenTransactionLoggerMiddleware extends AbstractDoctrineMiddleware
2726
{
28-
private $logger;
27+
private ?LoggerInterface $logger;
2928

3029
public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null, LoggerInterface $logger = null)
3130
{
3231
parent::__construct($managerRegistry, $entityManagerName);
3332

34-
$this->logger = $logger ?? new NullLogger();
33+
$this->logger = $logger;
3534
}
3635

3736
protected function handleForManager(EntityManagerInterface $entityManager, Envelope $envelope, StackInterface $stack): Envelope
@@ -40,7 +39,7 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
4039
return $stack->next()->handle($envelope, $stack);
4140
} finally {
4241
if ($entityManager->getConnection()->isTransactionActive()) {
43-
$this->logger->error('A handler opened a transaction but did not close it.', [
42+
$this->logger?->error('A handler opened a transaction but did not close it.', [
4443
'message' => $envelope->getMessage(),
4544
]);
4645
}

src/Symfony/Bundle/DebugBundle/Command/ServerDumpPlaceholderCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#[AsCommand(name: 'server:dump', description: 'Start a dump server that collects and displays dumps in a single place')]
3030
class ServerDumpPlaceholderCommand extends Command
3131
{
32-
private $replacedCommand;
32+
private ServerDumpCommand $replacedCommand;
3333

3434
public function __construct(DumpServer $server = null, array $descriptors = [])
3535
{

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
*/
3434
abstract class Descriptor implements DescriptorInterface
3535
{
36-
/**
37-
* @var OutputInterface
38-
*/
39-
protected $output;
36+
protected OutputInterface $output;
4037

4138
public function describe(OutputInterface $output, mixed $object, array $options = []): void
4239
{

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

-2
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,6 @@
424424

425425
<xsd:simpleType name="marking_store_type">
426426
<xsd:restriction base="xsd:string">
427-
<xsd:enumeration value="multiple_state" />
428-
<xsd:enumeration value="single_state" />
429427
<xsd:enumeration value="method" />
430428
</xsd:restriction>
431429
</xsd:simpleType>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<framework:workflow name="article" type="workflow">
1212
<framework:audit-trail enabled="true"/>
1313
<framework:initial-marking>draft</framework:initial-marking>
14-
<framework:marking-store type="method" property="state" />
1514
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTestCase</framework:support>
1615
<framework:place name="draft" />
1716
<framework:place name="wait_for_journalist" />

src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionPanelController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*/
2626
class ExceptionPanelController
2727
{
28-
private $errorRenderer;
29-
private $profiler;
28+
private HtmlErrorRenderer $errorRenderer;
29+
private ?Profiler $profiler;
3030

3131
public function __construct(HtmlErrorRenderer $errorRenderer, Profiler $profiler = null)
3232
{

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
*/
3333
class ProfilerController
3434
{
35-
private $templateManager;
36-
private $generator;
37-
private $profiler;
38-
private $twig;
39-
private $templates;
40-
private $cspHandler;
41-
private $baseDir;
35+
private TemplateManager $templateManager;
36+
private UrlGeneratorInterface $generator;
37+
private ?Profiler $profiler;
38+
private Environment $twig;
39+
private array $templates;
40+
private ?ContentSecurityPolicyHandler $cspHandler;
41+
private ?string $baseDir;
4242

4343
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, string $baseDir = null)
4444
{

src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
*/
3131
class RouterController
3232
{
33-
private $profiler;
34-
private $twig;
35-
private $matcher;
36-
private $routes;
33+
private ?Profiler $profiler;
34+
private Environment $twig;
35+
private ?UrlMatcherInterface $matcher;
36+
private ?RouteCollection $routes;
3737

3838
/**
3939
* @var ExpressionFunctionProviderInterface[]
4040
*/
41-
private $expressionLanguageProviders = [];
41+
private iterable $expressionLanguageProviders;
4242

4343
public function __construct(Profiler $profiler = null, Environment $twig, UrlMatcherInterface $matcher = null, RouteCollection $routes = null, iterable $expressionLanguageProviders = [])
4444
{

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424
class ContentSecurityPolicyHandler
2525
{
26-
private $nonceGenerator;
27-
private $cspDisabled = false;
26+
private NonceGenerator $nonceGenerator;
27+
private bool $cspDisabled = false;
2828

2929
public function __construct(NonceGenerator $nonceGenerator)
3030
{

src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525
class TemplateManager
2626
{
27-
protected $twig;
28-
protected $templates;
29-
protected $profiler;
27+
protected Environment $twig;
28+
protected array $templates;
29+
protected Profiler $profiler;
3030

3131
public function __construct(Profiler $profiler, Environment $twig, array $templates)
3232
{

src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@
2727
*/
2828
class WebProfilerExtension extends ProfilerExtension
2929
{
30-
/**
31-
* @var HtmlDumper
32-
*/
33-
private $dumper;
30+
private HtmlDumper $dumper;
3431

3532
/**
3633
* @var resource
3734
*/
3835
private $output;
3936

40-
/**
41-
* @var int
42-
*/
43-
private $stackLevel = 0;
37+
private int $stackLevel = 0;
4438

4539
public function __construct(HtmlDumper $dumper = null)
4640
{

src/Symfony/Component/Asset/Exception/AssetNotFoundException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class AssetNotFoundException extends RuntimeException
1818
{
19-
private $alternatives;
19+
private array $alternatives;
2020

2121
/**
2222
* @param string $message Exception message to throw

src/Symfony/Component/AssetMapper/Compiler/CssAssetUrlCompiler.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\AssetMapper\Compiler;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Psr\Log\NullLogger;
1615
use Symfony\Component\AssetMapper\AssetDependency;
1716
use Symfony\Component\AssetMapper\AssetMapperInterface;
1817
use Symfony\Component\AssetMapper\Exception\RuntimeException;
@@ -29,16 +28,13 @@ final class CssAssetUrlCompiler implements AssetCompilerInterface
2928
{
3029
use AssetCompilerPathResolverTrait;
3130

32-
private readonly LoggerInterface $logger;
33-
3431
// https://regex101.com/r/BOJ3vG/1
3532
public const ASSET_URL_PATTERN = '/url\(\s*["\']?(?!(?:\/|\#|%23|data|http|\/\/))([^"\'\s?#)]+)([#?][^"\')]+)?\s*["\']?\)/';
3633

3734
public function __construct(
3835
private readonly string $missingImportMode = self::MISSING_IMPORT_WARN,
39-
LoggerInterface $logger = null,
36+
private readonly ?LoggerInterface $logger = null,
4037
) {
41-
$this->logger = $logger ?? new NullLogger();
4238
}
4339

4440
public function compile(string $content, MappedAsset $asset, AssetMapperInterface $assetMapper): string
@@ -76,7 +72,7 @@ private function handleMissingImport(string $message, \Throwable $e = null): voi
7672
{
7773
match ($this->missingImportMode) {
7874
AssetCompilerInterface::MISSING_IMPORT_IGNORE => null,
79-
AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger->warning($message),
75+
AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger?->warning($message),
8076
AssetCompilerInterface::MISSING_IMPORT_STRICT => throw new RuntimeException($message, 0, $e),
8177
};
8278
}

src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\AssetMapper\Compiler;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Psr\Log\NullLogger;
1615
use Symfony\Component\AssetMapper\AssetDependency;
1716
use Symfony\Component\AssetMapper\AssetMapperInterface;
1817
use Symfony\Component\AssetMapper\Exception\RuntimeException;
@@ -29,16 +28,13 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface
2928
{
3029
use AssetCompilerPathResolverTrait;
3130

32-
private readonly LoggerInterface $logger;
33-
3431
// https://regex101.com/r/VFdR4H/1
3532
private const IMPORT_PATTERN = '/(?:import\s+(?:(?:\*\s+as\s+\w+|[\w\s{},*]+)\s+from\s+)?|\bimport\()\s*[\'"`](\.\/[^\'"`]+|(\.\.\/)+[^\'"`]+)[\'"`]\s*[;\)]?/m';
3633

3734
public function __construct(
3835
private readonly string $missingImportMode = self::MISSING_IMPORT_WARN,
39-
LoggerInterface $logger = null,
36+
private readonly ?LoggerInterface $logger = null,
4037
) {
41-
$this->logger = $logger ?? new NullLogger();
4238
}
4339

4440
public function compile(string $content, MappedAsset $asset, AssetMapperInterface $assetMapper): string
@@ -101,7 +97,7 @@ private function handleMissingImport(string $message, \Throwable $e = null): voi
10197
{
10298
match ($this->missingImportMode) {
10399
AssetCompilerInterface::MISSING_IMPORT_IGNORE => null,
104-
AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger->warning($message),
100+
AssetCompilerInterface::MISSING_IMPORT_WARN => $this->logger?->warning($message),
105101
AssetCompilerInterface::MISSING_IMPORT_STRICT => throw new RuntimeException($message, 0, $e),
106102
};
107103
}

src/Symfony/Component/BrowserKit/AbstractBrowser.php

+9-34
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,7 @@ public function getCookieJar(): CookieJar
192192
*/
193193
public function getCrawler(): Crawler
194194
{
195-
if (null === $this->crawler) {
196-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
197-
}
198-
199-
return $this->crawler;
195+
return $this->crawler ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
200196
}
201197

202198
/**
@@ -216,11 +212,7 @@ public function useHtml5Parser(bool $useHtml5Parser): static
216212
*/
217213
public function getInternalResponse(): Response
218214
{
219-
if (null === $this->internalResponse) {
220-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
221-
}
222-
223-
return $this->internalResponse;
215+
return $this->internalResponse ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
224216
}
225217

226218
/**
@@ -233,23 +225,15 @@ public function getInternalResponse(): Response
233225
*/
234226
public function getResponse(): object
235227
{
236-
if (null === $this->response) {
237-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
238-
}
239-
240-
return $this->response;
228+
return $this->response ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
241229
}
242230

243231
/**
244232
* Returns the current BrowserKit Request instance.
245233
*/
246234
public function getInternalRequest(): Request
247235
{
248-
if (null === $this->internalRequest) {
249-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
250-
}
251-
252-
return $this->internalRequest;
236+
return $this->internalRequest ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
253237
}
254238

255239
/**
@@ -262,11 +246,7 @@ public function getInternalRequest(): Request
262246
*/
263247
public function getRequest(): object
264248
{
265-
if (null === $this->request) {
266-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
267-
}
268-
269-
return $this->request;
249+
return $this->request ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
270250
}
271251

272252
/**
@@ -288,11 +268,9 @@ public function click(Link $link): Crawler
288268
*/
289269
public function clickLink(string $linkText): Crawler
290270
{
291-
if (null === $this->crawler) {
292-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
293-
}
271+
$crawler = $this->crawler ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
294272

295-
return $this->click($this->crawler->selectLink($linkText)->link());
273+
return $this->click($crawler->selectLink($linkText)->link());
296274
}
297275

298276
/**
@@ -319,11 +297,8 @@ public function submit(Form $form, array $values = [], array $serverParameters =
319297
*/
320298
public function submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = []): Crawler
321299
{
322-
if (null === $this->crawler) {
323-
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
324-
}
325-
326-
$buttonNode = $this->crawler->selectButton($button);
300+
$crawler = $this->crawler ?? throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
301+
$buttonNode = $crawler->selectButton($button);
327302

328303
if (0 === $buttonNode->count()) {
329304
throw new InvalidArgumentException(sprintf('There is no button with "%s" as its content, id, value or name.', $button));

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
3333
*/
3434
protected const NS_SEPARATOR = ':';
3535

36-
private static $apcuSupported;
37-
private static $phpFilesSupported;
36+
private static bool $apcuSupported;
3837

3938
protected function __construct(string $namespace = '', int $defaultLifetime = 0)
4039
{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class NullAdapter implements AdapterInterface, CacheInterface
2222
{
23-
private static $createCacheItem;
23+
private static \Closure $createCacheItem;
2424

2525
public function __construct()
2626
{

src/Symfony/Component/Cache/LockRegistry.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*/
2727
final class LockRegistry
2828
{
29-
private static $openedFiles = [];
30-
private static $lockedFiles;
31-
private static $signalingException;
32-
private static $signalingCallback;
29+
private static array $openedFiles = [];
30+
private static ?array $lockedFiles = null;
31+
private static \Exception $signalingException;
32+
private static \Closure $signalingCallback;
3333

3434
/**
3535
* The number of items in this list controls the max number of concurrent processes.
3636
*/
37-
private static $files = [
37+
private static array $files = [
3838
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractAdapter.php',
3939
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AbstractTagAwareAdapter.php',
4040
__DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'AdapterInterface.php',

0 commit comments

Comments
 (0)