Explorar el Código

Add strict mode 1

Visman hace 4 años
padre
commit
bd0ca920fd

+ 2 - 0
app/Controllers/Install.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Controllers;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Controllers/Primary.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Controllers;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Controllers/Routing.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Controllers;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Controllers/Update.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Controllers;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Core/Cache/FileCache.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core\Cache;
 
 use Psr\SimpleCache\CacheInterface;

+ 2 - 0
app/Core/Config.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Exceptions\ForkException;

+ 4 - 0
app/Core/Container.php

@@ -1,8 +1,12 @@
 <?php
+
 /**
  * based on Container https://github.com/artoodetoo/container
  * by artoodetoo
  */
+
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use InvalidArgumentException;

+ 2 - 0
app/Core/Csrf.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Secury;

+ 2 - 0
app/Core/DB.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\DBStatement;

+ 2 - 0
app/Core/DB/mysql.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core\DB;
 
 use ForkBB\Core\DB;

+ 2 - 0
app/Core/DBStatement.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use PDO;

+ 2 - 0
app/Core/ErrorHandler.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use Throwable;

+ 2 - 0
app/Core/File.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Exceptions\FileException;

+ 2 - 0
app/Core/Files.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\File;

+ 2 - 0
app/Core/Func.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Container;

+ 5 - 3
app/Core/Image.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Files;
@@ -59,8 +61,8 @@ class Image extends File
         $wr     = ($maxW < 1) ? 1 : $maxW / $oldW;
         $hr     = ($maxH < 1) ? 1 : $maxH / $oldH;
         $r      = \min($wr, $hr, 1);
-        $width  = \round($oldW * $r);
-        $height = \round($oldH * $r);
+        $width  = (int) \round($oldW * $r);
+        $height = (int) \round($oldH * $r);
 
         if (false === ($image = \imagecreatetruecolor($width, $height))) {
             throw new FileException('Failed to create new truecolor image');
@@ -126,7 +128,7 @@ class Image extends File
                 $result = @\imagejpeg($this->image, $path, $this->quality);
                 break;
             case 'png':
-                $quality = \floor((100 - $this->quality) / 11);
+                $quality = (int) \floor((100 - $this->quality) / 11);
                 $result  = @\imagepng($this->image, $path, $quality);
                 break;
             case 'gif':

+ 2 - 0
app/Core/Lang.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Core/Mail.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Exceptions\MailException;

+ 2 - 0
app/Core/Parser.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use Parserus;

+ 3 - 1
app/Core/Router.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Csrf;
@@ -84,7 +86,7 @@ class Router
         $this->baseUrl = $base;
         $this->csrf    = $csrf;
         $this->host    = \parse_url($base, \PHP_URL_HOST);
-        $this->prefix  = \parse_url($base, \PHP_URL_PATH);
+        $this->prefix  = \parse_url($base, \PHP_URL_PATH) ?? '';
         $this->length  = \strlen($this->prefix);
     }
 

+ 2 - 0
app/Core/RulesValidator.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Core/Secury.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use RuntimeException;

+ 2 - 0
app/Core/Test.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Core/Validator.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use ForkBB\Core\Container;

+ 2 - 0
app/Core/View.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB\Core;
 
 use R2\Templating\Dirk;

+ 4 - 2
app/bootstrap.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB;
 
 use ForkBB\Core\Container;
@@ -8,8 +10,8 @@ use ForkBB\Models\Page;
 use RuntimeException;
 
 \error_reporting(\E_ALL ^ \E_NOTICE);
-\ini_set('display_errors', 0);
-\ini_set('log_errors', 1);
+\ini_set('display_errors', '0');
+\ini_set('log_errors', '1');
 
 \setlocale(\LC_ALL, 'C');
 \mb_language('uni');

+ 4 - 2
app/config/install.php

@@ -1,8 +1,10 @@
 <?php
 
+declare(strict_types=1);
+
 \error_reporting(\E_ALL);
-\ini_set('display_errors', 1);
-\ini_set('log_errors', 1);
+\ini_set('display_errors', '1');
+\ini_set('log_errors', '1');
 
 function forkGetBaseURL()
 {

+ 4 - 2
app/config/main.dist.php

@@ -1,9 +1,11 @@
 <?php
 
+declare(strict_types=1);
+
 # development
 #\error_reporting(\E_ALL);
-#\ini_set('display_errors', 1);
-#\ini_set('log_errors', 1);
+#\ini_set('display_errors', '1');
+#\ini_set('log_errors', '1');
 
 return [
     'BASE_URL'    => '_BASE_URL_',

+ 4 - 2
app/functions.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 namespace ForkBB;
 
 use ForkBB\Core\Container;
@@ -67,7 +69,7 @@ function e(string $arg): string
 function num(/* mixed */ $number, int $decimals = 0): string
 {
     return \is_numeric($number)
-        ? \number_format($number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep'))
+        ? \number_format((float) $number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep'))
         : '-';
 }
 
@@ -87,7 +89,7 @@ function dt(int $arg, bool $dateOnly = false, string $dateFormat = null, string
         return __('Never');
     }
 
-    $diff = ($c->user->timezone + $c->user->dst) * 3600;
+    $diff = (int) (($c->user->timezone + $c->user->dst) * 3600);
     $arg += $diff;
 
     if (null === $dateFormat) {

+ 2 - 0
index.dist.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 $forkStart = empty($_SERVER['REQUEST_TIME_FLOAT']) ? \microtime(true) : $_SERVER['REQUEST_TIME_FLOAT'];
 $forkPublic = __DIR__ . '/public';
 $forkPublicPrefix = '/public';

+ 2 - 0
public/index.dist.php

@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 $forkStart = empty($_SERVER['REQUEST_TIME_FLOAT']) ? \microtime(true) : $_SERVER['REQUEST_TIME_FLOAT'];
 $forkPublic = __DIR__;
 $forkPublicPrefix = '';