]> git.mxchange.org Git - core.git/blobdiff - framework/main/exceptions/class_FrameworkException.php
Continued:
[core.git] / framework / main / exceptions / class_FrameworkException.php
index e1dedd97025987948db99be489afe313b926a470..c08687a23ec5665a14bf48e82c54a8a3b8f3ca8b 100644 (file)
@@ -12,7 +12,7 @@ use \ReflectionException;
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -33,7 +33,7 @@ abstract class FrameworkException extends ReflectionException {
        /**
         * Array for the backtrace
         */
-       private $backTrace = array();
+       private $backTrace = [];
 
        /**
         * Extra data
@@ -47,17 +47,13 @@ abstract class FrameworkException extends ReflectionException {
         * @param       $code           An optional code for better debugging
         * @return      void
         */
-       public function __construct ($message, $code = 0) {
+       public function __construct (string $message, int $code = 0) {
                // Make sure everything is assigned properly
                parent::__construct($message, $code);
 
                // Extract backtrace
                $this->saveBackTrace();
 
-               // Cast all data
-               $message = (string) $message;
-               $code    = (int)    $code;
-
                // In emergency exit?
                if (defined('EMERGENCY_EXIT_CALLED')) {
                        // Output message
@@ -70,7 +66,7 @@ abstract class FrameworkException extends ReflectionException {
 
                        // End here
                        exit();
-               } // END - if
+               }
 
                // Should we log exceptions? (bad implementation)
                if (defined('LOG_EXCEPTIONS')) {
@@ -81,7 +77,7 @@ abstract class FrameworkException extends ReflectionException {
                                $message,
                                $this->getHexCode()
                        ));
-               } // END - if
+               }
        }
 
        /**
@@ -132,12 +128,12 @@ abstract class FrameworkException extends ReflectionException {
                                        // Add only non-array elements
                                        if (!is_array($debug)) {
                                                $info .= $debug . ', ';
-                                       } // END - if
-                               } // END - foreach
+                                       }
+                               }
 
                                // Remove last chars (commata, space)
                                $info = substr($info, 0, -2);
-                       } // END - if
+                       }
 
                        // Prepare argument infos
                        $info = '<em id="debug_args_' . $dbgIndex . '">' . $info . '</em>';
@@ -146,17 +142,17 @@ abstract class FrameworkException extends ReflectionException {
                        $file = 'Unknown file';
                        if (isset($dbgInfo['file'])) {
                                $file = basename($dbgInfo['file']);
-                       } // END - if
+                       }
 
                        // Line detection
                        $line = 'Unknown line';
                        if (isset($dbgInfo['line'])) {
                                $line = 'line ' . $dbgInfo['line'];
-                       } // END - if
+                       }
 
                        // The message
                        $dbgMsg .= "\t at <em id=\"debug_id_".$dbgIndex."\">".$dbgIndex."</em> <em id=\"debug_file_".$dbgIndex."\">".$file."</em> (<em id=\"debug_line_".$dbgIndex."\">".$line."</em>) -&gt; ".$dbgInfo['function'].'('.$info.")<br />\n";
-               } // END - if
+               }
 
                // Add end-message
                $dbgMsg .= "Debug backtrace end<br />\n";
@@ -180,9 +176,12 @@ abstract class FrameworkException extends ReflectionException {
         * @param       $code           Integer code to encode in hex
         * @return      $hexCode        The exception code in hex-decimal format
         */
-       public final function getHexCode ($code = NULL) {
-               // Get the decimal code
-               if (is_null($code)) $code = $this->getCode();
+       public final function getHexCode (int $code = NULL) {
+               // Is NULL?
+               if (is_null($code)) {
+                       // Get default error code
+                       $code = $this->getCode();
+               }
 
                // Format it to hex-decimal, 0x as prefix and 3 chars
                $hexCode = sprintf("0x%03s", dechex($code));
@@ -197,7 +196,7 @@ abstract class FrameworkException extends ReflectionException {
         * @param       $extraData      Extra data to store
         * @return      void
         */
-       protected final function setExtraData ($extraData) {
+       protected final function setExtraData (string $extraData) {
                $this->extraData = $extraData;
        }