Add strict mode 1

This commit is contained in:
Visman 2020-10-14 20:01:43 +07:00
parent 25889b1415
commit bd0ca920fd
31 changed files with 76 additions and 12 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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':

View file

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

View file

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

View file

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

View file

@ -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);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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');

View file

@ -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()
{

View file

@ -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_',

View file

@ -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) {

View file

@ -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';

View file

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