From 0424f5fc59af574442749cd7a3d7090ee204cd2e Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 24 Oct 2021 18:23:51 +0200 Subject: Fix a bug in the Item constructor parameter list The id parameter of the Pagelet and Resource constructor doesn't accept NULL values anymore (since 76cdd118d68bda3b7b29b192c7bf3d6e02bd6079). Therefore, allow NULL values by using the parameter type "?string" instead of "string" to allow either string values or NULL. --- include/classes/BigPipe/Pagelet.php | 2 +- include/classes/BigPipe/Resource.php | 2 +- include/classes/BigPipe/Resource/Javascript.php | 2 +- include/classes/BigPipe/Resource/Stylesheet.php | 2 +- include/classes/Debugging/Pagelet.php | 2 +- include/classes/Debugging/Resource/Javascript.php | 2 +- include/classes/Debugging/Resource/Stylesheet.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include/classes') diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index daca9df..d6f2103 100644 --- a/include/classes/BigPipe/Pagelet.php +++ b/include/classes/BigPipe/Pagelet.php @@ -35,7 +35,7 @@ class Pagelet extends Item { const PHASE_LOADJS = 3; # After all the JS resources have been loaded const PHASE_DONE = 4; # After the static JS code has been executed - public function __construct(string $id = NULL, int $priority = self::PRIORITY_NORMAL) { + public function __construct(?string $id = NULL, int $priority = self::PRIORITY_NORMAL) { $this->id = $id ?? spl_object_hash($this); $this->priority = $priority; diff --git a/include/classes/BigPipe/Resource.php b/include/classes/BigPipe/Resource.php index 92b61ef..b6f3b8c 100644 --- a/include/classes/BigPipe/Resource.php +++ b/include/classes/BigPipe/Resource.php @@ -33,7 +33,7 @@ abstract class Resource extends Item { #=============================================================================== # Build resource #=============================================================================== - public function __construct(string $id, int $type, string $url) { + public function __construct(?string $id, int $type, string $url) { $this->id = $id ?? spl_object_hash($this); $this->type = $type; $this->url = $url; diff --git a/include/classes/BigPipe/Resource/Javascript.php b/include/classes/BigPipe/Resource/Javascript.php index b549075..6a9d492 100644 --- a/include/classes/BigPipe/Resource/Javascript.php +++ b/include/classes/BigPipe/Resource/Javascript.php @@ -13,7 +13,7 @@ class Javascript extends \BigPipe\Resource { #=============================================================================== # Build resource #=============================================================================== - public function __construct(string $id, string $url) { + public function __construct(?string $id, string $url) { parent::__construct($id, parent::TYPE_JAVASCRIPT, $url); } diff --git a/include/classes/BigPipe/Resource/Stylesheet.php b/include/classes/BigPipe/Resource/Stylesheet.php index a5998df..9f4afba 100644 --- a/include/classes/BigPipe/Resource/Stylesheet.php +++ b/include/classes/BigPipe/Resource/Stylesheet.php @@ -13,7 +13,7 @@ class Stylesheet extends \BigPipe\Resource { #=============================================================================== # Build resource #=============================================================================== - public function __construct(string $id, string $url) { + public function __construct(?string $id, string $url) { parent::__construct($id, parent::TYPE_STYLESHEET, $url); } diff --git a/include/classes/Debugging/Pagelet.php b/include/classes/Debugging/Pagelet.php index 9bae56e..a8a23d7 100644 --- a/include/classes/Debugging/Pagelet.php +++ b/include/classes/Debugging/Pagelet.php @@ -2,7 +2,7 @@ namespace Debugging; class Pagelet extends \BigPipe\Pagelet { - public function __construct(string $id = NULL, int $priority = self::PRIORITY_NORMAL) { + public function __construct(?string $id = NULL, int $priority = self::PRIORITY_NORMAL) { parent::__construct(...func_get_args()); foreach(['INIT', 'LOADCSS', 'HTML', 'LOADJS', 'DONE'] as $phase) { diff --git a/include/classes/Debugging/Resource/Javascript.php b/include/classes/Debugging/Resource/Javascript.php index a2d7d75..d7acb60 100644 --- a/include/classes/Debugging/Resource/Javascript.php +++ b/include/classes/Debugging/Resource/Javascript.php @@ -2,7 +2,7 @@ namespace Debugging\Resource; class Javascript extends \BigPipe\Resource\Javascript { - public function __construct(string $id, string $url) { + public function __construct(?string $id, string $url) { parent::__construct(...func_get_args()); foreach(['INIT', 'LOAD', 'DONE'] as $phase) { diff --git a/include/classes/Debugging/Resource/Stylesheet.php b/include/classes/Debugging/Resource/Stylesheet.php index 1acaa4b..abd9045 100644 --- a/include/classes/Debugging/Resource/Stylesheet.php +++ b/include/classes/Debugging/Resource/Stylesheet.php @@ -2,7 +2,7 @@ namespace Debugging\Resource; class Stylesheet extends \BigPipe\Resource\Stylesheet { - public function __construct(string $id, string $url) { + public function __construct(?string $id, string $url) { parent::__construct(...func_get_args()); foreach(['INIT', 'LOAD', 'DONE'] as $phase) { -- cgit v1.2.3