Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use explicit nullable type #231

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Asset/EntrypointLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/EntrypointLookupCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/EntrypointLookupCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Author

@maxhelias maxhelias Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas Is it a BC to add explicitly the nullable type on interfaces?

}
8 changes: 4 additions & 4 deletions src/Asset/TagRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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".');
Expand Down
2 changes: 1 addition & 1 deletion src/CacheWarmer/EntrypointCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Twig/EntryFilesTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down