diff options
author | Thomas Lange <code@nerdmind.de> | 2021-10-24 17:23:44 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-10-24 17:33:14 +0200 |
commit | 76cdd118d68bda3b7b29b192c7bf3d6e02bd6079 (patch) | |
tree | ec9159bd6ea23c9319d2fec58d182aeeb08d2c88 /include | |
parent | 10c0d433f4d2557bd57cf1f2e3b2bbd760ba804c (diff) | |
download | bigpipe-76cdd118d68bda3b7b29b192c7bf3d6e02bd6079.tar.gz bigpipe-76cdd118d68bda3b7b29b192c7bf3d6e02bd6079.tar.xz bigpipe-76cdd118d68bda3b7b29b192c7bf3d6e02bd6079.zip |
Add parameter and return types for all PHP methods
Diffstat (limited to 'include')
-rw-r--r-- | include/classes/Application.php | 6 | ||||
-rw-r--r-- | include/classes/BigPipe/BigPipe.php | 8 | ||||
-rw-r--r-- | include/classes/BigPipe/Item.php | 4 | ||||
-rw-r--r-- | include/classes/BigPipe/Pagelet.php | 18 | ||||
-rw-r--r-- | include/classes/BigPipe/Resource.php | 8 | ||||
-rw-r--r-- | include/classes/BigPipe/Resource/Javascript.php | 4 | ||||
-rw-r--r-- | include/classes/BigPipe/Resource/Stylesheet.php | 4 | ||||
-rw-r--r-- | include/classes/Debugging/Pagelet.php | 2 | ||||
-rw-r--r-- | include/classes/Debugging/Resource/Javascript.php | 2 | ||||
-rw-r--r-- | include/classes/Debugging/Resource/Stylesheet.php | 2 |
10 files changed, 29 insertions, 29 deletions
diff --git a/include/classes/Application.php b/include/classes/Application.php index 88161cc..c6ae419 100644 --- a/include/classes/Application.php +++ b/include/classes/Application.php @@ -5,7 +5,7 @@ class Application { #=============================================================================== # Create Pagelet instance #=============================================================================== - public static function createPagelet($ID = NULL): BigPipe\Pagelet { + public static function createPagelet(string $ID = NULL): BigPipe\Pagelet { $namespace = self::$debugging ? 'Debugging' : 'BigPipe'; $classname = "{$namespace}\Pagelet"; @@ -16,7 +16,7 @@ class Application { #=============================================================================== # Create Stylesheet instance #=============================================================================== - public static function createStylesheet($ID, $href): BigPipe\Resource\Stylesheet { + public static function createStylesheet(string $ID, string $href): BigPipe\Resource\Stylesheet { $namespace = self::$debugging ? 'Debugging' : 'BigPipe'; $classname = "{$namespace}\Resource\Stylesheet"; @@ -27,7 +27,7 @@ class Application { #=============================================================================== # Create Javascript instance #=============================================================================== - public static function createJavascript($ID, $href): BigPipe\Resource\Javascript { + public static function createJavascript(string $ID, string $href): BigPipe\Resource\Javascript { $namespace = self::$debugging ? 'Debugging' : 'BigPipe'; $classname = "{$namespace}\Resource\Javascript"; diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php index 6162388..236c1e2 100644 --- a/include/classes/BigPipe/BigPipe.php +++ b/include/classes/BigPipe/BigPipe.php @@ -31,28 +31,28 @@ class BigPipe { #=============================================================================== # Insert pagelet into queue #=============================================================================== - public static function enqueue(Pagelet $Pagelet) { + public static function enqueue(Pagelet $Pagelet): void { self::$pagelets[spl_object_hash($Pagelet)] = $Pagelet; } #=============================================================================== # Remove pagelet from queue #=============================================================================== - public static function dequeue(Pagelet $Pagelet) { + public static function dequeue(Pagelet $Pagelet): void { unset(self::$pagelets[spl_object_hash($Pagelet)]); } #=============================================================================== # Sends output buffer so far as possible towards user #=============================================================================== - public static function flushOutputBuffer() { + public static function flushOutputBuffer(): void { ob_flush(); flush(); } #=============================================================================== # Renders all remaining pagelets from the queue in the appropriate order #=============================================================================== - public static function completeResponse() { + public static function completeResponse(): void { self::flushOutputBuffer(); $pagelets_ordered = []; diff --git a/include/classes/BigPipe/Item.php b/include/classes/BigPipe/Item.php index adfe102..126cd5c 100644 --- a/include/classes/BigPipe/Item.php +++ b/include/classes/BigPipe/Item.php @@ -22,7 +22,7 @@ abstract class Item { #=============================================================================== # Return the unique ID #=============================================================================== - public function getID() { + public function getID(): string { return $this->ID; } @@ -36,7 +36,7 @@ abstract class Item { #=============================================================================== # Attach a PhaseDoneJS callback #=============================================================================== - public function addPhaseDoneJS($phase, $code): void { + public function addPhaseDoneJS(int $phase, string $code): void { $this->phaseDoneJS[$phase][] = $code; } } diff --git a/include/classes/BigPipe/Pagelet.php b/include/classes/BigPipe/Pagelet.php index 8c89539..985be54 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($customID = NULL, $priority = self::PRIORITY_NORMAL) { + public function __construct(string $customID = NULL, int $priority = self::PRIORITY_NORMAL) { $this->ID = $customID ?? spl_object_hash($this); $this->priority = $priority; @@ -48,14 +48,14 @@ class Pagelet extends Item { #=============================================================================== # Return the priority #=============================================================================== - public function getPriority() { + public function getPriority(): int { return $this->priority; } #=============================================================================== # Return the HTML content #=============================================================================== - public function getHTML() { + public function getHTML(): string { return $this->HTML; } @@ -83,7 +83,7 @@ class Pagelet extends Item { #=============================================================================== # Add HTML or attach more #=============================================================================== - public function addHTML($HTML): void { + public function addHTML(string $HTML): void { $this->HTML .= $HTML; } @@ -97,7 +97,7 @@ class Pagelet extends Item { #=============================================================================== # Attach a main JS code part #=============================================================================== - public function addJSCode($code): void { + public function addJSCode(string $code): void { $this->JSCode[] = $code; } @@ -111,14 +111,14 @@ class Pagelet extends Item { #=============================================================================== # Set custom placeholder tag name #=============================================================================== - public function setTagName($tagName): void { + public function setTagName(string $tagName): void { $this->tagName = $tagName; } #=============================================================================== # Set custom placeholder HTML #=============================================================================== - public function setPlaceholderHTML($HTML): void { + public function setPlaceholderHTML(string $HTML): void { $this->tagHTML = $HTML; } @@ -149,7 +149,7 @@ class Pagelet extends Item { #=============================================================================== # Flush pagelet immediately #=============================================================================== - public function flush() { + public function flush(): void { if(BigPipe::isEnabled()) { $pageletHTML = str_replace(["\r", "\n", "\t"], '', $this->getHTML()); $pageletHTML = str_replace('--', '--', $pageletHTML); @@ -167,7 +167,7 @@ class Pagelet extends Item { #=============================================================================== # Magic method: __toString() #=============================================================================== - public function __toString() { + public function __toString(): string { $pageletHTML = "<{$this->tagName} id=\"{$this->getID()}\">"; $pageletHTML .= !BigPipe::isEnabled() ? $this->getHTML() : $this->tagHTML; $pageletHTML .= "</{$this->tagName}>"; diff --git a/include/classes/BigPipe/Resource.php b/include/classes/BigPipe/Resource.php index a7ed728..d5ff21f 100644 --- a/include/classes/BigPipe/Resource.php +++ b/include/classes/BigPipe/Resource.php @@ -15,7 +15,7 @@ abstract class Resource extends Item { #=============================================================================== # Render resource HTML for disabled pipeline #=============================================================================== - abstract public function renderHTML(); + abstract public function renderHTML(): string; #=============================================================================== # Resource types @@ -33,7 +33,7 @@ abstract class Resource extends Item { #=============================================================================== # Build resource #=============================================================================== - public function __construct($customID, $type, $resourceURL) { + public function __construct(string $customID, int $type, string $resourceURL) { $this->ID = $customID ?? spl_object_hash($this); $this->type = $type; $this->resourceURL = $resourceURL; @@ -44,14 +44,14 @@ abstract class Resource extends Item { #=============================================================================== # Return the resource type #=============================================================================== - public function getType() { + public function getType(): int { return $this->type; } #=============================================================================== # Return the resource URL #=============================================================================== - public function getURL() { + public function getURL(): string { return $this->resourceURL; } diff --git a/include/classes/BigPipe/Resource/Javascript.php b/include/classes/BigPipe/Resource/Javascript.php index 3bd79d3..099432d 100644 --- a/include/classes/BigPipe/Resource/Javascript.php +++ b/include/classes/BigPipe/Resource/Javascript.php @@ -13,14 +13,14 @@ class Javascript extends \BigPipe\Resource { #=============================================================================== # Build resource #=============================================================================== - public function __construct($customID, $resourceURL) { + public function __construct(string $customID, string $resourceURL) { parent::__construct($customID, parent::TYPE_JAVASCRIPT, $resourceURL); } #=============================================================================== # Render resource HTML #=============================================================================== - public function renderHTML() { + public function renderHTML(): string { return sprintf('<script data-id="%s" src="%s"></script>', $this->getID(), $this->getURL()); } } diff --git a/include/classes/BigPipe/Resource/Stylesheet.php b/include/classes/BigPipe/Resource/Stylesheet.php index 90dadf3..daa7561 100644 --- a/include/classes/BigPipe/Resource/Stylesheet.php +++ b/include/classes/BigPipe/Resource/Stylesheet.php @@ -13,14 +13,14 @@ class Stylesheet extends \BigPipe\Resource { #=============================================================================== # Build resource #=============================================================================== - public function __construct($customID, $resourceURL) { + public function __construct(string $customID, string $resourceURL) { parent::__construct($customID, parent::TYPE_STYLESHEET, $resourceURL); } #=============================================================================== # Render resource HTML #=============================================================================== - public function renderHTML() { + public function renderHTML(): string { return sprintf('<link data-id="%s" href="%s" rel="stylesheet" />', $this->getID(), $this->getURL()); } } diff --git a/include/classes/Debugging/Pagelet.php b/include/classes/Debugging/Pagelet.php index e4e15f6..41eeb8f 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($customID = NULL, $priority = self::PRIORITY_NORMAL) { + public function __construct(string $customID = 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 4d0d47c..a0f988f 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($customID, $resourceURL) { + public function __construct(string $customID, string $resourceURL) { 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 39ce8a4..028752f 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($customID, $resourceURL) { + public function __construct(string $customID, string $resourceURL) { parent::__construct(...func_get_args()); foreach(['INIT', 'LOAD', 'DONE'] as $phase) { |