Skip to content

Commit

Permalink
E_STRICT and "Implicitly marking parameter as nullable is deprecated"…
Browse files Browse the repository at this point in the history
… fixes for PHP8.4

Might be more of these lurking, but this version should at least get PW to load without a huge mess of Tracy errors.
  • Loading branch information
adrianbj committed Nov 26, 2024
1 parent bf7603c commit e9a3c83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
7 changes: 5 additions & 2 deletions TracyDebugger.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
'version' => '4.26.42',
'version' => '4.26.43',
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand Down Expand Up @@ -1468,6 +1468,10 @@ function bsZIndex() {

// TRACY SETTING
//convert checked log severity strings to constants and array_reduce to bitwise OR (|) line
// remove E_STRICT in case it's still set from old version of Tracy - it's deprecated in PHP 8.4
if(($key = array_search('E_STRICT', $this->data['logSeverity'])) !== false) {
unset($this->data['logSeverity'][$key]);
}
$severityOptions = array_map('constant', $this->data['logSeverity']);
Debugger::$logSeverity = array_reduce($severityOptions, function($a, $b) { return $a | $b; }, 0);

Expand Down Expand Up @@ -3565,7 +3569,6 @@ public function getModuleConfigInputfields(array $data) {
$f->addOption('E_USER_ERROR', 'E_USER_ERROR');
$f->addOption('E_USER_WARNING', 'E_USER_WARNING');
$f->addOption('E_USER_NOTICE', 'E_USER_NOTICE');
$f->addOption('E_STRICT', 'E_STRICT');
$f->addOption('E_RECOVERABLE_ERROR', 'E_RECOVERABLE_ERROR');
$f->addOption('E_DEPRECATED', 'E_DEPRECATED');
$f->addOption('E_USER_DEPRECATED', 'E_USER_DEPRECATED');
Expand Down
24 changes: 12 additions & 12 deletions includes/TD.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected static function tracyUnavailable() {
* Tracy\Debugger::debugAll() shortcut.
* @tracySkipLocation
*/
public static function debugAll($var, $title = NULL, array $options = NULL) {
public static function debugAll(string|array $var, string|array|null $title = NULL, ?array $options = NULL) {
if(self::tracyUnavailable()) return false;
static::barDump($var, $title, $options);
static::dump($var, $title, $options);
Expand All @@ -51,7 +51,7 @@ public static function debugAll($var, $title = NULL, array $options = NULL) {
* Tracy\Debugger::barEcho() shortcut.
* @tracySkipLocation
*/
public static function barEcho($str, $title = null) {
public static function barEcho(string $str, string|array|null $title = null) {
if(self::tracyUnavailable() && !\TracyDebugger::getDataValue('recordGuestDumps')) return false;
static::dumpToBar($str, $title, null, true);
}
Expand All @@ -60,7 +60,7 @@ public static function barEcho($str, $title = null) {
* Tracy\Debugger::barDump() shortcut.
* @tracySkipLocation
*/
public static function barDump($var, $title = NULL, array $options = NULL) {
public static function barDump(string|array $var, string|array|null $title = NULL, ?array $options = NULL) {
if(self::tracyUnavailable() && !\TracyDebugger::getDataValue('recordGuestDumps')) return false;
if(is_array($title)) {
$options = $title;
Expand All @@ -85,7 +85,7 @@ public static function barDump($var, $title = NULL, array $options = NULL) {
* Tracy\Debugger::barDumpBig() shortcut dumping with maxDepth = 6, maxLength = 9999, and maxItems = 250.
* @tracySkipLocation
*/
public static function barDumpBig($var, $title = NULL, array $options = NULL) {
public static function barDumpBig(string|array $var, string|array|null $title = NULL, ?array $options = NULL) {
if(self::tracyUnavailable() && !\TracyDebugger::getDataValue('recordGuestDumps')) return false;
if(is_array($title)) {
$options = $title;
Expand All @@ -108,7 +108,7 @@ public static function barDumpBig($var, $title = NULL, array $options = NULL) {
* Tracy\Debugger::dump() shortcut.
* @tracySkipLocation
*/
public static function dump($var, $title = NULL, array $options = NULL) {
public static function dump(string|array $var, string|array|null $title = NULL, ?array $options = NULL) {
if(self::tracyUnavailable() && PHP_SAPI !== 'cli') return false;
if(is_array($title)) {
$options = $title;
Expand Down Expand Up @@ -153,7 +153,7 @@ public static function dump($var, $title = NULL, array $options = NULL) {
* Tracy\Debugger::dumpBig() shortcut dumping with maxDepth = 6, maxLength = 9999 and maxItems = 250.
* @tracySkipLocation
*/
public static function dumpBig($var, $title = NULL, array $options = NULL) {
public static function dumpBig(string|array $var, string|array|null $title = NULL, ?array $options = NULL) {
if(self::tracyUnavailable() && PHP_SAPI !== 'cli') return false;
if(is_array($title)) {
$options = $title;
Expand Down Expand Up @@ -196,7 +196,7 @@ public static function dumpBig($var, $title = NULL, array $options = NULL) {
* Send content to dump bar
* @tracySkipLocation
*/
private static function dumpToBar($var, $title = NULL, array $options = NULL, $echo = false) {
private static function dumpToBar(string|array $var, string|array|null $title = NULL, ?array $options = NULL, $echo = false) {
$dumpItem = array();
$dumpItem['title'] = $title;
$dumpItem['dump'] = $echo ? '<div class="tracy-echo">' . $var . '</div>' : static::generateDump($var, $options);
Expand All @@ -214,7 +214,7 @@ private static function dumpToBar($var, $title = NULL, array $options = NULL, $e
* Generate debugInfo and Full Object tabbed output
* @tracySkipLocation
*/
private static function generateDump($var, $options) {
private static function generateDump(string|array $var, array $options) {
// standard options for all dump/barDump variations
$options[Dumper::COLLAPSE] = isset($options['collapse']) ? $options['collapse'] : \TracyDebugger::getDataValue('collapse');
$options[Dumper::COLLAPSE_COUNT] = isset($options['collapse_count']) ? $options['collapse_count'] : \TracyDebugger::getDataValue('collapse_count');
Expand Down Expand Up @@ -341,7 +341,7 @@ private static function generateEditViewLinks($var, $type, $section) {
* Tracy\Debugger::log() shortcut.
* @tracySkipLocation
*/
public static function log($message, $priority = Debugger::INFO) {
public static function log(string $message, $priority = Debugger::INFO) {
if(self::tracyUnavailable()) return false;
return Debugger::log($message, $priority);
}
Expand All @@ -350,7 +350,7 @@ public static function log($message, $priority = Debugger::INFO) {
* Tracy\Debugger::timer() shortcut.
* @tracySkipLocation
*/
public static function timer($name = NULL) {
public static function timer(?string $name = NULL) {
if(self::tracyUnavailable()) return false;
$roundedTime = round(Debugger::timer($name),4);
if($name) {
Expand All @@ -365,7 +365,7 @@ public static function timer($name = NULL) {
* Tracy\Debugger::fireLog() shortcut.
* @tracySkipLocation
*/
public static function fireLog($message = NULL) {
public static function fireLog(?string $message = NULL) {
if(!method_exists('Tracy\Debugger', 'getFireLogger') || self::tracyUnavailable()) return false;
return Debugger::fireLog($message);
}
Expand All @@ -375,7 +375,7 @@ public static function fireLog($message = NULL) {
* Zarganwar\PerformancePanel\Register::add() shortcut.
* @tracySkipLocation
*/
public static function addBreakpoint($name = null, $enforceParent = null) {
public static function addBreakpoint(?string $name = null, ?bool $enforceParent = null) {
if(self::tracyUnavailable() || !class_exists('\Zarganwar\PerformancePanel\Register')) return false;
return Zarganwar\PerformancePanel\Register::add($name, $enforceParent);
}
Expand Down

0 comments on commit e9a3c83

Please sign in to comment.