refactor: add type for properties

This commit is contained in:
kenjis 2022-07-01 13:49:24 +09:00
parent 7eddfab313
commit a2310baa13
No known key found for this signature in database
GPG Key ID: BD254878922AF198
5 changed files with 50 additions and 215 deletions

View File

@ -25,21 +25,6 @@ parameters:
count: 1
path: system/Autoloader/Autoloader.php
-
message: "#^Property Config\\\\Cache\\:\\:\\$backupHandler \\(string\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Cache/CacheFactory.php
-
message: "#^Property Config\\\\Cache\\:\\:\\$handler \\(string\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Cache/CacheFactory.php
-
message: "#^Property Config\\\\Cache\\:\\:\\$validHandlers \\(array\\<string, string\\>\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Cache/CacheFactory.php
-
message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and \\(array\\|float\\|int\\) results in an error\\.$#"
count: 1
@ -50,11 +35,6 @@ parameters:
count: 1
path: system/Cache/Handlers/FileHandler.php
-
message: "#^Property Config\\\\Cache\\:\\:\\$storePath \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Cache/Handlers/FileHandler.php
-
message: "#^Method MemcachePool\\:\\:decrement\\(\\) invoked with 4 parameters, 1\\-2 required\\.$#"
count: 1
@ -80,11 +60,6 @@ parameters:
count: 1
path: system/Cache/Handlers/MemcachedHandler.php
-
message: "#^Property Config\\\\Cache\\:\\:\\$redis \\(array\\<string, int\\|string\\|null\\>\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Cache/Handlers/PredisHandler.php
-
message: "#^Property CodeIgniter\\\\Cache\\\\Handlers\\\\RedisHandler\\:\\:\\$redis \\(Redis\\) in isset\\(\\) is not nullable\\.$#"
count: 1
@ -105,16 +80,6 @@ parameters:
count: 1
path: system/CodeIgniter.php
-
message: "#^Property Config\\\\App\\:\\:\\$appTimezone \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/CodeIgniter.php
-
message: "#^Property Config\\\\App\\:\\:\\$defaultLocale \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/CodeIgniter.php
-
message: "#^Property CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:\\$db \\(CodeIgniter\\\\Database\\\\BaseConnection\\) in empty\\(\\) is not falsy\\.$#"
count: 1
@ -165,16 +130,6 @@ parameters:
count: 1
path: system/Database/Migration.php
-
message: "#^Property Config\\\\Migrations\\:\\:\\$enabled \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Database/MigrationRunner.php
-
message: "#^Property Config\\\\Migrations\\:\\:\\$table \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Database/MigrationRunner.php
-
message: "#^Cannot access property \\$errno on bool\\|object\\|resource\\.$#"
count: 1
@ -440,26 +395,11 @@ parameters:
count: 2
path: system/Database/SQLite3/Result.php
-
message: "#^Property Config\\\\Database\\:\\:\\$filesPath \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Database/Seeder.php
-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Debug/Exceptions.php
-
message: "#^Property Config\\\\Exceptions\\:\\:\\$sensitiveDataInTrace \\(array\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Debug/Exceptions.php
-
message: "#^Property Config\\\\Toolbar\\:\\:\\$collectVarData \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Debug/Toolbar.php
-
message: "#^Call to an undefined method CodeIgniter\\\\View\\\\RendererInterface\\:\\:getPerformanceData\\(\\)\\.$#"
count: 1
@ -485,11 +425,6 @@ parameters:
count: 1
path: system/Email/Email.php
-
message: "#^Property Config\\\\Encryption\\:\\:\\$digest \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 2
path: system/Encryption/Encryption.php
-
message: "#^Property CodeIgniter\\\\Files\\\\File\\:\\:\\$size \\(int\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
@ -500,21 +435,6 @@ parameters:
count: 1
path: system/Filters/Filters.php
-
message: "#^Property Config\\\\Filters\\:\\:\\$filters \\(array\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Filters/Filters.php
-
message: "#^Property Config\\\\Filters\\:\\:\\$globals \\(array\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Filters/Filters.php
-
message: "#^Property Config\\\\Filters\\:\\:\\$methods \\(array\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: system/Filters/Filters.php
-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
count: 1
@ -645,11 +565,6 @@ parameters:
count: 1
path: system/Images/Handlers/ImageMagickHandler.php
-
message: "#^Property Config\\\\Logger\\:\\:\\$dateFormat \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Log/Logger.php
-
message: "#^Call to an undefined method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:getDefaultNamespace\\(\\)\\.$#"
count: 3
@ -695,16 +610,6 @@ parameters:
count: 1
path: system/Router/Router.php
-
message: "#^Property Config\\\\App\\:\\:\\$CSRF[a-zA-Z]+ \\([a-zA-Z]+\\) on left side of \\?\\? is not nullable\\.$#"
count: 6
path: system/Security/Security.php
-
message: "#^Property Config\\\\Security\\:\\:\\$[a-zA-Z]+ \\([a-zA-Z]+\\) on left side of \\?\\? is not nullable\\.$#"
count: 8
path: system/Security/Security.php
-
message: "#^Strict comparison using \\=\\=\\= between string and true will always evaluate to false\\.$#"
count: 1
@ -715,71 +620,6 @@ parameters:
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$cookieDomain \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$cookiePath \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$cookieSecure \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$sessionCookieName \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$sessionExpiration \\(int\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$sessionMatchIP \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$sessionRegenerateDestroy \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\App\\:\\:\\$sessionTimeToUpdate \\(int\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\Cookie\\:\\:\\$domain \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\Cookie\\:\\:\\$path \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\Cookie\\:\\:\\$raw \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\Cookie\\:\\:\\$samesite \\(string\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Property Config\\\\Cookie\\:\\:\\$secure \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: system/Session/Session.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
@ -845,11 +685,6 @@ parameters:
count: 1
path: system/View/Parser.php
-
message: "#^Result of \\|\\| is always false\\.$#"
paths:
- system/Cache/CacheFactory.php
-
message: "#^Binary operation \"/\" between string and 8 results in an error\\.$#"
path: system/Encryption/Handlers/OpenSSLHandler.php

View File

@ -15,27 +15,27 @@ use Config\App;
class MockAppConfig extends App
{
public $baseURL = 'http://example.com/';
public $uriProtocol = 'REQUEST_URI';
public $cookiePrefix = '';
public $cookieDomain = '';
public $cookiePath = '/';
public $cookieSecure = false;
public $cookieHTTPOnly = false;
public $cookieSameSite = 'Lax';
public $proxyIPs = '';
public $CSRFTokenName = 'csrf_test_name';
public $CSRFHeaderName = 'X-CSRF-TOKEN';
public $CSRFCookieName = 'csrf_cookie_name';
public $CSRFExpire = 7200;
public $CSRFRegenerate = true;
public $CSRFExcludeURIs = ['http://example.com'];
public $CSRFRedirect = false;
public $CSRFSameSite = 'Lax';
public $CSPEnabled = false;
public $defaultLocale = 'en';
public $negotiateLocale = false;
public $supportedLocales = [
public string $baseURL = 'http://example.com/';
public string $uriProtocol = 'REQUEST_URI';
public string $cookiePrefix = '';
public string $cookieDomain = '';
public string $cookiePath = '/';
public bool $cookieSecure = false;
public bool $cookieHTTPOnly = false;
public ?string $cookieSameSite = 'Lax';
public $proxyIPs = '';
public string $CSRFTokenName = 'csrf_test_name';
public string $CSRFHeaderName = 'X-CSRF-TOKEN';
public string $CSRFCookieName = 'csrf_cookie_name';
public int $CSRFExpire = 7200;
public bool $CSRFRegenerate = true;
public array $CSRFExcludeURIs = ['http://example.com'];
public bool $CSRFRedirect = false;
public string $CSRFSameSite = 'Lax';
public bool $CSPEnabled = false;
public string $defaultLocale = 'en';
public bool $negotiateLocale = false;
public array $supportedLocales = [
'en',
'es',
];

View File

@ -15,25 +15,25 @@ use Config\App;
class MockCLIConfig extends App
{
public $baseURL = 'http://example.com/';
public $uriProtocol = 'REQUEST_URI';
public $cookiePrefix = '';
public $cookieDomain = '';
public $cookiePath = '/';
public $cookieSecure = false;
public $cookieHTTPOnly = false;
public $cookieSameSite = 'Lax';
public $proxyIPs = '';
public $CSRFTokenName = 'csrf_test_name';
public $CSRFCookieName = 'csrf_cookie_name';
public $CSRFExpire = 7200;
public $CSRFRegenerate = true;
public $CSRFExcludeURIs = ['http://example.com'];
public $CSRFSameSite = 'Lax';
public $CSPEnabled = false;
public $defaultLocale = 'en';
public $negotiateLocale = false;
public $supportedLocales = [
public string $baseURL = 'http://example.com/';
public string $uriProtocol = 'REQUEST_URI';
public string $cookiePrefix = '';
public string $cookieDomain = '';
public string $cookiePath = '/';
public bool $cookieSecure = false;
public bool $cookieHTTPOnly = false;
public ?string $cookieSameSite = 'Lax';
public $proxyIPs = '';
public string $CSRFTokenName = 'csrf_test_name';
public string $CSRFCookieName = 'csrf_cookie_name';
public int $CSRFExpire = 7200;
public bool $CSRFRegenerate = true;
public $CSRFExcludeURIs = ['http://example.com'];
public string $CSRFSameSite = 'Lax';
public bool $CSPEnabled = false;
public string $defaultLocale = 'en';
public bool $negotiateLocale = false;
public array $supportedLocales = [
'en',
'es',
];

View File

@ -20,12 +20,12 @@ use Config\Security;
*/
class MockSecurityConfig extends Security
{
public $tokenName = 'csrf_test_name';
public $headerName = 'X-CSRF-TOKEN';
public $cookieName = 'csrf_cookie_name';
public $expires = 7200;
public $regenerate = true;
public $redirect = false;
public $samesite = 'Lax';
public $excludeURIs = ['http://example.com'];
public string $tokenName = 'csrf_test_name';
public string $headerName = 'X-CSRF-TOKEN';
public string $cookieName = 'csrf_cookie_name';
public int $expires = 7200;
public bool $regenerate = true;
public bool $redirect = false;
public string $samesite = 'Lax';
public $excludeURIs = ['http://example.com'];
}

View File

@ -16,8 +16,8 @@ class Encryption extends EncryptionConfig
private const HEX2BIN = 'hex2bin:84cf2c0811d5daf9e1c897825a3debce91f9a33391e639f72f7a4740b30675a2';
private const BASE64 = 'base64:Psf8bUHRh1UJYG2M7e+5ec3MdjpKpzAr0twamcAvOcI=';
public $key;
public $driver = 'MCrypt';
public string $key;
public string $driver = 'MCrypt';
public function __construct(string $prefix = 'hex2bin')
{