From 2c69095a1edf7474073451285238659d0f62ce3f Mon Sep 17 00:00:00 2001 From: Appleman1234 Date: Sun, 25 Sep 2022 13:30:13 +1000 Subject: PHP8.1 fixes from Rector --- b.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'b.php') diff --git a/b.php b/b.php index a0638ec3..9c4edfc5 100755 --- a/b.php +++ b/b.php @@ -9,15 +9,15 @@ function getFilesInDirectory($dir) { return null; } - return array_diff(scandir($dir), array('.', '..')); + return array_diff(scandir($dir), ['.', '..']); } // Serve a random banner and exit. -function serveRandomBanner($dir, $files) { +function serveRandomBanner($dir, $files): never { $name = $files[array_rand($files)]; // snags the extension - $ext = pathinfo($name, PATHINFO_EXTENSION); + $ext = pathinfo((string) $name, PATHINFO_EXTENSION); // send the right headers header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1 @@ -39,7 +39,7 @@ $banners = getFilesInDirectory($bannerDir); $priority = getFilesInDirectory($priorityDir); // If there are priority banners, serve 1/3rd of the time. -if($priority !== null && count($priority) !== 0 && rand(0,2) === 0) { +if($priority !== null && (is_countable($priority) ? count($priority) : 0) !== 0 && random_int(0,2) === 0) { serveRandomBanner($priorityDir, $priority); } -- cgit v1.3