diff --git a/src/Cache/Cache.php b/src/Cache/Cache.php index 86fc5b4e..ba4ecf0c 100644 --- a/src/Cache/Cache.php +++ b/src/Cache/Cache.php @@ -9,7 +9,7 @@ interface Cache { * @param int $expiresIn * @return mixed */ - public function get($key, callable $cached = null, $expiresIn = 0); + public function get($key, ?callable $cached = null, $expiresIn = 0); /** * @param string $key diff --git a/src/Cache/Sqlite/Cache.php b/src/Cache/Sqlite/Cache.php index 56b9ee5c..a62fe1c1 100644 --- a/src/Cache/Sqlite/Cache.php +++ b/src/Cache/Sqlite/Cache.php @@ -18,7 +18,7 @@ class Cache implements CacheInterface { private $functions; - public function __construct(array $config, string $namespace, ObjectifiedFunctions $functions = null) { + public function __construct(array $config, string $namespace, ?ObjectifiedFunctions $functions = null) { $this->cacheRoot = (string) $config['cacheRoot']; $this->name = (string) ($config['name'] ?? 'cache'); $this->maxSize = (int) $config['maxSize']; @@ -26,7 +26,7 @@ public function __construct(array $config, string $namespace, ObjectifiedFunctio $this->functions = $functions ?? new ObjectifiedFunctions(); } - public function get($key, callable $fn = null, $expiresIn = 0) { + public function get($key, ?callable $fn = null, $expiresIn = 0) { return $this->getManager()->get($this->getKey($key), $fn, $expiresIn, $this->functions); } diff --git a/src/Common/System.php b/src/Common/System.php index cb3ac1ed..87e3c94b 100644 --- a/src/Common/System.php +++ b/src/Common/System.php @@ -7,7 +7,7 @@ class System { private $functions; - public function __construct(ObjectifiedFunctions $functions = null) { + public function __construct(?ObjectifiedFunctions $functions = null) { if ($functions === null) { $functions = new ObjectifiedFunctions(); } diff --git a/src/Exceptions/ItemNotFoundException.php b/src/Exceptions/ItemNotFoundException.php index 695d9b4b..0e92421e 100644 --- a/src/Exceptions/ItemNotFoundException.php +++ b/src/Exceptions/ItemNotFoundException.php @@ -11,7 +11,7 @@ class ItemNotFoundException extends \Exception { */ private $url; - public function __construct($message = '', $code = 0, Throwable $previous = null, URL $failed = null) { + public function __construct($message = '', $code = 0, ?Throwable $previous = null, ?URL $failed = null) { parent::__construct($message, $code, $previous); $this->url = $failed; } diff --git a/src/Filters/HTML/CSSInlining/Filter.php b/src/Filters/HTML/CSSInlining/Filter.php index fc631b8d..85e402e0 100644 --- a/src/Filters/HTML/CSSInlining/Filter.php +++ b/src/Filters/HTML/CSSInlining/Filter.php @@ -320,7 +320,7 @@ private function inlineCSS( return $elements; } - private function addIEFallback(URL $fallbackUrl = null, array $elements = null) { + private function addIEFallback(?URL $fallbackUrl = null, ?array $elements = null) { if ($fallbackUrl === null || !$elements) { return $elements; } diff --git a/src/Filters/HTML/ImagesOptimizationService/ImageURLRewriter.php b/src/Filters/HTML/ImagesOptimizationService/ImageURLRewriter.php index a689ab61..235c955d 100644 --- a/src/Filters/HTML/ImagesOptimizationService/ImageURLRewriter.php +++ b/src/Filters/HTML/ImagesOptimizationService/ImageURLRewriter.php @@ -79,7 +79,7 @@ public function __construct( * @param bool $mustExist * @return string */ - public function rewriteUrl($url, URL $baseUrl = null, array $params = [], $mustExist = false) { + public function rewriteUrl($url, ?URL $baseUrl = null, array $params = [], $mustExist = false) { if (strpos($url, '#') === 0) { return $url; } @@ -171,7 +171,7 @@ public function getCacheSalt() { * @param URL|null $baseUrl * @return URL|null */ - private function makeURLAbsoluteToBase($url, URL $baseUrl = null) { + private function makeURLAbsoluteToBase($url, ?URL $baseUrl = null) { $url = trim($url); if (!$url || substr($url, 0, 5) === 'data:') { return null; diff --git a/src/Filters/HTML/ScriptsProxyService/Filter.php b/src/Filters/HTML/ScriptsProxyService/Filter.php index fe1b59fc..366828aa 100644 --- a/src/Filters/HTML/ScriptsProxyService/Filter.php +++ b/src/Filters/HTML/ScriptsProxyService/Filter.php @@ -51,7 +51,7 @@ public function __construct( ServiceSignature $signature, LocalRetriever $retriever, TokenRefMaker $tokenRefMaker, - ObjectifiedFunctions $functions = null + ?ObjectifiedFunctions $functions = null ) { $this->config = $config; $this->signature = $signature; diff --git a/src/Filters/Image/ImageImplementations/DefaultImage.php b/src/Filters/Image/ImageImplementations/DefaultImage.php index 1d47e0db..b7a51728 100644 --- a/src/Filters/Image/ImageImplementations/DefaultImage.php +++ b/src/Filters/Image/ImageImplementations/DefaultImage.php @@ -36,7 +36,7 @@ class DefaultImage extends BaseImage implements Image { */ private $funcs; - public function __construct(URL $imageURL, Retriever $retriever, ObjectifiedFunctions $funcs = null) { + public function __construct(URL $imageURL, Retriever $retriever, ?ObjectifiedFunctions $funcs = null) { $this->imageURL = $imageURL; $this->retriever = $retriever; $this->funcs = is_null($funcs) ? new ObjectifiedFunctions() : $funcs; diff --git a/src/Logging/LogWriters/PHPError/Writer.php b/src/Logging/LogWriters/PHPError/Writer.php index b76533dc..cad4589a 100644 --- a/src/Logging/LogWriters/PHPError/Writer.php +++ b/src/Logging/LogWriters/PHPError/Writer.php @@ -23,7 +23,7 @@ class Writer extends BaseLogWriter { * @param array $config * @param ObjectifiedFunctions $funcs */ - public function __construct(array $config, ObjectifiedFunctions $funcs = null) { + public function __construct(array $config, ?ObjectifiedFunctions $funcs = null) { foreach (['messageType', 'destination', 'extraHeaders'] as $field) { if (isset($config[$field])) { $this->$field = $config[$field]; diff --git a/src/Logging/LogWriters/RotatingTextFile/Writer.php b/src/Logging/LogWriters/RotatingTextFile/Writer.php index 9daedbf4..1d3f5536 100644 --- a/src/Logging/LogWriters/RotatingTextFile/Writer.php +++ b/src/Logging/LogWriters/RotatingTextFile/Writer.php @@ -23,7 +23,7 @@ class Writer extends BaseLogWriter { * @param array $config * @param ?ObjectifiedFunctions $funcs */ - public function __construct(array $config, ObjectifiedFunctions $funcs = null) { + public function __construct(array $config, ?ObjectifiedFunctions $funcs = null) { if (isset($config['path'])) { $this->path = (string) $config['path']; } diff --git a/src/Logging/Logger.php b/src/Logging/Logger.php index e1cdcd95..0482d75a 100644 --- a/src/Logging/Logger.php +++ b/src/Logging/Logger.php @@ -24,7 +24,7 @@ class Logger { * Logger constructor. * @param LogWriter $writer */ - public function __construct(LogWriter $writer, ObjectifiedFunctions $functions = null) { + public function __construct(LogWriter $writer, ?ObjectifiedFunctions $functions = null) { $this->writer = $writer; $this->functions = is_null($functions) ? new ObjectifiedFunctions() : $functions; } diff --git a/src/PhastServices.php b/src/PhastServices.php index 334bae92..f2f3a74f 100644 --- a/src/PhastServices.php +++ b/src/PhastServices.php @@ -17,7 +17,7 @@ class PhastServices { /** * @param callable|null $getConfig */ - public static function serve(callable $getConfig = null) { + public static function serve(?callable $getConfig = null) { $httpRequest = Request::fromGlobals(); if ($httpRequest->getHeader('CDN-Loop') @@ -131,7 +131,7 @@ public static function output( Request $request, Response $response, array $config, - ObjectifiedFunctions $funcs = null + ?ObjectifiedFunctions $funcs = null ) { if (is_null($funcs)) { $funcs = new ObjectifiedFunctions(); diff --git a/src/Retrievers/CachingRetriever.php b/src/Retrievers/CachingRetriever.php index 501cfc53..22ad1840 100644 --- a/src/Retrievers/CachingRetriever.php +++ b/src/Retrievers/CachingRetriever.php @@ -27,7 +27,7 @@ class CachingRetriever implements Retriever { * @param Cache $cache * @param int $defaultCacheTime */ - public function __construct(Cache $cache, Retriever $retriever = null, $defaultCacheTime = 0) { + public function __construct(Cache $cache, ?Retriever $retriever = null, $defaultCacheTime = 0) { $this->cache = $cache; $this->retriever = $retriever; } diff --git a/src/Retrievers/LocalRetriever.php b/src/Retrievers/LocalRetriever.php index da367570..70c6dbde 100644 --- a/src/Retrievers/LocalRetriever.php +++ b/src/Retrievers/LocalRetriever.php @@ -22,7 +22,7 @@ class LocalRetriever implements Retriever { * @param array $map * @param ObjectifiedFunctions|null $functions */ - public function __construct(array $map, ObjectifiedFunctions $functions = null) { + public function __construct(array $map, ?ObjectifiedFunctions $functions = null) { $this->map = $map; if ($functions) { $this->funcs = $functions; diff --git a/src/Retrievers/PostDataRetriever.php b/src/Retrievers/PostDataRetriever.php index 8371da5e..36d5e501 100644 --- a/src/Retrievers/PostDataRetriever.php +++ b/src/Retrievers/PostDataRetriever.php @@ -18,7 +18,7 @@ class PostDataRetriever implements Retriever { * PostDataRetriever constructor. * @param ObjectifiedFunctions $funcs */ - public function __construct(ObjectifiedFunctions $funcs = null) { + public function __construct(?ObjectifiedFunctions $funcs = null) { $this->funcs = is_null($funcs) ? new ObjectifiedFunctions() : $funcs; } diff --git a/src/ValueObjects/PhastJavaScript.php b/src/ValueObjects/PhastJavaScript.php index 197b236d..4e8045e7 100644 --- a/src/ValueObjects/PhastJavaScript.php +++ b/src/ValueObjects/PhastJavaScript.php @@ -43,7 +43,7 @@ private function __construct(string $filename, string $script, bool $minified) { * @param string $filename * @param ObjectifiedFunctions|null $funcs */ - public static function fromFile($filename, ObjectifiedFunctions $funcs = null) { + public static function fromFile($filename, ?ObjectifiedFunctions $funcs = null) { $funcs = $funcs ? $funcs : new ObjectifiedFunctions(); $contents = $funcs->file_get_contents($filename); if ($contents === false) { diff --git a/test/php/Filters/Service/CachingServiceFilterTest.php b/test/php/Filters/Service/CachingServiceFilterTest.php index 305a9530..175ef7c2 100644 --- a/test/php/Filters/Service/CachingServiceFilterTest.php +++ b/test/php/Filters/Service/CachingServiceFilterTest.php @@ -35,7 +35,7 @@ public function setUp(): void { $cache = $this->createMock(Cache::class); $cache->method('get') - ->willReturnCallback(function ($key, callable $cb = null, $ttl = 0) { + ->willReturnCallback(function ($key, ?callable $cb = null, $ttl = 0) { if (!isset($this->cachedData[$key])) { if ($cb) { $data = $cb(); diff --git a/test/php/Services/Scripts/ServiceTest.php b/test/php/Services/Scripts/ServiceTest.php index 1c0180d4..4aaa2a93 100644 --- a/test/php/Services/Scripts/ServiceTest.php +++ b/test/php/Services/Scripts/ServiceTest.php @@ -46,7 +46,7 @@ public function setUp(): void { $this->retriever = $this->createMock(Retriever::class); $this->filter = $this->createMock(ServiceFilter::class); $this->filter->method('apply') - ->willReturnCallback(function (Resource $resource, array $params = null) { + ->willReturnCallback(function (Resource $resource, ?array $params = null) { if (isset($this->returnResource)) { return $this->returnResource; }