]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/class_BaseFrameworkSystem.php
WIP:
[core.git] / framework / main / classes / class_BaseFrameworkSystem.php
index 91af004ff3d4f14ee47cd58aad482b75f0de8e6b..0c7e737e4a6c49fc806d07a30be8c4fafb5332d1 100644 (file)
@@ -224,7 +224,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                if (self::$startupTime == 0) {
                        // Then set it
                        self::$startupTime = microtime(true);
-               } // END - if
+               }
        }
 
        /**
@@ -259,7 +259,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @args        $args                   Arguments passed to the method
         * @return      void
         */
-       public final function __call ($methodName, $args) {
+       public final function __call (string $methodName, array $args = NULL) {
                // Set self-instance
                self::$instance = $this;
 
@@ -278,11 +278,9 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @return      void
         * @throws      InvalidArgumentException If self::$instance is not a framework's own object
         */
-       public static final function __callStatic ($methodName, $args) {
-               // Trace message
-               //* PRINT-DEBUG: */ printf('[%s:%d]: methodName=%s,args[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $methodName, gettype($args));
-
+       public static final function __callStatic (string $methodName, array $args = NULL) {
                // Init argument string and class name
+               //* PRINT-DEBUG: */ printf('[%s:%d]: methodName=%s,args[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $methodName, gettype($args));
                $argsString = '';
                $className = 'unknown';
 
@@ -336,19 +334,16 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
 
                                // Comma for next one
                                $argsString .= ', ';
-                       } // END - foreach
+                       }
 
                        // Last comma found?
                        if (substr($argsString, -2, 1) == ',') {
                                // Remove last comma
                                $argsString = substr($argsString, 0, -2);
-                       } // END - if
+                       }
 
                        // Close braces
                        $argsString .= ')';
-               } else {
-                       // Invalid arguments!
-                       $argsString = sprintf('!INVALID:%s!', gettype($args));
                }
 
                // Output stub message
@@ -379,7 +374,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @param       $value  Value to store
         * @return      void
         */
