X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Flanguage%2Fclass_LanguageSystem.php;h=ebcfc38e6e1a0cae8bd7fc90c10f4800294ef053;hb=f50b908a487166a866eb49856bccb8c45d76a4bc;hp=f301eac05b77eb89fa02a023c63a9a25612bc48b;hpb=93901b5d15fd1278425ed5780613ffaf4123e197;p=core.git diff --git a/framework/main/classes/language/class_LanguageSystem.php b/framework/main/classes/language/class_LanguageSystem.php index f301eac0..ebcfc38e 100644 --- a/framework/main/classes/language/class_LanguageSystem.php +++ b/framework/main/classes/language/class_LanguageSystem.php @@ -19,7 +19,7 @@ use \InvalidArgumentException; * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -73,13 +73,13 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * @param $languageBasePath The local base path for all language strings or emty for auto-detection * @return $langInstance An instance of LanguageSystem * @throws InvalidArgumentException If languageBasePath remains empty (@TODO Get rid of that old-lost code) - * @throws InvalidLanguagePathStringException If $languageBasePath is no string - * @throws LanguagePathIsNoDirectoryException If $languageBasePath is no + * @throws InvalidArgumentException If $languageBasePath is no string + * @throws InvalidArgumentException If $languageBasePath is no * directory or not found - * @throws LanguagePathReadProtectedException If $languageBasePath is + * @throws InvalidArgumentException If $languageBasePath is * read-protected */ - public static final function createLanguageSystem ($languageBasePath = '') { + public static final function createLanguageSystem (string $languageBasePath = '') { // Get a new instance $langInstance = new LanguageSystem(); @@ -91,7 +91,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, // 2) Try to build it $languageBasePath = sprintf('%s%s/language/', - $langInstance->getConfigInstance()->getConfigEntry('application_base_path'), + FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path'), $applicationInstance->getAppShortName() ); } // END - if @@ -102,13 +102,13 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, throw new InvalidArgumentException('languageBasePath is still empty'); } elseif (!is_string($languageBasePath)) { // Is not a string - throw new InvalidLanguagePathStringException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_STRING); + throw new InvalidArgumentException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_STRING); } elseif (!is_dir($languageBasePath)) { // Is not a path - throw new LanguagePathIsNoDirectoryException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_PATH_NAME); + throw new InvalidArgumentException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_PATH_NAME); } elseif (!is_readable($languageBasePath)) { // Is not readable - throw new LanguagePathReadProtectedException(array($langInstance, $languageBasePath), self::EXCEPTION_READ_PROTECED_PATH); + throw new InvalidArgumentException(array($langInstance, $languageBasePath), self::EXCEPTION_READ_PROTECED_PATH); } // Set the base path @@ -142,7 +142,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * @param $languageBasePath The relative base path for all language files * @return void */ - protected final function setLanguageBasePath ($languageBasePath) { + protected final function setLanguageBasePath (string $languageBasePath) { // And set it $this->languageBasePath = (string) $languageBasePath; } @@ -153,10 +153,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * @param $langCode The language code for the current application * @return void */ - protected final function setLanguageCode ($langCode) { - // Cast it - $langCode = (string) $langCode; - + protected final function setLanguageCode (string $langCode) { // And set it (only 2 chars) $this->langCode = substr($langCode, 0, 2); } @@ -211,7 +208,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, * @param $messageId The message id we shall find in the cache variable * @return $messageText The plain message text */ - public function getMessage ($messageId) { + public function getMessage (string $messageId) { // Default is missing message text $messageText = sprintf('!%s!', $messageId