diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index 986601771fef..ad101a555afd 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -25,10 +25,6 @@ parameters: count: 1 path: system/Cache/Handlers/MemcachedHandler.php - - - message: "#^Variable \\$data might not be defined\\.$#" - count: 1 - path: system/Cache/Handlers/MemcachedHandler.php - message: "#^Property CodeIgniter\\\\Cache\\\\Handlers\\\\RedisHandler\\:\\:\\$redis \\(Redis\\) in isset\\(\\) is not nullable\\.$#" @@ -200,11 +196,6 @@ parameters: count: 1 path: system/Helpers/number_helper.php - - - message: "#^Variable \\$count might not be defined\\.$#" - count: 1 - path: system/Helpers/url_helper.php - - message: "#^Property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$image \\(CodeIgniter\\\\Images\\\\Image\\) in empty\\(\\) is not falsy\\.$#" count: 1 @@ -230,21 +221,6 @@ parameters: count: 4 path: system/Images/Handlers/ImageMagickHandler.php - - - message: "#^Variable \\$gravity might not be defined\\.$#" - count: 1 - path: system/Images/Handlers/ImageMagickHandler.php - - - - message: "#^Variable \\$xAxis might not be defined\\.$#" - count: 1 - path: system/Images/Handlers/ImageMagickHandler.php - - - - message: "#^Variable \\$yAxis might not be defined\\.$#" - count: 1 - path: system/Images/Handlers/ImageMagickHandler.php - - message: "#^Call to an undefined method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:getDefaultNamespace\\(\\)\\.$#" count: 3 diff --git a/rector.php b/rector.php index d53f9af118eb..095cb2444c62 100644 --- a/rector.php +++ b/rector.php @@ -36,7 +36,6 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; -use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; @@ -106,9 +105,6 @@ // sometime too detail CountOnNullRector::class, - // may not be unitialized on purpose - AddDefaultValueForUndefinedVariableRector::class, - // use mt_rand instead of random_int on purpose on non-cryptographically random RandomFunctionRector::class, diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index f7d5ec8bcd1a..5053b1a6752a 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -124,7 +124,8 @@ public function initialize() */ public function get(string $key) { - $key = static::validateKey($key, $this->prefix); + $data = []; + $key = static::validateKey($key, $this->prefix); if ($this->memcached instanceof Memcached) { $data = $this->memcached->get($key); diff --git a/system/Commands/Generators/MigrationGenerator.php b/system/Commands/Generators/MigrationGenerator.php index 5cc3b6dfd56a..817c16885205 100644 --- a/system/Commands/Generators/MigrationGenerator.php +++ b/system/Commands/Generators/MigrationGenerator.php @@ -97,6 +97,7 @@ public function run(array $params) */ protected function prepare(string $class): string { + $data = []; $data['session'] = false; if ($this->getOption('session')) { diff --git a/system/Commands/Generators/SessionMigrationGenerator.php b/system/Commands/Generators/SessionMigrationGenerator.php index a1e02a131b63..fbfb2d3db1ff 100644 --- a/system/Commands/Generators/SessionMigrationGenerator.php +++ b/system/Commands/Generators/SessionMigrationGenerator.php @@ -89,6 +89,7 @@ public function run(array $params) */ protected function prepare(string $class): string { + $data = []; $data['session'] = true; $data['table'] = $this->getOption('t'); $data['DBGroup'] = $this->getOption('g'); diff --git a/system/Commands/Utilities/FilterCheck.php b/system/Commands/Utilities/FilterCheck.php index 15f66e97a8a7..d2eb2fb728a4 100644 --- a/system/Commands/Utilities/FilterCheck.php +++ b/system/Commands/Utilities/FilterCheck.php @@ -72,6 +72,7 @@ class FilterCheck extends BaseCommand */ public function run(array $params) { + $tbody = []; if (! isset($params[0], $params[1])) { CLI::error('You must specify a HTTP verb and a route.'); CLI::write(' Usage: ' . $this->usage); diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3142aa18d01b..2caba0b12442 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1423,6 +1423,7 @@ public function orHaving($key, $value = null, ?bool $escape = null) */ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null) { + $qbOrderBy = []; if (empty($orderBy)) { return $this; } diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index b74435036c18..5d9b208d6010 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -529,6 +529,7 @@ public function getPlatform(): string */ public function getVersion(): string { + $info = []; if (isset($this->dataCache['version'])) { return $this->dataCache['version']; } diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 10dad0f4a947..17e67aa8eb94 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -76,6 +76,7 @@ public function __construct(ToolbarConfig $config) */ public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string { + $data = []; // Data items used within the view. $data['url'] = current_url(); $data['method'] = strtoupper($request->getMethod()); diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 2991840c8de1..c7ed6703b402 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -140,6 +140,7 @@ protected function formatTimelineData(): array */ public function display(): array { + $data = []; $data['queries'] = array_map(static function (array $query) { $isDuplicate = $query['duplicate'] === true; diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 979aae1b9179..c7a36e270860 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -236,6 +236,7 @@ function link_tag( bool $indexPage = false, string $hreflang = '' ): string { + $attributes = []; // extract fields if needed if (is_array($href)) { $rel = $href['rel'] ?? $rel; diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 1f2db240e627..682830ba1e5a 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -56,12 +56,10 @@ function _get_uri(string $relativePath = '', ?App $config = null): URI // Build the full URL based on $config and $relativePath $request = Services::request(); - if ($request instanceof CLIRequest) { - /** @var App $config */ - $url = rtrim($config->baseURL, '/ ') . '/'; - } else { - $url = $request->getUri()->getBaseURL(); - } + /** @var App $config */ + $url = $request instanceof CLIRequest + ? rtrim($config->baseURL, '/ ') . '/' + : $request->getUri()->getBaseURL(); // Check for an index page if ($config->indexPage !== '') { @@ -329,6 +327,7 @@ function mailto(string $email, string $title = '', $attributes = ''): string */ function safe_mailto(string $email, string $title = '', $attributes = ''): string { + $count = 0; if (trim($title) === '') { $title = $email; } diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index b96fdc06d20d..41274c6a9591 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -322,7 +322,10 @@ protected function supportedFormatCheck() */ protected function _text(string $text, array $options = []) { - $cmd = ''; + $xAxis = 0; + $yAxis = 0; + $gravity = ''; + $cmd = ''; // Reverse the vertical offset // When the image is positioned at the bottom diff --git a/system/Model.php b/system/Model.php index 0278be4e4d21..de646c6f8c7c 100644 --- a/system/Model.php +++ b/system/Model.php @@ -427,6 +427,7 @@ protected function doUpdateBatch(?array $set = null, ?string $index = null, int */ protected function doDelete($id = null, bool $purge = false) { + $set = []; $builder = $this->builder(); if ($id) { diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index d698f647abe5..1506c7b3d2f5 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -123,6 +123,8 @@ public function testListTablesConstrainedByPrefixReturnsOnlyTablesWithMatchingPr public function testListTablesConstrainedByExtraneousPrefixReturnsOnlyTheExtraneousTable() { + $oldPrefix = ''; + try { $this->createExtraneousTable(); diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 100cf1535495..6597866b3f88 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -288,6 +288,7 @@ public function testClosureRuleWithLabel(): void */ public function testCanValidatetArrayData($value, bool $expected): void { + $data = []; $this->validation->setRules(['arr' => 'is_array']); $data['arr'] = $value;