From ef7a7e55c59c9e887e6bb09c8c02b8126309f716 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 2 Dec 2020 18:45:47 +0100 Subject: [PATCH] Continued: - added type-hints for primitive variables - thanks to these type-hints, some tests are no longer needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../bootstrap/class_FrameworkBootstrap.php | 13 +- .../config/class_FrameworkConfiguration.php | 93 ++--- .../main/classes/auth/class_CookieAuth.php | 4 +- .../classes/crypto/class_CryptoHelper.php | 9 +- .../classes/discovery/class_BaseDiscovery.php | 4 +- .../classes/handler/class_BaseHandler.php | 2 +- .../handler/tasks/class_TaskHandler.php | 28 +- .../captcha/images/class_ImageHelper.php | 36 +- .../web/class_GraphicalCodeCaptcha.php | 2 +- .../main/classes/helper/class_BaseHelper.php | 36 +- .../html/blocks/class_HtmlBlockHelper.php | 4 +- .../html/forms/class_HtmlFormHelper.php | 59 ++-- .../html/links/class_HtmlLinkHelper.php | 20 +- .../classes/request/class_BaseRequest.php | 6 +- .../request/console/class_ConsoleRequest.php | 4 +- .../request/html/class_HtmlRequest.php | 4 +- .../main/classes/states/class_BaseState.php | 2 +- .../crypto/mcrypt/class_McryptStream.php | 4 +- .../crypto/null/class_NullCryptoStream.php | 17 +- .../crypto/openssl/class_OpenSslStream.php | 4 +- .../image/class_ImageTemplateEngine.php | 22 +- .../mail/class_MailTemplateEngine.php | 4 +- .../menu/class_MenuTemplateEngine.php | 16 +- .../xml/class_BaseXmlTemplateEngine.php | 10 +- .../database/class_DatabaseException.php | 2 +- .../interfaces/crypto/class_Cryptable.php | 6 +- .../handler/task/class_HandleableTask.php | 4 +- .../registration/class_UserRegister.php | 2 +- .../interfaces/request/class_Requestable.php | 6 +- .../crypto/class_EncryptableStream.php | 5 +- .../class_FrameworkBootstrapTest.php | 80 ----- .../config/FrameworkConfigurationTest.php | 320 ------------------ 32 files changed, 192 insertions(+), 636 deletions(-) diff --git a/framework/bootstrap/class_FrameworkBootstrap.php b/framework/bootstrap/class_FrameworkBootstrap.php index 0e0cdb6a..9f376df5 100644 --- a/framework/bootstrap/class_FrameworkBootstrap.php +++ b/framework/bootstrap/class_FrameworkBootstrap.php @@ -449,18 +449,11 @@ final class FrameworkBootstrap { * * @param $timezone The timezone string (e.g. Europe/Berlin) * @return $success If timezone was accepted - * @throws NullPointerException If $timezone is NULL * @throws InvalidArgumentException If $timezone is empty */ - public static function setDefaultTimezone ($timezone) { - // Is it null? - if (is_null($timezone)) { - // Throw NPE - throw new NullPointerException(NULL, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_string($timezone)) { - // Is not a string - throw new InvalidArgumentException(sprintf('timezone[]=%s is not a string', gettype($timezone))); - } elseif ((is_string($timezone)) && (empty($timezone))) { + public static function setDefaultTimezone (string $timezone) { + // Is it set? + if (empty($timezone)) { // Entry is empty throw new InvalidArgumentException('timezone is empty'); } diff --git a/framework/config/class_FrameworkConfiguration.php b/framework/config/class_FrameworkConfiguration.php index 0d5560a5..132fba6a 100644 --- a/framework/config/class_FrameworkConfiguration.php +++ b/framework/config/class_FrameworkConfiguration.php @@ -6,7 +6,6 @@ namespace Org\Mxchange\CoreFramework\Configuration; // Import framework stuff use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; -use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\Registerable; @@ -84,18 +83,11 @@ class FrameworkConfiguration implements Registerable { * * @param $configKey The configuration key we shall check * @return $isset Whether the given configuration key is set - * @throws NullPointerException If $configKey is NULL * @throws InvalidArgumentException If $configKey is empty */ - public function isConfigurationEntrySet ($configKey) { + public function isConfigurationEntrySet (string $configKey) { // Is it null? - if (is_null($configKey)) { - // Throw NPE - throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_string($configKey)) { - // Is not a string - throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY); - } elseif ((is_string($configKey)) && (empty($configKey))) { + if (empty($configKey)) { // Entry is empty throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY); } @@ -112,19 +104,12 @@ class FrameworkConfiguration implements Registerable { * * @param $configKey The configuration element * @return $configValue The fetched configuration value - * @throws NullPointerException If $configKey is NULL * @throws InvalidArgumentException If $configKey is empty * @throws NoConfigEntryException If a configuration element was not found */ - public function getConfigEntry ($configKey) { + public function getConfigEntry (string $configKey) { // Is it null? - if (is_null($configKey)) { - // Throw NPE - throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_string($configKey)) { - // Is not a string - throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY); - } elseif ((is_string($configKey)) && (empty($configKey))) { + if (empty($configKey)) { // Entry is empty throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY); } @@ -148,19 +133,12 @@ class FrameworkConfiguration implements Registerable { * @param $configKey The configuration key we want to add/change * @param $configValue The configuration value we want to set * @return void - * @throws NullPointerException If $configKey is NULL * @throws InvalidArgumentException If $configKey is empty * @throws InvalidArgumentException If $configValue has an unsupported variable type */ - public final function setConfigEntry ($configKey, $configValue) { + public final function setConfigEntry (string $configKey, $configValue) { // Is a valid configuration key key provided? - if (is_null($configKey)) { - // Configuration key is null - throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_string($configKey)) { - // Is not a string - throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY); - } elseif ((is_string($configKey)) && (empty($configKey))) { + if (empty($configKey)) { // Entry is empty throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY); } elseif ((is_array($configValue)) || (is_object($configValue)) || (is_resource($configValue))) { @@ -195,19 +173,12 @@ class FrameworkConfiguration implements Registerable { * * @param $configKey Configuration key to unset * @return void - * @throws NullPointerException If $configKey is NULL * @throws InvalidArgumentException If $configKey is empty * @throws NoConfigEntryException If a configuration element was not found */ - public final function unsetConfigEntry ($configKey) { + public final function unsetConfigEntry (string $configKey) { // Validate parameters - if (is_null($configKey)) { - // Configuration key is null - throw new NullPointerException($this, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_string($configKey)) { - // Entry is empty - throw new InvalidArgumentException(sprintf('configKey[]=%s is not a string', gettype($configKey)), self::EXCEPTION_CONFIG_KEY_IS_EMPTY); - } elseif ((is_string($configKey)) && (empty($configKey))) { + if (empty($configKey)) { // Entry is empty throw new InvalidArgumentException('configKey is empty', self::EXCEPTION_CONFIG_KEY_IS_EMPTY); } @@ -225,30 +196,6 @@ class FrameworkConfiguration implements Registerable { unset(self::$config[$configKey]); } - /** - * Getter for field name - * - * @param $fieldName Field name which we shall get - * @return $fieldValue Field value from the user - * @throws NullPointerException If the result instance is null - */ - public final function getField ($fieldName) { - // The super interface "FrameworkInterface" requires this - throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks if given field is set - * - * @param $fieldName Field name to check - * @return $isSet Whether the given field name is set - * @throws NullPointerException If the result instance is null - */ - public function isFieldSet ($fieldName) { - // The super interface "FrameworkInterface" requires this - throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION); - } - /** * Generates a code for hashes from this class * @@ -287,4 +234,28 @@ class FrameworkConfiguration implements Registerable { $this->callbackInstance = $callbackInstance; } + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + * @throws NullPointerException If the result instance is null + */ + public final function getField (string $fieldName) { + // The super interface "FrameworkInterface" requires this + throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks if given field is set + * + * @param $fieldName Field name to check + * @return $isSet Whether the given field name is set + * @throws NullPointerException If the result instance is null + */ + public function isFieldSet (string $fieldName) { + // The super interface "FrameworkInterface" requires this + throw new UnsupportedOperationException(array($this, __FUNCTION__), BaseFrameworkSystem::EXCEPTION_UNSPPORTED_OPERATION); + } + } diff --git a/framework/main/classes/auth/class_CookieAuth.php b/framework/main/classes/auth/class_CookieAuth.php index 659c9768..c9bd58d2 100644 --- a/framework/main/classes/auth/class_CookieAuth.php +++ b/framework/main/classes/auth/class_CookieAuth.php @@ -61,7 +61,7 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera * @param $userName The username from request we shall set * @return void */ - public function setUserAuth ($userName) { + public function setUserAuth (string $userName) { FrameworkBootstrap::getResponseInstance()->addCookie('username', $userName); } @@ -71,7 +71,7 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera * @param $passHash The hashed password from request we shall set * @return void */ - public function setPasswordAuth ($passHash) { + public function setPasswordAuth (string $passHash) { FrameworkBootstrap::getResponseInstance()->addCookie('u_hash', $passHash); } diff --git a/framework/main/classes/crypto/class_CryptoHelper.php b/framework/main/classes/crypto/class_CryptoHelper.php index 7ef8d3f3..c5115dec 100644 --- a/framework/main/classes/crypto/class_CryptoHelper.php +++ b/framework/main/classes/crypto/class_CryptoHelper.php @@ -201,10 +201,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) * @return $hashed The hashed and salted string */ - public function hashString ($str, $oldHash = '', $withFixed = true) { - // Cast the string - $str = (string) $str; - + public function hashString (string $str, string $oldHash = '', bool $withFixed = true) { // Default is the default salt ;-) $salt = $this->salt; @@ -245,7 +242,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { * @param $key Optional key, if none provided, a random key will be generated * @return $encrypted Encrypted string */ - public function encryptString ($str, $key = NULL) { + public function encryptString (string $str, string $key = NULL) { // Encrypt the string through the stream $encrypted = $this->cryptoStreamInstance->encryptStream($str, $key); @@ -259,7 +256,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { * @param $encrypted Encrypted string * @return $str The unencrypted string */ - public function decryptString ($encrypted) { + public function decryptString (string $encrypted) { // Encrypt the string through the stream $str = $this->cryptoStreamInstance->decryptStream($encrypted); diff --git a/framework/main/classes/discovery/class_BaseDiscovery.php b/framework/main/classes/discovery/class_BaseDiscovery.php index 62740e8e..47160076 100644 --- a/framework/main/classes/discovery/class_BaseDiscovery.php +++ b/framework/main/classes/discovery/class_BaseDiscovery.php @@ -50,8 +50,8 @@ abstract class BaseDiscovery extends BaseFrameworkSystem { * @param $actionName Action name to set * @return void */ - protected final function setActionName ($actionName) { - $this->actionName = (string) $actionName; + protected final function setActionName (string $actionName) { + $this->actionName = $actionName; } /** diff --git a/framework/main/classes/handler/class_BaseHandler.php b/framework/main/classes/handler/class_BaseHandler.php index 03751cce..e18c0f60 100644 --- a/framework/main/classes/handler/class_BaseHandler.php +++ b/framework/main/classes/handler/class_BaseHandler.php @@ -61,7 +61,7 @@ abstract class BaseHandler extends BaseFrameworkSystem implements HandleableData * @param $handlerName Name of this handler * @return void */ - protected final function setHandlerName ($handlerName) { + protected final function setHandlerName (string $handlerName) { $this->handlerName = $handlerName; } diff --git a/framework/main/classes/handler/tasks/class_TaskHandler.php b/framework/main/classes/handler/tasks/class_TaskHandler.php index 84b9f603..3bbe3938 100644 --- a/framework/main/classes/handler/tasks/class_TaskHandler.php +++ b/framework/main/classes/handler/tasks/class_TaskHandler.php @@ -105,7 +105,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { if (!$this->getListInstance()->getIterator()->valid()) { // Not valid! throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID); - } // END - if + } // Get current task $currentTask = $this->getListInstance()->getIterator()->current(); @@ -120,7 +120,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Skip this silently //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']); return; - } // END - if + } // Launch the task and mark it as updated $currentTask['task_started'] = true; @@ -128,7 +128,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms'); - } // END - if + } // Get time difference from interval delay $diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000; @@ -142,11 +142,11 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { if ($updateTask === true) { // Update the task before leaving $this->updateTask($currentTask); - } // END - if + } // Skip this silently return; - } // END - if + } // Set last activity $currentTask['task_last_activity'] = $this->getMilliTime(); @@ -218,8 +218,8 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Abort here break; - } // END - if - } // END - foreach + } + } // Return found name return $taskName; @@ -229,10 +229,10 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { * Registers a task with a task handler. * * @param $taskName A task name to register the task on - * @param $taskInstance The instance that should be registered as a task + * @param $taskInstance An instance of a Taskable class * @return void */ - public function registerTask ($taskName, Visitable $taskInstance) { + public function registerTask (string $taskName, Taskable $taskInstance) { // Get interval delay $intervalDelay = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_interval_delay'); $startupDelay = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_startup_delay'); @@ -243,7 +243,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { assert(($taskName === 'idle_loop') || (($taskName != 'idle_loop') && ($startupDelay > 0))); // Create the entry - $taskEntry = array( + $taskEntry = [ // Identifier for the generateHash() method 'id' => $taskName, // Whether the task is started @@ -266,7 +266,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { 'task_interval_delay' => $intervalDelay, // How often should this task run? 'task_max_runs' => FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('task_' . $taskName . '_max_runs'), - ); + ]; // Add the entry $this->getListInstance()->addEntry('tasks', $taskEntry); @@ -306,7 +306,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { if (!$this->getListInstance()->getIterator()->valid()) { // Rewind to the beginning for next loop $this->getListInstance()->getIterator()->rewind(); - } // END - if + } // Try to execute the task $this->executeCurrentTask(); @@ -350,7 +350,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Advance to next one $this->getListInstance()->getIterator()->next(); - } // END - while + } // Debug message self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK-HANDLER: Shutdown of all tasks completed.'); @@ -358,7 +358,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Remove all tasks foreach ($tasks as $entry) { $this->unregisterTask($entry); - } // END - foreach + } } } diff --git a/framework/main/classes/helper/captcha/images/class_ImageHelper.php b/framework/main/classes/helper/captcha/images/class_ImageHelper.php index 1353efc2..a1ef9add 100644 --- a/framework/main/classes/helper/captcha/images/class_ImageHelper.php +++ b/framework/main/classes/helper/captcha/images/class_ImageHelper.php @@ -123,8 +123,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $imageType Type of the image * @return void */ - protected final function setImageType ($imageType) { - $this->imageType = (string) $imageType; + protected final function setImageType (string $imageType) { + $this->imageType = $imageType; } /** @@ -142,8 +142,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $baseImage A base image template * @return void */ - public final function setBaseImage ($baseImage) { - $this->baseImage = (string) $baseImage; + public final function setBaseImage (string $baseImage) { + $this->baseImage = $baseImage; } /** @@ -161,8 +161,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $imageName Name of the image * @return void */ - public final function setImageName ($imageName) { - $this->imageName = (string) $imageName; + public final function setImageName (string $imageName) { + $this->imageName = $imageName; } /** @@ -180,8 +180,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $width Width of the image * @return void */ - public final function setWidth ($width) { - $this->width = (int) $width; + public final function setWidth (int $width) { + $this->width = $width; } /** @@ -199,8 +199,8 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { * @param $height Height of the image * @return void */ - public final function setHeight ($height) { - $this->height = (int) $height; + public final function setHeight (int $height) { + $this->height = $height; } /** @@ -224,13 +224,13 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { // Random numbers? if ($red === 'rand') { $red = $this->getRngInstance()->randomNumber(0, 255); - } // END - if + } if ($green === 'rand') { $green = $this->getRngInstance()->randomNumber(0, 255); - } // END - if + } if ($blue === 'rand') { $blue = $this->getRngInstance()->randomNumber(0, 255); - } // END - if + } $this->backgroundColor['red'] = (int) $red; $this->backgroundColor['green'] = (int) $green; @@ -249,13 +249,13 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { // Random numbers? if ($red === 'rand') { $red = $this->getRngInstance()->randomNumber(0, 255); - } // END - if + } if ($green === 'rand') { $green = $this->getRngInstance()->randomNumber(0, 255); - } // END - if + } if ($blue === 'rand') { $blue = $this->getRngInstance()->randomNumber(0, 255); - } // END - if + } $this->foregroundColor['red'] = (int) $red; $this->foregroundColor['green'] = (int) $green; @@ -339,7 +339,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { // Random font size? if ($fontSize === 'rand') { $fontSize = $this->getRngInstance()->randomNumber(4, 9); - } // END - if + } $this->imageStrings[$this->currString]['size'] = (int) $fontSize; } @@ -390,7 +390,7 @@ class ImageHelper extends BaseCaptcha implements HelpableTemplate { $templateInstance->addGroupVariable('image_y' , $this->getY()); $templateInstance->addGroupVariable('image_size' , $this->getFontSize()); $templateInstance->addGroupVariable('image_string', $this->getImageString()); - } // END - foreach + } // Get the raw content $imageContent = $templateInstance->getRawTemplateData(); diff --git a/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php b/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php index 4a229c0f..6d9d8574 100644 --- a/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php +++ b/framework/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php @@ -118,7 +118,7 @@ class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha { // Replace character $captchaString = str_replace($search, $replace, $captchaString, $captchaLength); - } // END - foreach + } // Get crypto instance $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); diff --git a/framework/main/classes/helper/class_BaseHelper.php b/framework/main/classes/helper/class_BaseHelper.php index d594489e..994988e5 100644 --- a/framework/main/classes/helper/class_BaseHelper.php +++ b/framework/main/classes/helper/class_BaseHelper.php @@ -97,8 +97,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $newContent New content to add * @return void */ - protected final function addContent ($newContent) { - $this->content .= (string) trim($newContent) . PHP_EOL; + protected final function addContent (string $newContent) { + $this->content .= trim($newContent) . PHP_EOL; } /** @@ -107,9 +107,9 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $content Content to to the base * @return void */ - protected function addHeaderContent ($content) { + protected function addHeaderContent (string $content) { // Add the header content - $this->groups['header']['content'] = (string) trim($content); + $this->groups['header']['content'] = trim($content); } /** @@ -118,9 +118,9 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $content Content to to the base * @return void */ - protected function addFooterContent ($content) { + protected function addFooterContent (string $content) { // Add the footer content - $this->groups['footer']['content'] = (string) trim($content); + $this->groups['footer']['content'] = trim($content); } /** @@ -131,7 +131,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $newContent New content to add * @return void */ - protected final function addContentToPreviousGroup ($newContent) { + protected final function addContentToPreviousGroup (string $newContent) { // Check for sub/group if ($this->ifSubGroupOpenedPreviously()) { // Get sub group id @@ -176,7 +176,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $fieldName Name of the field to assign * @return void */ - public function assignField ($fieldName) { + public function assignField (string $fieldName) { // Get the value from value instance $fieldValue = $this->getValueField($fieldName); @@ -254,7 +254,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperGroupAlreadyCreatedException If the group was already created before */ - protected function openGroupByIdContent ($groupId, $content, $tag) { + protected function openGroupByIdContent (string $groupId, string $content, string $tag) { //* DEBUG: */ echo "OPEN:groupId={$groupId},content=
".htmlentities($content)."
\n"; // Is the group already there? if (isset($this->groups[$groupId])) { @@ -289,7 +289,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found */ - public function closePreviousGroupByContent ($content = '') { + public function closePreviousGroupByContent (string $content = '') { // Check if any sub group was opened before if ($this->ifSubGroupOpenedPreviously()) { // Close it automatically @@ -341,7 +341,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before */ - protected function openSubGroupByIdContent ($subGroupId, $content, $tag) { + protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) { //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."
\n"; // Is the group already there? if (isset($this->subGroups[$subGroupId])) { @@ -370,7 +370,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found */ - public function closePreviousSubGroupByContent ($content = '') { + public function closePreviousSubGroupByContent (string $content = '') { // Check if any sub group was opened before if ($this->ifSubGroupOpenedPreviously() === false) { // Then throw an exception @@ -450,7 +450,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $groupId Id of group to check * @return $isOpened Whether the specified group is open */ - protected function ifGroupIsOpened ($groupId) { + protected function ifGroupIsOpened (string $groupId) { // Is the group open? $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true)); @@ -465,7 +465,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return $fieldValue Value from field * @throws NullPointerException Thrown if $valueInstance is null */ - public function getValueField ($fieldName) { + public function getValueField (string $fieldName) { // Init value $fieldValue = NULL; @@ -537,8 +537,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $previousGroupId Id of previously opened group * @return void */ - protected final function setPreviousGroupId ($previousGroupId) { - $this->previousGroupId = (string) $previousGroupId; + protected final function setPreviousGroupId (string $previousGroupId) { + $this->previousGroupId = $previousGroupId; } /** @@ -556,8 +556,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $previousSubGroupId Id of previously opened sub group * @return void */ - protected final function setPreviousSubGroupId ($previousSubGroupId) { - $this->previousSubGroupId = (string) $previousSubGroupId; + protected final function setPreviousSubGroupId (string $previousSubGroupId) { + $this->previousSubGroupId = $previousSubGroupId; } } diff --git a/framework/main/classes/helper/html/blocks/class_HtmlBlockHelper.php b/framework/main/classes/helper/html/blocks/class_HtmlBlockHelper.php index 346d56da..5611e603 100644 --- a/framework/main/classes/helper/html/blocks/class_HtmlBlockHelper.php +++ b/framework/main/classes/helper/html/blocks/class_HtmlBlockHelper.php @@ -72,8 +72,8 @@ class HtmlBlockHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $blockName Name of the block we shall generate * @return void */ - protected final function setBlockName ($blockName) { - $this->blockName = (string) $blockName; + protected final function setBlockName (string $blockName) { + $this->blockName = $blockName; } /** diff --git a/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php b/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php index 54422a82..add8e9fc 100644 --- a/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php +++ b/framework/main/classes/helper/html/forms/class_HtmlFormHelper.php @@ -83,7 +83,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $withForm Whether include the form tag * @return $helperInstance A preparedf instance of this helper */ - public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, $formId = false, bool $withForm = true) { + public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, string $formName, string $formId = NULL, bool $withForm = true) { // Get new instance $helperInstance = new HtmlFormHelper(); @@ -91,7 +91,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { $helperInstance->setTemplateInstance($templateInstance); // Is the form id not set? - if ($formId === false) { + if (is_null($formId)) { // Use form id from form name $formId = $formName; } // END - if @@ -121,12 +121,12 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @throws InvalidFormNameException If the form name is invalid ( = false) * @todo Add some unique PIN here to bypass problems with some browser and/or extensions */ - public function addFormTag ($formName = false, $formId = false) { + public function addFormTag (string $formName = NULL, string $formId = NULL) { // When the form is not yet opened at least form name must be valid - if (($this->formOpened === false) && ($formName === false)) { + if (($this->formOpened === false) && (is_null($formName))) { // Thrown an exception throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID); - } // END - if + } // Close the form is default $formContent = ''; @@ -177,7 +177,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputTextField ($fieldName, $fieldValue = '') { + public function addInputTextField (string $fieldName, string $fieldValue = '') { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -202,7 +202,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $fieldName Input field name * @return void */ - public function addInputTextFieldWithDefault ($fieldName) { + public function addInputTextFieldWithDefault (string $fieldName) { // Get the value from instance $fieldValue = $this->getValueField($fieldName); //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; @@ -220,7 +220,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputPasswordField ($fieldName, $fieldValue = '') { + public function addInputPasswordField (string $fieldName, string $fieldValue = '') { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -248,7 +248,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputHiddenField ($fieldName, $fieldValue = '') { + public function addInputHiddenField (string $fieldName, string $fieldValue = '') { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -271,7 +271,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $fieldName Input field name * @return void */ - public function addInputHiddenFieldWithDefault ($fieldName) { + public function addInputHiddenFieldWithDefault (string $fieldName) { // Get the value from instance $fieldValue = $this->getValueField($fieldName); //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; @@ -287,7 +287,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $prefix Prefix for configuration without trailing _ * @return void */ - public function addInputHiddenConfiguredField ($fieldName, $prefix) { + public function addInputHiddenConfiguredField (string $fieldName, string $prefix) { // Get the value from instance $fieldValue = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry("{$prefix}_{$fieldName}"); //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; @@ -305,7 +305,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputCheckboxField ($fieldName, $fieldChecked = true) { + public function addInputCheckboxField (string $fieldName, bool $fieldChecked = true) { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -313,8 +313,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { } // END - if // Set whether the check box is checked... - $checked = ' checked="checked"'; - if ($fieldChecked === false) $checked = ' '; + $checked = ($fieldChecked ? ' checked="checked"' : ' '); // Generate the content $inputContent = sprintf('', @@ -336,7 +335,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputResetButton ($buttonText) { + public function addInputResetButton (string $buttonText) { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -361,7 +360,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputSubmitButton ($buttonText) { + public function addInputSubmitButton (string $buttonText) { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -388,7 +387,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @throws FormClosedException If no form has been opened before * @throws InvalidArgumentException If $groupId is not set */ - public function addFormGroup ($groupId = '', $groupText = '') { + public function addFormGroup (string $groupId = '', string $groupText = '') { // Is a form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw exception here @@ -460,7 +459,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @throws FormFormClosedException If no group has been opened before * @throws InvalidArgumentException If $subGroupId is not set */ - public function addFormSubGroup ($subGroupId = '', $subGroupText = '') { + public function addFormSubGroup (string $subGroupId = '', string $subGroupText = '') { // Is a group opened? if ($this->ifGroupOpenedPreviously() === false) { // Throw exception here @@ -523,7 +522,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addFieldLabel ($fieldName, $fieldText, $fieldTitle = '') { + public function addFieldLabel (string $fieldName, string $fieldText, string $fieldTitle = '') { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -562,7 +561,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addFormNote ($noteId, $formNotes) { + public function addFormNote (string $noteId, string $formNotes) { // Is the form opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -590,7 +589,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws FormClosedException If the form is not yet opened */ - public function addInputSelectField ($selectId, $firstEntry) { + public function addInputSelectField (string $selectId, string $firstEntry) { // Is the form group opened? if (($this->formOpened === false) && ($this->formEnabled === true)) { // Throw an exception @@ -637,7 +636,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found * @todo Add checking if sub option is already added */ - public function addSelectSubOption ($subName, $subValue) { + public function addSelectSubOption (string $subName, string $subValue) { // Is there a sub group (shall be a selection box!) if ($this->ifSubGroupOpenedPreviously() === false) { // Then throw an exception here @@ -665,7 +664,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found * @todo Add checking if sub option is already added */ - public function addSelectOption ($optionName, $optionValue) { + public function addSelectOption (string $optionName, string $optionValue) { // Is there a sub group (shall be a selection box!) if ($this->ifSubGroupOpenedPreviously() === false) { // Then throw an exception here @@ -719,8 +718,8 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $formEnabled Whether form is enabled or disabled * @return void */ - public final function enableForm ($formEnabled = true) { - $this->formEnabled = (bool) $formEnabled; + public final function enableForm (bool $formEnabled = true) { + $this->formEnabled = $formEnabled; } /** @@ -729,8 +728,8 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $formName Name of this form * @return void */ - public final function setFormName ($formName) { - $this->formName = (string) $formName; + public final function setFormName (string $formName) { + $this->formName = $formName; } /** @@ -748,8 +747,8 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $formId Id of this form * @return void */ - public final function setFormId ($formId) { - $this->formId = (string) $formId; + public final function setFormId (string $formId) { + $this->formId = $formId; } /** @@ -826,7 +825,7 @@ class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { * * @return $required Whether the specified chat protocol is enabled */ - public function ifChatEnabled ($chatProtocol) { + public function ifChatEnabled (string $chatProtocol) { $required = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y'); return $required; } diff --git a/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php b/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php index 2dd3319c..e603d805 100644 --- a/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php +++ b/framework/main/classes/helper/html/links/class_HtmlLinkHelper.php @@ -139,7 +139,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $extraContent Optional extra HTML content * @return $linkContent Rendered text link content */ - private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') { + private function renderLinkContentWithTextExtraContent (string $linkText, string $linkTitle, string $extraContent = '') { // Construct link content $linkContent = sprintf('%s', $this->getLinkBase(), @@ -158,8 +158,8 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $linkName Name of the link we shall generate * @return void */ - protected final function setLinkName ($linkName) { - $this->linkName = (string) $linkName; + protected final function setLinkName (string $linkName) { + $this->linkName = $linkName; } /** @@ -177,8 +177,8 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $linkBase Base of the link we shall generate * @return void */ - protected final function setLinkBase ($linkBase) { - $this->linkBase = (string) $linkBase; + protected final function setLinkBase (string $linkBase) { + $this->linkBase = $linkBase; } /** @@ -222,7 +222,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $groupCode Code to open and close groups * @return void */ - public function addLinkGroup ($groupId, $groupText, $groupCode = 'div') { + public function addLinkGroup (string $groupId, string $groupText, string $groupCode = 'div') { // Is a group with that name open? if ($this->ifGroupOpenedPreviously()) { // Then close it here @@ -251,7 +251,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws NoGroupOpenedException If no previous group was opened */ - public function addLinkNote ($groupId, $groupNote, $groupCode = 'div') { + public function addLinkNote (string $groupId, string $groupNote, string $groupCode = 'div') { // Check if a previous group was opened if ($this->ifGroupOpenedPreviously() === false) { // No group was opened before! @@ -284,7 +284,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @return void * @throws NoGroupOpenedException If no previous group was opened */ - protected function addActionLink ($linkAction, $linkText, $linkTitle) { + protected function addActionLink (string $linkAction, string $linkText, string $linkTitle) { // Check if a previous group was opened if ($this->ifGroupOpenedPreviously() === false) { // No group was opened before! @@ -321,7 +321,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $languageId Language id string to use * @return void */ - public function addActionLinkById ($linkAction, $languageId) { + public function addActionLinkById (string $linkAction, string $languageId) { // Resolve the language string $languageResolvedText = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_text'); @@ -339,7 +339,7 @@ class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { * @param $languageId Language id string to use * @return void */ - public function addLinkWithTextById ($languageId) { + public function addLinkWithTextById (string $languageId) { // Resolve the language string $languageResolvedText = FrameworkBootstrap::getLanguageInstance()->getMessage('link_' . $languageId . '_text'); diff --git a/framework/main/classes/request/class_BaseRequest.php b/framework/main/classes/request/class_BaseRequest.php index c501680a..7ce49409 100644 --- a/framework/main/classes/request/class_BaseRequest.php +++ b/framework/main/classes/request/class_BaseRequest.php @@ -56,7 +56,7 @@ abstract class BaseRequest extends BaseFrameworkSystem { * @param $element Name of the request element we want to check * @return $isSet Whether the request element is set */ - public function isRequestElementSet ($element) { + public function isRequestElementSet (string $element) { // Is this element found? $isSet = isset($this->requestData[$element]); @@ -71,7 +71,7 @@ abstract class BaseRequest extends BaseFrameworkSystem { * @return $value Value of the found request element or 'null' if the * element was not found */ - public function getRequestElement ($element) { + public function getRequestElement (string $element) { // Initialize value $value = NULL; @@ -95,7 +95,7 @@ abstract class BaseRequest extends BaseFrameworkSystem { * @param $value Value to set * @return void */ - public function setRequestElement ($element, $value) { + public function setRequestElement (string $element, $value) { $this->requestData[$element] = $value; } diff --git a/framework/main/classes/request/console/class_ConsoleRequest.php b/framework/main/classes/request/console/class_ConsoleRequest.php index 0406c5e3..dd5f6ed7 100644 --- a/framework/main/classes/request/console/class_ConsoleRequest.php +++ b/framework/main/classes/request/console/class_ConsoleRequest.php @@ -105,7 +105,7 @@ class ConsoleRequest extends BaseRequest implements Requestable { * @return $headerValue Value of the header or 'null' if not found * @throws UnsupportedOperationException This method should never be called */ - public function getHeaderElement ($headerName) { + public function getHeaderElement (string $headerName) { // Console doesn't have any headers throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); } @@ -127,7 +127,7 @@ class ConsoleRequest extends BaseRequest implements Requestable { * @return $cookieValue Value of cookie or null if not found * @throws UnsupportedOperationException This method should never be called */ - public final function readCookie ($cookieName) { + public final function readCookie (string $cookieName) { // There are no cookies on console throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); } diff --git a/framework/main/classes/request/html/class_HtmlRequest.php b/framework/main/classes/request/html/class_HtmlRequest.php index f8b0fdba..77f36bee 100644 --- a/framework/main/classes/request/html/class_HtmlRequest.php +++ b/framework/main/classes/request/html/class_HtmlRequest.php @@ -104,7 +104,7 @@ class HtmlRequest extends BaseRequest implements Requestable { * @param $headerName Name of the header * @return $headerValue Value of the header or 'null' if not found */ - public function getHeaderElement ($headerName) { + public function getHeaderElement (string $headerName) { // Default return value on error $headerValue = NULL; @@ -135,7 +135,7 @@ class HtmlRequest extends BaseRequest implements Requestable { * @param $cookieName Name of cookie we shall read * @return $cookieValue Value of cookie or null if not found */ - public final function readCookie ($cookieName) { + public final function readCookie (string $cookieName) { // Default is no cookie with that name found $cookieValue = NULL; diff --git a/framework/main/classes/states/class_BaseState.php b/framework/main/classes/states/class_BaseState.php index e51fdc90..86e9a7ff 100644 --- a/framework/main/classes/states/class_BaseState.php +++ b/framework/main/classes/states/class_BaseState.php @@ -66,7 +66,7 @@ abstract class BaseState extends BaseFrameworkSystem implements Stateable { * @param $stateName Name of this state in a printable maner * @return void */ - protected final function setStateName ($stateName) { + protected final function setStateName (string $stateName) { $this->stateName = $stateName; } diff --git a/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php b/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php index 1a974893..e7680690 100644 --- a/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php +++ b/framework/main/classes/streams/crypto/mcrypt/class_McryptStream.php @@ -66,7 +66,7 @@ class McryptStream extends BaseCryptoStream implements EncryptableStream { * @param $key Optional key, if none provided, a random key will be generated * @return $encrypted Encrypted string */ - public function encryptStream ($str, $key = NULL) { + public function encryptStream (string $str, string $key = NULL) { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MCRYPT-STREAM: key[' . gettype($key) . ']=' . $key); @@ -133,7 +133,7 @@ class McryptStream extends BaseCryptoStream implements EncryptableStream { * @param $key Optional key, if none provided, a random key will be generated * @return $str The unencrypted string */ - public function decryptStream ($encrypted, $key = NULL) { + public function decryptStream (string $encrypted, string $key = NULL) { // Init crypto module $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); diff --git a/framework/main/classes/streams/crypto/null/class_NullCryptoStream.php b/framework/main/classes/streams/crypto/null/class_NullCryptoStream.php index 38337ba5..4e6908d9 100644 --- a/framework/main/classes/streams/crypto/null/class_NullCryptoStream.php +++ b/framework/main/classes/streams/crypto/null/class_NullCryptoStream.php @@ -58,29 +58,24 @@ class NullCryptoStream extends BaseCryptoStream implements EncryptableStream { * Encrypt the string with fixed salt * * @param $str The unencrypted string - * @param $key Optional key, if none provided, a random key will be generated + * @param $key Ignored * @return $encrypted Encrypted string */ - public function encryptStream ($str, $key = NULL) { - // Just handle it over - $encrypted = (string) $str; - + public function encryptStream (string $str, string $key = NULL) { // Return it - return $encrypted; + return $str; } /** * Decrypt the string with fixed salt * * @param $encrypted Encrypted string + * @param $key Ignored * @return $str The unencrypted string */ - public function decryptStream ($encrypted) { - // Just handle it over - $str = (string) $encrypted; - + public function decryptStream (string $encrypted, string $key = NULL) { // Return it - return $str; + return $encrypted; } /** diff --git a/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php b/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php index 72b9b706..6fad925e 100644 --- a/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php +++ b/framework/main/classes/streams/crypto/openssl/class_OpenSslStream.php @@ -65,7 +65,7 @@ class OpenSslStream extends BaseCryptoStream implements EncryptableStream { * @param $key Optional key, if none provided, a random key will be generated * @return $encrypted Encrypted string */ - public function encryptStream ($str, $key = NULL) { + public function encryptStream (string $str, string $key = NULL) { // @TODO unfinished return $str; @@ -135,7 +135,7 @@ class OpenSslStream extends BaseCryptoStream implements EncryptableStream { * @param $key Optional key, if none provided, a random key will be generated * @return $str The unencrypted string */ - public function decryptStream ($encrypted, $key = NULL) { + public function decryptStream (string $encrypted, string $key = NULL) { // @TODO unfinished return $encrypted; diff --git a/framework/main/classes/template/image/class_ImageTemplateEngine.php b/framework/main/classes/template/image/class_ImageTemplateEngine.php index 07ba19bf..d5efe92a 100644 --- a/framework/main/classes/template/image/class_ImageTemplateEngine.php +++ b/framework/main/classes/template/image/class_ImageTemplateEngine.php @@ -286,7 +286,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $imageType Code fragment or direct value holding the image type * @return void */ - private function setImageType ($imageType) { + private function setImageType (string $imageType) { // Set group to general $this->setVariableGroup('general'); @@ -366,7 +366,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @return void * @see ImageTemplateEngine::setImageResolution */ - private function setImageImageString ($groupable = 'single') { + private function setImageImageString (string $groupable = 'single') { // Call the image class $this->getImageInstance()->initImageString($groupable); @@ -380,7 +380,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $imageName Name of the image * @return void */ - private function setImagePropertyName ($imageName) { + private function setImagePropertyName (string $imageName) { // Call the image class $this->getImageInstance()->setImageName($imageName); } @@ -391,7 +391,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $width Width of the image or variable * @return void */ - private function setImagePropertyWidth ($width) { + private function setImagePropertyWidth (int $width) { // Call the image class $this->getImageInstance()->setWidth($width); } @@ -402,7 +402,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $height Height of the image or variable * @return void */ - private function setImagePropertyHeight ($height) { + private function setImagePropertyHeight (int $height) { // Call the image class $this->getImageInstance()->setHeight($height); } @@ -446,7 +446,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $stringName String name (identifier) * @return void */ - private function setImagePropertyStringName ($stringName) { + private function setImagePropertyStringName (string $stringName) { // Call the image class $this->getImageInstance()->setStringName($stringName); } @@ -457,7 +457,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $fontSize Size of the font * @return void */ - private function setImagePropertyFontSize ($fontSize) { + private function setImagePropertyFontSize (int $fontSize) { // Call the image class $this->getImageInstance()->setFontSize($fontSize); } @@ -468,7 +468,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $imageString Image string to set * @return void */ - private function setImagePropertyText ($imageString) { + private function setImagePropertyText (string $imageString) { // Call the image class $this->getImageInstance()->setString($imageString); } @@ -479,7 +479,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $x X coordinate * @return void */ - private function setImagePropertyX ($x) { + private function setImagePropertyX (int $x) { // Call the image class $this->getImageInstance()->setX($x); } @@ -490,7 +490,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * @param $y Y coordinate * @return void */ - private function setImagePropertyY ($y) { + private function setImagePropertyY (int $y) { // Call the image class $this->getImageInstance()->setY($y); } @@ -535,7 +535,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl * located in 'image' by default * @return void */ - public function loadImageTemplate ($template) { + public function loadImageTemplate (string $template) { // Set template type $this->setTemplateType(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('image_template_type')); diff --git a/framework/main/classes/template/mail/class_MailTemplateEngine.php b/framework/main/classes/template/mail/class_MailTemplateEngine.php index 6734da32..951093a0 100644 --- a/framework/main/classes/template/mail/class_MailTemplateEngine.php +++ b/framework/main/classes/template/mail/class_MailTemplateEngine.php @@ -267,7 +267,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla * @param $senderAddress Sender address to set in email * @return void */ - private function setEmailPropertySenderAddress ($senderAddress) { + private function setEmailPropertySenderAddress (string $senderAddress) { // Set the template variable $this->assignVariable('sender', $senderAddress); } @@ -278,7 +278,7 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla * @param $recipientAddress Recipient address to set in email * @return void */ - private function setEmailPropertyRecipientAddress ($recipientAddress) { + private function setEmailPropertyRecipientAddress (string $recipientAddress) { // Set the template variable $this->assignVariable('recipient', $recipientAddress); } diff --git a/framework/main/classes/template/menu/class_MenuTemplateEngine.php b/framework/main/classes/template/menu/class_MenuTemplateEngine.php index dcdf8cad..943b6a85 100644 --- a/framework/main/classes/template/menu/class_MenuTemplateEngine.php +++ b/framework/main/classes/template/menu/class_MenuTemplateEngine.php @@ -325,7 +325,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { // Did not match! throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), Parseable::EXCEPTION_XML_NODE_MISMATCH); - } // END - if + } // Construct method name $methodName = 'finish' . StringUtils::convertToClassName($nodeName); @@ -351,7 +351,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla if (empty($characters)) { // Then skip it silently return; - } // END - if + } // Assign the found characters to variable and use the last entry from // stack as the name @@ -365,7 +365,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla * @param $templateDependency A template to load to satisfy dependencies * @return void */ - private function handleTemplateDependency ($node, $templateDependency) { + private function handleTemplateDependency (string $node, string $templateDependency) { // Is the template dependency set? if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { // Get a temporay menu template instance @@ -379,7 +379,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla // Save the parsed raw content in our dependency array $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); - } // END - if + } } /** @@ -389,7 +389,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla * @return void * @todo Add cache creation here */ - private function initMenu ($templateDependency = '') { + private function initMenu (string $templateDependency = '') { // Get web template engine $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(GenericRegistry::getRegistry()->getInstance('application')))); @@ -816,11 +816,11 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla if ($variableName == 'anchor-href') { // Expand variable with URL then $variableValue = '{?base_url?}/' . $variableValue; - } // END - if + } // ... into the instance $this->getTemplateInstance()->assignVariable($variableName, $variableValue); - } // END - foreach + } // Compile template + variables $this->getTemplateInstance()->compileTemplate(); @@ -850,7 +850,7 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla // ... into the instance $this->getTemplateInstance()->assignVariable($variableName, $variableValue); - } // END - foreach + } // Assign block content $this->getTemplateInstance()->assignVariable('block_content', $blockContent); diff --git a/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php b/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php index e8676377..84680b8d 100644 --- a/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php +++ b/framework/main/classes/template/xml/class_BaseXmlTemplateEngine.php @@ -199,8 +199,8 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi * @param $element Element name to set as current main node * @return $currMainNode Current main node */ - private final function setCurrMainNode ($element) { - $this->curr['main_node'] = (string) $element; + private final function setCurrMainNode (string $element) { + $this->curr['main_node'] = $element; } /** @@ -275,7 +275,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi * @param $templateDependency A template to load to satisfy dependencies * @return void */ - protected function handleTemplateDependency ($node, $templateDependency) { + protected function handleTemplateDependency (string $node, string $templateDependency) { // Check that the XML node is not empty assert(!empty($node)); @@ -304,7 +304,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi * @return void * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found */ - public final function startElement ($resource, $element, array $attributes) { + public final function startElement ($resource, string $element, array $attributes) { // Initial method name which will never be called... $methodName = 'init' . StringUtils::convertToClassName($this->xmlTemplateType); @@ -339,7 +339,7 @@ abstract class BaseXmlTemplateEngine extends BaseTemplateEngine implements Compi * @return void * @throws XmlNodeMismatchException If current main node mismatches the closing one */ - public final function finishElement ($resource, $nodeName) { + public final function finishElement ($resource, string $nodeName) { // Make all lower-case $nodeName = strtolower($nodeName); diff --git a/framework/main/exceptions/database/class_DatabaseException.php b/framework/main/exceptions/database/class_DatabaseException.php index ec6067a5..8d7ca887 100644 --- a/framework/main/exceptions/database/class_DatabaseException.php +++ b/framework/main/exceptions/database/class_DatabaseException.php @@ -35,7 +35,7 @@ class DatabaseException extends FrameworkException { * @param $code Code number for the exception * @return void */ - public function __construct ($message, int $code) { + public function __construct (string $message, int $code) { // Just call the parent constructor parent::__construct($message, $code); } diff --git a/framework/main/interfaces/crypto/class_Cryptable.php b/framework/main/interfaces/crypto/class_Cryptable.php index 6dc778cc..427270d9 100644 --- a/framework/main/interfaces/crypto/class_Cryptable.php +++ b/framework/main/interfaces/crypto/class_Cryptable.php @@ -39,7 +39,7 @@ interface Cryptable extends FrameworkInterface { * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) * @return $hashed The hashed and salted string */ - function hashString ($str, $oldHash = '', $withFixed = true); + function hashString (string $str, string $oldHash = '', bool $withFixed = true); /** * Encrypt the string with fixed salt @@ -48,7 +48,7 @@ interface Cryptable extends FrameworkInterface { * @param $key Optional key, if none provided, a random key will be generated * @return $encrypted Encrypted string */ - function encryptString ($str, $key = NULL); + function encryptString (string $str, string $key = NULL); /** * Decrypt the string with fixed salt @@ -56,6 +56,6 @@ interface Cryptable extends FrameworkInterface { * @param $encrypted Encrypted string * @return $str The unencrypted string */ - function decryptString ($encrypted); + function decryptString (string $encrypted); } diff --git a/framework/main/interfaces/handler/task/class_HandleableTask.php b/framework/main/interfaces/handler/task/class_HandleableTask.php index 0c295274..3e9934e6 100644 --- a/framework/main/interfaces/handler/task/class_HandleableTask.php +++ b/framework/main/interfaces/handler/task/class_HandleableTask.php @@ -43,10 +43,10 @@ interface HandleableTask extends HandleableDataSet { * Registers a task with a task handler. * * @param $taskName A task name to register the task on - * @param $taskInstance The instance we should register as a task + * @param $taskInstance An instance of a Taskable class * @return void */ - function registerTask ($taskName, Visitable $taskInstance); + function registerTask (string $taskName, Taskable $taskInstance); /** * Checks whether tasks are left including idle task diff --git a/framework/main/interfaces/registration/class_UserRegister.php b/framework/main/interfaces/registration/class_UserRegister.php index af1cfc7f..ed4bb82f 100644 --- a/framework/main/interfaces/registration/class_UserRegister.php +++ b/framework/main/interfaces/registration/class_UserRegister.php @@ -35,7 +35,7 @@ interface UserRegister extends AddableCriteria { * @param $requestKey Key in request class * @return void */ - function encryptPassword ($requestKey); + function encryptPassword (string $requestKey); /** * Perform things like informing assigned affilates about new registration diff --git a/framework/main/interfaces/request/class_Requestable.php b/framework/main/interfaces/request/class_Requestable.php index 60def40c..55f4cac4 100644 --- a/framework/main/interfaces/request/class_Requestable.php +++ b/framework/main/interfaces/request/class_Requestable.php @@ -34,7 +34,7 @@ interface Requestable extends FrameworkInterface { * @param $element Name of the request element we want to check * @return $isSet Whether the request element is set */ - function isRequestElementSet ($element); + function isRequestElementSet (string $element); /** * Getter for request element or 'null' if element was not found @@ -43,7 +43,7 @@ interface Requestable extends FrameworkInterface { * @return $value Value of the found request element or 'null' if the * element was not found */ - function getRequestElement ($element); + function getRequestElement (string $element); /** * Setter for request elements @@ -52,7 +52,7 @@ interface Requestable extends FrameworkInterface { * @param $value Value to set * @return void */ - function setRequestElement ($element, $value); + function setRequestElement (string $element, $value); /** * Setter for request data array diff --git a/framework/main/interfaces/streams/crypto/class_EncryptableStream.php b/framework/main/interfaces/streams/crypto/class_EncryptableStream.php index c73c4613..68b85c2a 100644 --- a/framework/main/interfaces/streams/crypto/class_EncryptableStream.php +++ b/framework/main/interfaces/streams/crypto/class_EncryptableStream.php @@ -40,14 +40,15 @@ interface EncryptableStream extends Stream { * @param $key Optional key, if none provided, a random key will be generated * @return $encrypted Encrypted string */ - function encryptStream ($str, $key = NULL); + function encryptStream (string $str, string $key = NULL); /** * Decrypt the string with fixed salt * * @param $encrypted Encrypted string + * @param $key Optional key, if none provided, a random key will be generated * @return $str The unencrypted string */ - function decryptStream ($encrypted); + function decryptStream (string $encrypted, string $key = NULL); } diff --git a/tests/framework/bootstrap/class_FrameworkBootstrapTest.php b/tests/framework/bootstrap/class_FrameworkBootstrapTest.php index 8dd7cfeb..7b900fd2 100644 --- a/tests/framework/bootstrap/class_FrameworkBootstrapTest.php +++ b/tests/framework/bootstrap/class_FrameworkBootstrapTest.php @@ -77,86 +77,6 @@ class FrameworkBootstrapTest extends TestCase { //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__); } - /** - * Tests setting a NULL default timezone - */ - public function testSettingNullDefaultTimezone () { - // Will throw this exception - $this->expectException(NullPointerException::class); - - // Test it - FrameworkBootstrap::setDefaultTimezone(NULL); - } - - /** - * Tests setting a boolean default timezone - */ - public function testSettingBooleanDefaultTimezone () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - FrameworkBootstrap::setDefaultTimezone(FALSE); - } - - /** - * Tests setting a decimal default timezone - */ - public function testSettingDecimalDefaultTimezone () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - FrameworkBootstrap::setDefaultTimezone(12345); - } - - /** - * Tests setting a float default timezone - */ - public function testSettingFloatDefaultTimezone () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - FrameworkBootstrap::setDefaultTimezone(123.45); - } - - /** - * Tests setting an array default timezone - */ - public function testSettingArrayDefaultTimezone () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - FrameworkBootstrap::setDefaultTimezone(array()); - } - - /** - * Tests setting an object default timezone - */ - public function testSettingObjectDefaultTimezone () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - FrameworkBootstrap::setDefaultTimezone($this); - } - - /** - * Tests setting a resource default timezone - */ - public function testSettingResourceDefaultTimezone () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Init some resource - $resource = fopen(__FILE__, 'r'); - - // Test it - FrameworkBootstrap::setDefaultTimezone($resource); - } - /** * Tests setting an empty default timezone */ diff --git a/tests/framework/config/FrameworkConfigurationTest.php b/tests/framework/config/FrameworkConfigurationTest.php index 6506e2d6..12d8e551 100644 --- a/tests/framework/config/FrameworkConfigurationTest.php +++ b/tests/framework/config/FrameworkConfigurationTest.php @@ -164,28 +164,6 @@ class FrameworkConfigurationTest extends TestCase { $this->assertEquals($config1, $config2); } - /** - * Tests if a proper exception is thrown when check for a NULL key - */ - public function testCheckingNullConfigKey () { - // Will throw this exception - $this->expectException(NullPointerException::class); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet(NULL); - } - - /** - * Tests if a proper exception is thrown when checking a boolean key - */ - public function testCheckingBooleanConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet(FALSE); - } - /** * Tests if a proper exception is thrown when checking an empty key */ @@ -197,64 +175,6 @@ class FrameworkConfigurationTest extends TestCase { $dummy = self::$configInstance->isConfigurationEntrySet(''); } - /** - * Tests if a proper exception is thrown when checking an array key - */ - public function testCheckingArrayConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet(array()); - } - - /** - * Tests if a proper exception is thrown when checking a decimal key - */ - public function testCheckingDecimalConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet(12345); - } - - /** - * Tests if a proper exception is thrown when checking a float key - */ - public function testCheckingFloatConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet(123.45); - } - - /** - * Tests if a proper exception is thrown when checking an object key - */ - public function testCheckingObjectConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet($this); - } - - /** - * Tests if a proper exception is thrown when checking a resource key - */ - public function testCheckingResourceConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Init some resource - $resource = fopen(__FILE__, 'r'); - - // Test it - $dummy = self::$configInstance->isConfigurationEntrySet($resource); - } - /** * Tests if checking an existing (well-known) key can be found and returns * TRUE. @@ -272,28 +192,6 @@ class FrameworkConfigurationTest extends TestCase { $this->assertFalse(self::$configInstance->isConfigurationEntrySet('__non_existing_key__')); } - /** - * Tests if a proper exception is thrown when getting a NULL key - */ - public function testGettingNullConfigKey () { - // Will throw this exception - $this->expectException(NullPointerException::class); - - // Test it - $dummy = self::$configInstance->getConfigEntry(NULL); - } - - /** - * Tests if a proper exception is thrown when getting a boolean key - */ - public function testGettingBooleanConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->getConfigEntry(FALSE); - } - /** * Tests if a proper exception is thrown when getting an empty key */ @@ -305,64 +203,6 @@ class FrameworkConfigurationTest extends TestCase { $dummy = self::$configInstance->getConfigEntry(''); } - /** - * Tests if a proper exception is thrown when getting a decimal key - */ - public function testGettingDecimalConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->getConfigEntry(12345); - } - - /** - * Tests if a proper exception is thrown when getting a float key - */ - public function testGettingFloatConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->getConfigEntry(123.45); - } - - /** - * Tests if a proper exception is thrown when getting an array key - */ - public function testGettingArrayConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->getConfigEntry(array()); - } - - /** - * Tests if a proper exception is thrown when getting an object key - */ - public function testGettingObjectConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - $dummy = self::$configInstance->getConfigEntry($this); - } - - /** - * Tests if a proper exception is thrown when getting a resource key - */ - public function testGettingResourceConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Init some resource - $resource = fopen(__FILE__, 'r'); - - // Test it - $dummy = self::$configInstance->getConfigEntry($resource); - } - /** * Tests if getting a non-existing key will cause a proper exception been * thrown. @@ -386,28 +226,6 @@ class FrameworkConfigurationTest extends TestCase { $this->assertDirectoryIsReadable($value); } - /** - * Tests setting a NULL key (value doesn't matter) - */ - public function testSettingNullConfigKey () { - // Will throw this exception - $this->expectException(NullPointerException::class); - - // Test it - self::$configInstance->setConfigEntry(NULL, 'foo'); - } - - /** - * Tests setting a boolean key (value doesn't matter) - */ - public function testSettingBooleanConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->setConfigEntry(FALSE, 'foo'); - } - /** * Tests setting an empty key (value doesn't matter) */ @@ -419,64 +237,6 @@ class FrameworkConfigurationTest extends TestCase { self::$configInstance->setConfigEntry('', 'foo'); } - /** - * Tests setting a decimal key (value doesn't matter) - */ - public function testSettingDecimalConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->setConfigEntry(12345, 'foo'); - } - - /** - * Tests setting a float key (value doesn't matter) - */ - public function testSettingFloatConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->setConfigEntry(123.45, 'foo'); - } - - /** - * Tests setting an array key (value doesn't matter) - */ - public function testSettingArrayConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->setConfigEntry(array(), 'foo'); - } - - /** - * Tests setting an object key (value doesn't matter) - */ - public function testSettingObjectConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->setConfigEntry($this, 'foo'); - } - - /** - * Tests setting a resource key (value doesn't matter) - */ - public function testSettingResourceConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Init some resource - $resource = fopen(__FILE__, 'r'); - - // Test it - self::$configInstance->setConfigEntry($resource, 'foo'); - } - /** * Tests setting a valid key but array for value */ @@ -513,86 +273,6 @@ class FrameworkConfigurationTest extends TestCase { self::$configInstance->setConfigEntry('foo', $resource); } - /** - * Tests unsetting NULL key - */ - public function testUnsettingNullConfigKey () { - // Will throw this exception - $this->expectException(NullPointerException::class); - - // Test it - self::$configInstance->unsetConfigEntry(NULL); - } - - /** - * Tests unsetting boolean key - */ - public function testUnsettingBooleanConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->unsetConfigEntry(FALSE); - } - - /** - * Tests unsetting decimal key - */ - public function testUnsettingDecimalConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->unsetConfigEntry(12345); - } - - /** - * Tests unsetting float key - */ - public function testUnsettingFloatConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->unsetConfigEntry(123.45); - } - - /** - * Tests unsetting array key - */ - public function testUnsettingArrayConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->unsetConfigEntry(array()); - } - - /** - * Tests unsetting object key - */ - public function testUnsettingObjectConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Test it - self::$configInstance->unsetConfigEntry($this); - } - - /** - * Tests unsetting resource key - */ - public function testUnsettingResourceConfigKey () { - // Will throw this exception - $this->expectException(InvalidArgumentException::class); - - // Init some resource - $resource = fopen(__FILE__, 'r'); - - // Test it - self::$configInstance->unsetConfigEntry($resource); - } - /** * Tests unsetting an empty key */ -- 2.39.5