From 76cdd118d68bda3b7b29b192c7bf3d6e02bd6079 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Sun, 24 Oct 2021 17:23:44 +0200 Subject: Add parameter and return types for all PHP methods --- include/classes/BigPipe/Pagelet.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/classes/BigPipe/Pagelet.php') 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 .= "tagName}>"; -- cgit v1.2.3