diff --git a/.hhconfig b/.hhconfig index 4fa5a13..4886645 100644 --- a/.hhconfig +++ b/.hhconfig @@ -3,3 +3,4 @@ safe_array = true safe_vector_array = true unsafe_rx = false ignored_paths = [ "vendor/.+/tests/.+", "vendor/.+/bin/.+" ] +const_default_func_args = true diff --git a/src/Nuxed/Asset/Package.hack b/src/Nuxed/Asset/Package.hack index 7cafe30..8aee460 100644 --- a/src/Nuxed/Asset/Package.hack +++ b/src/Nuxed/Asset/Package.hack @@ -6,10 +6,13 @@ use namespace HH\Lib\Str; * Basic package that adds a version to asset URLs. */ class Package implements IPackage { +private Context\IContext $context; + public function __construct( private VersionStrategy\IVersionStrategy $versionStrategy, - private Context\IContext $context = new Context\NullContext(), + ?Context\IContext $context = null ) { + $this->context = $context ?? new Context\NullContext(); } /** diff --git a/src/Nuxed/Asset/PathPackage.hack b/src/Nuxed/Asset/PathPackage.hack index 10bd075..e84b530 100644 --- a/src/Nuxed/Asset/PathPackage.hack +++ b/src/Nuxed/Asset/PathPackage.hack @@ -21,8 +21,9 @@ class PathPackage extends Package { public function __construct( string $basePath, IVersionStrategy $versionStrategy, - IContext $context = new Context\NullContext(), + ?IContext $context = null, ) { + $context ??= new Context\NullContext(); parent::__construct($versionStrategy, $context); if ('' === $basePath) { diff --git a/src/Nuxed/Asset/UrlPackage.hack b/src/Nuxed/Asset/UrlPackage.hack index 193345f..70408da 100644 --- a/src/Nuxed/Asset/UrlPackage.hack +++ b/src/Nuxed/Asset/UrlPackage.hack @@ -26,8 +26,9 @@ class UrlPackage extends Package { public function __construct( Container $baseUrls, VersionStrategy\IVersionStrategy $versionStrategy, - Context\IContext $context = new Context\NullContext(), + ?Context\IContext $context = null, ) { + $context ??= new Context\NullContext(); parent::__construct($versionStrategy, $context); if (C\is_empty($baseUrls)) {