From 8f40fa616236262de8d82654c1509355a0cdbd0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 10 Jul 2022 13:30:51 +0200 Subject: [PATCH] Continued: - added missing type-hints --- framework/main/classes/class_BaseFrameworkSystem.php | 7 ++----- .../main/classes/compressor/class_Bzip2Compressor.php | 4 ++-- framework/main/classes/compressor/class_GzipCompressor.php | 4 ++-- framework/main/classes/compressor/class_NullCompressor.php | 4 ++-- framework/main/classes/compressor/class_ZlibCompressor.php | 4 ++-- framework/main/classes/points/class_UserPoints.php | 6 +++--- framework/main/interfaces/compressor/class_Compressor.php | 4 ++-- framework/main/interfaces/points/class_BookablePoints.php | 4 ++-- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 35add654..36e7bd6b 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -1337,7 +1337,7 @@ Loaded includes: * @param $keyGroup Main group for the key * @return $count Count of given group */ - protected final function countGenericArray ($keyGroup) { + protected final function countGenericArray (string $keyGroup) { // Debug message //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup); @@ -1425,7 +1425,7 @@ Loaded includes: * @param $keyGroup Key group to get * @return $array Whole generic array group */ - protected final function getGenericArray ($keyGroup) { + protected final function getGenericArray (string $keyGroup) { // Debug message //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup); @@ -1579,9 +1579,6 @@ Loaded includes: * @return $translated Translated boolean value */ public static final function translateBooleanToYesNo (bool $boolean) { - // Make sure it is really boolean - assert(is_bool($boolean)); - // "Translate" it $translated = ($boolean === true) ? 'Y' : 'N'; diff --git a/framework/main/classes/compressor/class_Bzip2Compressor.php b/framework/main/classes/compressor/class_Bzip2Compressor.php index 8aa0055f..64602350 100644 --- a/framework/main/classes/compressor/class_Bzip2Compressor.php +++ b/framework/main/classes/compressor/class_Bzip2Compressor.php @@ -68,7 +68,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The compressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function compressStream ($streamData) { + public function compressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception @@ -86,7 +86,7 @@ class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The decompressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function decompressStream ($streamData) { + public function decompressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception diff --git a/framework/main/classes/compressor/class_GzipCompressor.php b/framework/main/classes/compressor/class_GzipCompressor.php index 20f997d1..7f7f9ca4 100644 --- a/framework/main/classes/compressor/class_GzipCompressor.php +++ b/framework/main/classes/compressor/class_GzipCompressor.php @@ -68,7 +68,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The compressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function compressStream ($streamData) { + public function compressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception @@ -86,7 +86,7 @@ class GzipCompressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The decompressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function decompressStream ($streamData) { + public function decompressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception diff --git a/framework/main/classes/compressor/class_NullCompressor.php b/framework/main/classes/compressor/class_NullCompressor.php index 58d6f0cd..dd813fec 100644 --- a/framework/main/classes/compressor/class_NullCompressor.php +++ b/framework/main/classes/compressor/class_NullCompressor.php @@ -62,7 +62,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The compressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function compressStream ($streamData) { + public function compressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception @@ -80,7 +80,7 @@ class NullCompressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The decompressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function decompressStream ($streamData) { + public function decompressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception diff --git a/framework/main/classes/compressor/class_ZlibCompressor.php b/framework/main/classes/compressor/class_ZlibCompressor.php index ddd56a67..fc36c2b9 100644 --- a/framework/main/classes/compressor/class_ZlibCompressor.php +++ b/framework/main/classes/compressor/class_ZlibCompressor.php @@ -68,7 +68,7 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The compressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function compressStream ($streamData) { + public function compressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception @@ -86,7 +86,7 @@ class ZlibCompressor extends BaseFrameworkSystem implements Compressor { * @return $streamData The decompressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - public function decompressStream ($streamData) { + public function decompressStream (string $streamData) { // Validate parameter if (is_object($streamData) || is_resource($streamData)) { // Throw an exception diff --git a/framework/main/classes/points/class_UserPoints.php b/framework/main/classes/points/class_UserPoints.php index 39b94a2f..49be57d6 100644 --- a/framework/main/classes/points/class_UserPoints.php +++ b/framework/main/classes/points/class_UserPoints.php @@ -97,7 +97,7 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo * @param $amount Amount of points to store * @return void */ - public final function setAmount ($amount) { + public final function setAmount (float $amount) { $this->amount = (float) $amount; } @@ -117,7 +117,7 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo * @return $hasRequired Whether the user has the required points * @todo Finish loading part of points */ - public function ifUserHasRequiredPoints ($action) { + public function ifUserHasRequiredPoints (string $action) { // Default is that everyone is poor... ;-) $hasRequired = false; @@ -146,7 +146,7 @@ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePo * @param $amount Amount of points we shall book * @return void */ - public function bookPointsDirectly ($amount) { + public function bookPointsDirectly (float $amount) { // Rewind always $this->getResultInstance()->rewind(); diff --git a/framework/main/interfaces/compressor/class_Compressor.php b/framework/main/interfaces/compressor/class_Compressor.php index 3e467fe0..a8aa359d 100644 --- a/framework/main/interfaces/compressor/class_Compressor.php +++ b/framework/main/interfaces/compressor/class_Compressor.php @@ -35,7 +35,7 @@ interface Compressor extends FrameworkInterface { * @return $streamData The compressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - function compressStream ($streamData); + function compressStream (string $streamData); /** * A decompression stream @@ -44,7 +44,7 @@ interface Compressor extends FrameworkInterface { * @return $streamData The decompressed stream data * @throws InvalidArgumentException If the stream is not compressable or decompressable */ - function decompressStream ($streamData); + function decompressStream (string $streamData); /** * Getter for the file extension of this compressor diff --git a/framework/main/interfaces/points/class_BookablePoints.php b/framework/main/interfaces/points/class_BookablePoints.php index 7c072a2b..d35bdd7a 100644 --- a/framework/main/interfaces/points/class_BookablePoints.php +++ b/framework/main/interfaces/points/class_BookablePoints.php @@ -34,7 +34,7 @@ interface BookablePoints extends AddableCriteria { * @param $action The action or configuration entry plus prefix the user wants to perform * @return $hasRequired Whether the user has the required points */ - function ifUserHasRequiredPoints ($action); + function ifUserHasRequiredPoints (string $action); /** * "Books" the given points amount on the current user's account @@ -42,6 +42,6 @@ interface BookablePoints extends AddableCriteria { * @param $amount Amount of points we shall book * @return void */ - function bookPointsDirectly ($amount); + function bookPointsDirectly (float $amount); } -- 2.39.5