-       public final function __set ($name, $value) {
+       public final function __set (string $name, $value) {
                $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s',
                        $name,
                        gettype($value),
@@ -393,7 +388,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @param       $name   Name of the field/attribute
         * @return      void
         */
-       public final function __get ($name) {
+       public final function __get (string $name) {
                $this->debugBackTrace(sprintf('Tried to get a missing field. name=%s',
                        $name
                ));
@@ -405,7 +400,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @param       $name   Name of the field/attribute
         * @return      void
         */
-       public final function __unset ($name) {
+       public final function __unset (string $name) {
                $this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s',
                        $name
                ));
@@ -447,9 +442,9 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         * @param       $realClass      Class name (string)
         * @return      void
         */
-       public final function setRealClass ($realClass) {
+       public final function setRealClass (string $realClass) {
                // Set real class
-               $this->realClass = (string) $realClass;
+               $this->realClass = $realClass;
        }
 
        /**
@@ -766,7 +761,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                // Is there a trailing slash?
                if (substr($str, -1, 1) != '/') {
                        $str .= '/';
-               } // END - if
+               }
 
                // Return string with trailing slash
                return $str;
@@ -791,7 +786,7 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                        $content = sprintf('<div class="debug_message">
        Message: %s
 </div>' . PHP_EOL, $message);
-               } // END - if
+               }
 
                // Generate the output
                $content .= sprintf('<pre>%s</pre>',
@@ -852,7 +847,7 @@ Loaded includes:
                if (!empty($message)) {
                        // Then add it as well
                        $stubMessage .= ' Message: ' . $message;
-               } // END - if
+               }
 
                // Debug instance is there?
                if (!is_null($this->getDebugInstance())) {
@@ -877,7 +872,7 @@ Loaded includes:
                if (!empty($message)) {
                        // Output message
                        printf('Message: %s<br />' . PHP_EOL, $message);
-               } // END - if
+               }
 
                print('<pre>');
                debug_print_backtrace();
@@ -886,7 +881,7 @@ Loaded includes:
                // Exit program?
                if ($doExit === true) {
                        exit();
-               } // END - if
+               }
        }
 
        /**
@@ -989,13 +984,13 @@ Loaded includes:
                        if ($doPrint === false) {
                                // Die here if not printed
                                exit();
-                       } // END - if
+                       }
                } else {
                        // Are debug times enabled?
                        if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') {
                                // Prepent it
                                $message = $this->getPrintableExecutionTime() . $message;
-                       } // END - if
+                       }
 
                        // Put directly out
                        if ($doPrint === true) {
@@ -1030,7 +1025,7 @@ Loaded includes:
                                $errorArray['message'],
                                $errorArray['type']
                        );
-               } // END - if
+               }
 
                // Add line number to the code
                foreach (explode(chr(10), $phpCode) as $lineNo => $code) {
@@ -1039,79 +1034,12 @@ Loaded includes:
                                ($lineNo + 1),
                                htmlentities($code, ENT_QUOTES)
                        );
-               } // END - foreach
+               }
 
                // Return the code
                return $markedCode;
        }
 
-       /**
-        * Filter a given GMT timestamp (non Uni* stamp!) to make it look more
-        * beatiful for web-based front-ends. If null is given a message id
-        * null_timestamp will be resolved and returned.
-        *
-        * @param       $timestamp      Timestamp to prepare (filter) for display
-        * @return      $readable       A readable timestamp
-        */
-       public function doFilterFormatTimestamp ($timestamp) {
-               // Default value to return
-               $readable = '???';
-
-               // Is the timestamp null?
-               if (is_null($timestamp)) {
-                       // Get a message string
-                       $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
-               } else {
-                       switch ($this->getLanguageInstance()->getLanguageCode()) {
-                               case 'de': // German format is a bit different to default
-                                       // Split the GMT stamp up
-                                       $dateTime  = explode(' ', $timestamp  );
-                                       $dateArray = explode('-', $dateTime[0]);
-                                       $timeArray = explode(':', $dateTime[1]);
-
-                                       // Construct the timestamp
-                                       $readable = sprintf(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('german_date_time'),
-                                               $dateArray[0],
-                                               $dateArray[1],
-                                               $dateArray[2],
-                                               $timeArray[0],
-                                               $timeArray[1],
-                                               $timeArray[2]
-                                       );
-                                       break;
-
-                               default: // Default is pass-through
-                                       $readable = $timestamp;
-                                       break;
-                       } // END - switch
-               }
-
-               // Return the stamp
-               return $readable;
-       }
-
-       /**
-        * Filter a given number into a localized number
-        *
-        * @param       $value          The raw value from e.g. database
-        * @return      $localized      Localized value
-        */
-       public function doFilterFormatNumber ($value) {
-               // Generate it from config and localize dependencies
-               switch ($this->getLanguageInstance()->getLanguageCode()) {
-                       case 'de': // German format is a bit different to default
-                               $localized = number_format($value, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('decimals'), ',', '.');
-                               break;
-
-                       default: // US, etc.
-                               $localized = number_format($value, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('decimals'), '.', ',');
-                               break;
-               } // END - switch
-
-               // Return it
-               return $localized;
-       }
-
        /**
         * "Getter" for databse entry
         *
@@ -1124,7 +1052,7 @@ Loaded includes:
                if (!$this->getResultInstance() instanceof SearchableResult) {
                        // Throw an exception here
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
+               }
 
                // Rewind it
                $this->getResultInstance()->rewind();
@@ -1133,7 +1061,7 @@ Loaded includes:
                if ($this->getResultInstance()->valid() === false) {
                        // @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available
                        throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
-               } // END - if
+               }
 
                // Get next entry
                $this->getResultInstance()->next();
@@ -1163,7 +1091,7 @@ Loaded includes:
                if (is_null($resultInstance)) {
                        // Then the user instance is no longer valid (expired cookies?)
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
+               }
 
                // Get current array
                $fieldArray = $resultInstance->current();
@@ -1203,7 +1131,7 @@ Loaded includes:
                if (is_null($resultInstance)) {
                        // Then the user instance is no longer valid (expired cookies?)
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
-               } // END - if
+               }
 
                // Get current array
                $fieldArray = $resultInstance->current();
@@ -1238,7 +1166,7 @@ Loaded includes:
 
                        // Yes, then send the whole result to the database layer
                        $wrapperInstance->doUpdateByResult($this->getResultInstance());
-               } // END - if
+               }
        }
 
        /**
@@ -1407,7 +1335,7 @@ Loaded includes:
                if (is_null(self::$hashLength)) {
                        // No, then hash a string and save its length.
                        self::$hashLength = strlen(self::hash('abc123'));
-               } // END - if
+               }
 
                // Return it
                return self::$hashLength;
@@ -1429,13 +1357,13 @@ Loaded includes:
                if ($castValue === true) {
                        // Cast to biggest numeric type
                        $ret = (double) $ret;
-               } // END - if
+               }
 
                // Assert only if requested
                if ($assertMismatch === true) {
                        // Has the whole value changed?
                        assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
-               } // END - if
+               }
 
                // Return result
                return $ret;
@@ -1456,7 +1384,7 @@ Loaded includes:
                if ($assertMismatch === true) {
                        // Has the whole value changed?
                        assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
-               } // END - if
+               }
 
                // Return result
                return $ret;
@@ -1532,7 +1460,7 @@ Loaded includes:
                        // No, then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
                        exit;
-               } // END - if
+               }
 
                // Debug message
                //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], true));
@@ -1657,7 +1585,7 @@ Loaded includes:
                        // Already initialized
                        trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.');
                        exit;
-               } // END - if
+               }
 
                // Initialize it
                $this->genericArray[$keyGroup][$subGroup] = array();
@@ -1681,7 +1609,7 @@ Loaded includes:
                        // Already initialized
                        trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
                        exit;
-               } // END - if
+               }
 
                // Initialize it
                $this->genericArray[$keyGroup][$subGroup][$key] = array();
@@ -1706,7 +1634,7 @@ Loaded includes:
                        // Already initialized
                        trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.');
                        exit;
-               } // END - if
+               }
 
                // Initialize it
                $this->genericArray[$keyGroup][$subGroup][$key][$element] = array();
@@ -1729,7 +1657,7 @@ Loaded includes:
                if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
                        // Initialize array
                        $this->initGenericArrayKey($keyGroup, $subGroup, $key);
-               } // END - if
+               }
 
                // Then push it
                $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
@@ -1758,7 +1686,7 @@ Loaded includes:
                if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
                        // Initialize array
                        $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element);
-               } // END - if
+               }
 
                // Then push it
                $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value);
@@ -1786,7 +1714,7 @@ Loaded includes:
                        // Not found
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
                        exit;
-               } // END - if
+               }
 
                // Then "pop" it
                $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]);
@@ -1814,7 +1742,7 @@ Loaded includes:
                        // Not found
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
                        exit;
-               } // END - if
+               }
 
                // Then "shift" it
                $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]);
@@ -1840,7 +1768,7 @@ Loaded includes:
                        // Abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
                        exit;
-               } // END - if
+               }
 
                // Then count it
                $count = count($this->genericArray[$keyGroup]);
@@ -1868,7 +1796,7 @@ Loaded includes:
                        // Abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
                        exit;
-               } // END - if
+               }
 
                // Then count it
                $count = count($this->genericArray[$keyGroup][$subGroup]);
@@ -1928,7 +1856,7 @@ Loaded includes:
                        // Then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
                        exit;
-               } // END - if
+               }
 
                // Return it
                return $this->genericArray[$keyGroup];
@@ -1968,7 +1896,7 @@ Loaded includes:
                        // Then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
                        exit;
-               } // END - if
+               }
 
                // Return it
                return $this->genericArray[$keyGroup][$subGroup][$key];
@@ -2010,7 +1938,7 @@ Loaded includes:
                        // Then abort here
                        trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
                        exit;
-               } // END - if
+               }
 
                // Return it
                return $this->genericArray[$keyGroup][$subGroup][$key][$element];
@@ -2103,7 +2031,7 @@ Loaded includes:
                if (!is_writable($basePath)) {
                        // Path is write-protected
                        throw new PathWriteProtectedException($infoInstance, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN);
-               } // END - if
+               }
 
                // Add it
                $tempInstance = new SplFileInfo($basePath . DIRECTORY_SEPARATOR . $infoInstance->getBasename());
@@ -2112,7 +2040,7 @@ Loaded includes:
                if (!FrameworkBootstrap::isReachableFilePath($tempInstance)) {
                        // Not reachable
                        throw new FileIoException($tempInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
-               } // END - if
+               }
 
                // Return it
                return $tempInstance;
@@ -2134,7 +2062,7 @@ Loaded includes:
                if ($stateInstance instanceof Stateable) {
                        // Then use that state name
                        $stateName = $stateInstance->getStateName();
-               } // END - if
+               }
 
                // Return result
                return $stateName;