summaryrefslogtreecommitdiff
path: root/b.php
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
commit2c69095a1edf7474073451285238659d0f62ce3f (patch)
tree5dee476605402c66dc2853d0836b29f6aedae62b /b.php
parente9a61e2fbbd930eaa80d6a5f33420cedc59d748c (diff)
PHP8.1 fixes from Rector
Diffstat (limited to 'b.php')
-rwxr-xr-xb.php8
1 files changed, 4 insertions, 4 deletions
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);
}