From 7904b1e64afe27d6444e2196796a207f39bf6567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20H=C3=A9lias?= Date: Fri, 19 Apr 2024 17:01:23 +0200 Subject: [PATCH] Use explicit nullable type --- src/Asset/EntrypointLookup.php | 2 +- src/Asset/EntrypointLookupCollection.php | 4 ++-- src/Asset/EntrypointLookupCollectionInterface.php | 2 +- src/Asset/TagRenderer.php | 8 ++++---- src/CacheWarmer/EntrypointCacheWarmer.php | 2 +- src/Twig/EntryFilesTwigExtension.php | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Asset/EntrypointLookup.php b/src/Asset/EntrypointLookup.php index a802d764..a5c94db4 100644 --- a/src/Asset/EntrypointLookup.php +++ b/src/Asset/EntrypointLookup.php @@ -33,7 +33,7 @@ class EntrypointLookup implements EntrypointLookupInterface, IntegrityDataProvid private $strictMode; - public function __construct(string $entrypointJsonPath, CacheItemPoolInterface $cache = null, string $cacheKey = null, bool $strictMode = true) + public function __construct(string $entrypointJsonPath, ?CacheItemPoolInterface $cache = null, ?string $cacheKey = null, bool $strictMode = true) { $this->entrypointJsonPath = $entrypointJsonPath; $this->cache = $cache; diff --git a/src/Asset/EntrypointLookupCollection.php b/src/Asset/EntrypointLookupCollection.php index 6ddf0712..e9b114c9 100644 --- a/src/Asset/EntrypointLookupCollection.php +++ b/src/Asset/EntrypointLookupCollection.php @@ -25,13 +25,13 @@ class EntrypointLookupCollection implements EntrypointLookupCollectionInterface private $defaultBuildName; - public function __construct(ContainerInterface $buildEntrypoints, string $defaultBuildName = null) + public function __construct(ContainerInterface $buildEntrypoints, ?string $defaultBuildName = null) { $this->buildEntrypoints = $buildEntrypoints; $this->defaultBuildName = $defaultBuildName; } - public function getEntrypointLookup(string $buildName = null): EntrypointLookupInterface + public function getEntrypointLookup(?string $buildName = null): EntrypointLookupInterface { if (null === $buildName) { if (null === $this->defaultBuildName) { diff --git a/src/Asset/EntrypointLookupCollectionInterface.php b/src/Asset/EntrypointLookupCollectionInterface.php index 3f4dbf15..0179d51b 100644 --- a/src/Asset/EntrypointLookupCollectionInterface.php +++ b/src/Asset/EntrypointLookupCollectionInterface.php @@ -18,5 +18,5 @@ interface EntrypointLookupCollectionInterface * * @throws UndefinedBuildException if the build does not exist */ - public function getEntrypointLookup(string $buildName = null): EntrypointLookupInterface; + public function getEntrypointLookup(?string $buildName = null): EntrypointLookupInterface; } diff --git a/src/Asset/TagRenderer.php b/src/Asset/TagRenderer.php index c09bcd3c..146fa443 100644 --- a/src/Asset/TagRenderer.php +++ b/src/Asset/TagRenderer.php @@ -34,7 +34,7 @@ public function __construct( array $defaultAttributes = [], array $defaultScriptAttributes = [], array $defaultLinkAttributes = [], - EventDispatcherInterface $eventDispatcher = null + ?EventDispatcherInterface $eventDispatcher = null ) { $this->entrypointLookupCollection = $entrypointLookupCollection; $this->packages = $packages; @@ -46,7 +46,7 @@ public function __construct( $this->reset(); } - public function renderWebpackScriptTags(string $entryName, string $packageName = null, string $entrypointName = null, array $extraAttributes = []): string + public function renderWebpackScriptTags(string $entryName, ?string $packageName = null, ?string $entrypointName = null, array $extraAttributes = []): string { $entrypointName = $entrypointName ?: '_default'; $scriptTags = []; @@ -83,7 +83,7 @@ public function renderWebpackScriptTags(string $entryName, string $packageName = return implode('', $scriptTags); } - public function renderWebpackLinkTags(string $entryName, string $packageName = null, string $entrypointName = null, array $extraAttributes = []): string + public function renderWebpackLinkTags(string $entryName, ?string $packageName = null, ?string $entrypointName = null, array $extraAttributes = []): string { $entrypointName = $entrypointName ?: '_default'; $scriptTags = []; @@ -144,7 +144,7 @@ public function reset(): void ]; } - private function getAssetPath(string $assetPath, string $packageName = null): string + private function getAssetPath(string $assetPath, ?string $packageName = null): string { if (null === $this->packages) { throw new \Exception('To render the script or link tags, run "composer require symfony/asset".'); diff --git a/src/CacheWarmer/EntrypointCacheWarmer.php b/src/CacheWarmer/EntrypointCacheWarmer.php index b5e9a780..c1156a14 100644 --- a/src/CacheWarmer/EntrypointCacheWarmer.php +++ b/src/CacheWarmer/EntrypointCacheWarmer.php @@ -24,7 +24,7 @@ public function __construct(array $cacheKeys, string $phpArrayFile) parent::__construct($phpArrayFile); } - protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, string $buildDir = null): bool + protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter, ?string $buildDir = null): bool { foreach ($this->cacheKeys as $cacheKey => $path) { // If the file does not exist then just skip past this entry point. diff --git a/src/Twig/EntryFilesTwigExtension.php b/src/Twig/EntryFilesTwigExtension.php index 253704c0..8f8de609 100644 --- a/src/Twig/EntryFilesTwigExtension.php +++ b/src/Twig/EntryFilesTwigExtension.php @@ -48,13 +48,13 @@ public function getWebpackCssFiles(string $entryName, string $entrypointName = ' ->getCssFiles($entryName); } - public function renderWebpackScriptTags(string $entryName, string $packageName = null, string $entrypointName = '_default', array $attributes = []): string + public function renderWebpackScriptTags(string $entryName, ?string $packageName = null, string $entrypointName = '_default', array $attributes = []): string { return $this->getTagRenderer() ->renderWebpackScriptTags($entryName, $packageName, $entrypointName, $attributes); } - public function renderWebpackLinkTags(string $entryName, string $packageName = null, string $entrypointName = '_default', array $attributes = []): string + public function renderWebpackLinkTags(string $entryName, ?string $packageName = null, string $entrypointName = '_default', array $attributes = []): string { return $this->getTagRenderer() ->renderWebpackLinkTags($entryName, $packageName, $entrypointName, $attributes);