From 7a640e1d2aa954f8bb1cd101ec5c1cd9f6a15c94 Mon Sep 17 00:00:00 2001 From: sealsrock12 Date: Sat, 2 May 2026 16:04:47 -0700 Subject: [PATCH] make phpstan happy --- doom-scroll.php | 18 +++++++++--------- manualupload.php | 2 +- phpstan.neon | 8 +++++++- rudimentary.php | 2 +- viewer.php | 28 +++++++++++++++------------- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/doom-scroll.php b/doom-scroll.php index ee44f50..81baf0e 100644 --- a/doom-scroll.php +++ b/doom-scroll.php @@ -358,7 +358,7 @@ function object_table_iter(?array $arr): string foreach ($json_data['Hardware']['Storage'] as $disk) { foreach ($disk['Partitions'] as $partNum => $part) { if (isset($part['DirtyBitSet']) && $part['DirtyBitSet']) { - if (empty($part['PartitionLetter'])) { + if ($part['PartitionLetter'] === '') { echo "
  • Dirty bit set on partition $partNum ({$disk['DeviceName']}) @@ -425,7 +425,7 @@ function object_table_iter(?array $arr): string foreach ($json_data['System']['ChoiceRegistryValues'] as $regkey) { - if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']])) { + if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']], true)) { echo "
  • Registry Value {$regkey['Name']} found set, value of {$regkey['Value']} @@ -879,9 +879,9 @@ function(&$row) {

    Storage

    $drive) { + + foreach ($json_data['Hardware']['Storage'] as $drive) { $drive_size_raw = $drive['DiskCapacity']; $drive_free_raw = getDriveFree($drive); $drive_taken_raw = $drive_size_raw - $drive_free_raw; @@ -889,14 +889,14 @@ function(&$row) { $drive_taken = floor(bytesToGigabytes($drive_taken_raw)); // the drive size can sometimes be z ero if the drive is failing if ($drive_taken != 0 && $drive_size != 0) { - $drive_percentage = round((float)$drive_taken / (float)$drive_size * 100); + $drive_percentage = round($drive_taken / $drive_size * 100); } else $drive_percentage = 0; $letters = array_filter( array_column($drive['Partitions'], 'PartitionLetter') ); $lettersString = implode(", ", $letters); - $lettersStringDisplay = empty($lettersString) ? '' : "($lettersString)"; + $lettersStringDisplay = ($lettersString === '') ? '' : "($lettersString)"; echo '

    ' . $drive['DeviceName'] . '

    @@ -930,7 +930,7 @@ function(&$row) { $part_size_mb = bytesToMegabytes($part_size); $part_taken_mb = ceil(bytesToMegabytes($part_taken)); $part_display = ""; - if (!empty($part['PartitionLabel'])) { + if ($part['PartitionLabel'] !== '') { $part_display .= $part['PartitionLabel']; if (isset($part['PartitionLetter'])) { $part_display .= " ({$part['PartitionLetter']})"; @@ -938,7 +938,7 @@ function(&$row) { } else if (isset($part['PartitionLetter'])) { // and not partition label $part_display = $part['PartitionLetter']; } - if (!empty($part_display)) + if ($part_display !== '') $part_display .= '
    '; $fs_display = $part['Filesystem'] ?? 'Unknown'; @@ -1145,7 +1145,7 @@ function(&$row) { } else $default_browser = ''; foreach ($browser['Profiles'] as $profile): - $profile_key = array_search($profile, $browser['Profiles']); + $profile_key = array_search($profile, $browser['Profiles'], true); ?>

    Profile ""

    diff --git a/manualupload.php b/manualupload.php index 998d9fb..f4cfb7b 100644 --- a/manualupload.php +++ b/manualupload.php @@ -33,7 +33,7 @@ function check_keys_recursive($arr1, $arr2) { $randomString = bin2hex($randomBytes); $randomString = preg_replace('/[^A-Za-z0-9]/', '', substr($randomString, 0, 8)); - if(in_array($file_ext,$extensions)== false){ + if(in_array($file_ext,$extensions, true)== false){ $errors[]="Extension not allowed, please choose a Specify JSON file"; } diff --git a/phpstan.neon b/phpstan.neon index f483de6..263c3d8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,8 +2,14 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon parameters: strictRules: + booleansInConditions: false + level: 0 paths: - . + excludePaths: - - 'vendor/' \ No newline at end of file + - 'vendor/' + - 'gesp-mode.php' + ignoreErrors: + - identifier: empty.notAllowed \ No newline at end of file diff --git a/rudimentary.php b/rudimentary.php index 2632621..034fed1 100644 --- a/rudimentary.php +++ b/rudimentary.php @@ -79,7 +79,7 @@ function scan_dir($dir) { $files = array(); //----------------------------------- create an empty files array to play with foreach (scandir($dir) as $file) { if ($file[0] === '.') continue; //----------------- ignores all files starting with '.' - if (in_array($file, $ignored)) continue; //-------- ignores all files given in $ignored + if (in_array($file, $ignored, true)) continue; //-------- ignores all files given in $ignored $files[$file] = filemtime($dir . '/' . $file); //-- add to files list } arsort($files); //------------------------------------- sort file values (creation timestamps) diff --git a/viewer.php b/viewer.php index 2c74b8d..100eebf 100644 --- a/viewer.php +++ b/viewer.php @@ -874,16 +874,18 @@
    0) { $adapterText = $adapter['Description']; + $foundAdapter = true; break; } }; - if ($adapter == "") { + if (!$foundAdapter) { foreach ($json_data['Network']['Adapters'] as $adapter) { if ((bool) $adapter['PhysicalAdapter']) { $adapterText = $adapter['Description']; @@ -1204,7 +1206,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB $part_size = $part['PartitionCapacity']; $part_taken = $part_size - $part['PartitionFree']; $part_display = ""; - if (!empty($part['PartitionLabel'])) { + if ($part['PartitionLabel'] !== '') { $part_display .= $part['PartitionLabel']; if (isset($part['PartitionLetter'])) { $part_display .= " ({$part['PartitionLetter']})"; @@ -1212,7 +1214,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB } else if (isset($part['PartitionLetter'])) { // and not partition label $part_display = $part['PartitionLetter']; } - if (!empty($part_display)) + if ($part_display !== '') $part_display .= '
    '; $fs_display = $part['Filesystem'] ?? 'Unknown'; @@ -1599,7 +1601,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB '; } - if (!empty($json_data['Hardware']['Batteries'])) { + if (count($json_data['Hardware']['Batteries']) > 0) { foreach ($json_data['Hardware']['Batteries'] as $battery) { $cap = floatval($battery["Remaining_Life_Percentage"]); if ( @@ -1618,7 +1620,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB foreach ($json_data['Hardware']['Storage'] as $disk) { foreach ($disk['Partitions'] as $partNum => $part) { if (isset($part['DirtyBitSet']) && $part['DirtyBitSet']) { - if (empty($part['PartitionLetter'])) { + if ($part['PartitionLetter'] === '') { $noteshtml .= "

    Dirty bit set on partition $partNum ({$disk['DeviceName']}) @@ -1692,7 +1694,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB - if (!empty($noteshtml)) { + if ($noteshtml !== '') { $noteshtml = '
    ' . $noteshtml; echo $noteshtml; } @@ -1738,7 +1740,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB $driveKey += 1; } - if (!empty($drivehtml)) { + if ($drivehtml !== '') { $drivehtml = '

    Drive / SMART Notes

    ' . $drivehtml; echo $drivehtml; } @@ -1757,7 +1759,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB foreach ($json_data['System']['ChoiceRegistryValues'] as $regkey) { - if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']])){ + if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']], true)){ $reghtml .= '

    Registry Value ' . $regkey['Name'] . ' found set, value of ' . $regkey['Value'] . ' @@ -1766,7 +1768,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB } - if (!empty($reghtml)) { + if ($reghtml !== '') { $reghtml = '

    Notable Registry Changes

    ' . $reghtml; echo $reghtml; } @@ -1777,7 +1779,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB 0) { $puphtml .= '

    Notable Software found Installed

    '; @@ -1790,7 +1792,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB $puphtml .= ''; } - if (!empty($pupsfoundRunning)) { + if (count($pupsfoundRunning) > 0) { $puphtml .= '

    Notable Software found Running

    '; @@ -1803,7 +1805,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB $puphtml .= ''; } - if (!empty($puphtml)) { + if ($puphtml !== '') { echo $puphtml; } else { echo '

    No Notable Software found, yay!

    '; @@ -1904,7 +1906,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB