*
* @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 - 2021 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* Array for the backtrace
*/
- private $backTrace = array();
+ private $backTrace = [];
/**
* Extra data
* @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
// End here
exit();
- } // END - if
+ }
// Should we log exceptions? (bad implementation)
if (defined('LOG_EXCEPTIONS')) {
$message,
$this->getHexCode()
));
- } // END - if
+ }
}
/**
// 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>';
$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>) -> ".$dbgInfo['function'].'('.$info.")<br />\n";
- } // END - if
+ }
// Add end-message
$dbgMsg .= "Debug backtrace end<br />\n";
* @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));
* @param $extraData Extra data to store
* @return void
*/
- protected final function setExtraData ($extraData) {
+ protected final function setExtraData (string $extraData) {
$this->extraData = $extraData;
}