diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 1ba751d7c11d..9b25dfe58a2b 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -3085,18 +3085,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/OCI8/Connection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Database\\\\OCI8\\\\Connection\\:\\:\\$resetStmtId has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/OCI8/Connection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Database\\\\OCI8\\\\Connection\\:\\:\\$validDSNs has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/OCI8/Connection.php', -]; $ignoreErrors[] = [ // identifier: method.childReturnType 'message' => '#^Return type \\(array\\{code\\: int\\|string\\|null, message\\: string\\|null\\}\\) of method CodeIgniter\\\\Database\\\\OCI8\\\\Connection\\:\\:error\\(\\) should be covariant with return type \\(array\\\\) of method CodeIgniter\\\\Database\\\\ConnectionInterface\\\\:\\:error\\(\\)$#', @@ -3325,30 +3313,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:\\$connect_timeout has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:\\$options has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:\\$service has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:\\$sslmode has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/Postgre/Connection.php', -]; $ignoreErrors[] = [ // identifier: method.childReturnType 'message' => '#^Return type \\(array\\\\) of method CodeIgniter\\\\Database\\\\Postgre\\\\Connection\\:\\:error\\(\\) should be covariant with return type \\(array\\{code\\: int\\|string\\|null, message\\: string\\|null\\}\\) of method CodeIgniter\\\\Database\\\\BaseConnection\\\\:\\:error\\(\\)$#', @@ -9463,12 +9427,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Test/Mock/MockBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Test\\\\Mock\\\\MockCLIConfig\\:\\:\\$CSRFExcludeURIs has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockCLIConfig.php', -]; $ignoreErrors[] = [ // identifier: missingType.return 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCURLRequest\\:\\:getBaseURI\\(\\) has no return type specified\\.$#', @@ -9493,24 +9451,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.parameter - 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCURLRequest\\:\\:setOutput\\(\\) has parameter \\$output with no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Test\\\\Mock\\\\MockCURLRequest\\:\\:\\$curl_options has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.property - 'message' => '#^Property CodeIgniter\\\\Test\\\\Mock\\\\MockCURLRequest\\:\\:\\$output has no type specified\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:getMetaData\\(\\) return type has no value type specified in iterable type array\\.$#', diff --git a/system/Database/OCI8/Connection.php b/system/Database/OCI8/Connection.php index 2b870b755b44..94c551bfeb03 100644 --- a/system/Database/OCI8/Connection.php +++ b/system/Database/OCI8/Connection.php @@ -52,7 +52,12 @@ class Connection extends BaseConnection 'rownum', ]; - protected $validDSNs = [ + /** + * Array of valid DSN patterns for different Oracle connections. + * + * @var array{tns: string,ec: string,in: string} + */ + protected array $validDSNs = [ // TNS 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // Easy Connect string (Oracle 10g+). @@ -79,7 +84,7 @@ class Connection extends BaseConnection * Used by storedProcedure() to prevent execute() from * re-setting the statement ID. */ - protected $resetStmtId = true; + protected bool $resetStmtId = true; /** * Statement ID diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index ec886dbd4d8b..19e9aefc21c8 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -50,10 +50,22 @@ class Connection extends BaseConnection */ public $escapeChar = '"'; - protected $connect_timeout; - protected $options; - protected $sslmode; - protected $service; + /** + * @var int Connection timeout in seconds + */ + protected int $connect_timeout; + + /** + * @var string Connection options + */ + protected string $options; + + /** + * @var string Possible values are: disable, allow, prefer, require, verify-ca, verify-full + */ + protected string $sslmode; + + protected string $service; /** * Connect to the database. @@ -546,7 +558,11 @@ protected function buildDSN() // provided via string> Example: // // Postgre://username:password@localhost:5432/database?connect_timeout=5&sslmode=1 - foreach (['connect_timeout', 'options', 'sslmode', 'service'] as $key) { + if (isset($this->connect_timeout)) { + $this->DSN .= "connect_timeout={$this->connect_timeout} "; + } + + foreach (['options', 'sslmode', 'service'] as $key) { if (isset($this->{$key}) && is_string($this->{$key}) && $this->{$key} !== '') { $this->DSN .= "{$key}='{$this->{$key}}' "; } diff --git a/system/Session/Handlers/ArrayHandler.php b/system/Session/Handlers/ArrayHandler.php index 8faa00fdc9d7..cb09d28aafe1 100644 --- a/system/Session/Handlers/ArrayHandler.php +++ b/system/Session/Handlers/ArrayHandler.php @@ -21,7 +21,7 @@ */ class ArrayHandler extends BaseHandler { - protected static $cache = []; + protected static array $cache = []; /** * Re-initialize existing session, or creates a new one. diff --git a/system/Test/Mock/MockCLIConfig.php b/system/Test/Mock/MockCLIConfig.php index c62df3d9f43a..99e3597d353a 100644 --- a/system/Test/Mock/MockCLIConfig.php +++ b/system/Test/Mock/MockCLIConfig.php @@ -17,14 +17,19 @@ class MockCLIConfig extends App { - public string $baseURL = 'http://example.com/'; - public string $uriProtocol = 'REQUEST_URI'; - public array $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 $baseURL = 'http://example.com/'; + public string $uriProtocol = 'REQUEST_URI'; + public array $proxyIPs = []; + public string $CSRFTokenName = 'csrf_test_name'; + public string $CSRFCookieName = 'csrf_cookie_name'; + public int $CSRFExpire = 7200; + public bool $CSRFRegenerate = true; + + /** + * @var list + */ + public array $CSRFExcludeURIs = ['http://example.com']; + public string $CSRFSameSite = 'Lax'; public bool $CSPEnabled = false; public string $defaultLocale = 'en'; diff --git a/system/Test/Mock/MockCURLRequest.php b/system/Test/Mock/MockCURLRequest.php index 97f80e7c1da2..df9444f1e54e 100644 --- a/system/Test/Mock/MockCURLRequest.php +++ b/system/Test/Mock/MockCURLRequest.php @@ -24,10 +24,10 @@ */ class MockCURLRequest extends CURLRequest { - public $curl_options; - protected $output = ''; + public array $curl_options; + protected string $output = ''; - public function setOutput($output) + public function setOutput(string $output): static { $this->output = $output;