diff --git a/composer.json b/composer.json index 3d257784b2f0..6f15a3622b7a 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "boundwize/structarmed": "0.13.4", - "codeigniter/phpstan-codeigniter": "^1.5", + "codeigniter/phpstan-codeigniter": "^2.1", "fakerphp/faker": "^1.24", "kint-php/kint": "^6.1", "mikey179/vfsstream": "^1.6.12", @@ -29,7 +29,7 @@ "phpunit/phpcov": "^9.0.2 || ^10.0", "phpunit/phpunit": "^10.5.16 || ^11.2", "predis/predis": "^3.0", - "rector/rector": "2.4.5", + "rector/rector": "2.4.6", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a508f84c696a..f90fcc94ee33 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -47,5 +47,6 @@ parameters: additionalModelNamespaces: - Tests\Support\Models checkArgumentTypeOfModel: false + schemaCacheDirectory: %currentWorkingDirectory%/build/phpstan shipmonkBaselinePerIdentifier: directory: %currentWorkingDirectory% diff --git a/rector.php b/rector.php index eeede43de2a7..4552a898aee3 100644 --- a/rector.php +++ b/rector.php @@ -77,10 +77,10 @@ __DIR__ . '/phpstan-bootstrap.php', ]) ->withPHPStanConfigs([ - __DIR__ . '/phpstan.neon.dist', __DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon', __DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon', __DIR__ . '/vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon', + __DIR__ . '/phpstan.neon.dist', ]) // is there a file you need to skip? ->withSkip([ diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index 5ec5fc0fa074..bf5419eab560 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -375,7 +375,7 @@ public function getRequiredFilters(string $position = 'before'): array { // For backward compatibility. For users who do not update Config\Filters. if (! isset($this->config->required[$position])) { - $baseConfig = config(BaseFiltersConfig::class); // @phpstan-ignore-line + $baseConfig = config(BaseFiltersConfig::class); $filters = $baseConfig->required[$position]; $aliases = $baseConfig->aliases; } else { diff --git a/tests/system/CommonSingleServiceTest.php b/tests/system/CommonSingleServiceTest.php index e423d1feaee0..829f0f6e2d96 100644 --- a/tests/system/CommonSingleServiceTest.php +++ b/tests/system/CommonSingleServiceTest.php @@ -34,8 +34,8 @@ public function testSingleServiceWithNoParamsSupplied(string $service): void { Services::injectMock('security', new MockSecurity(new SecurityConfig())); - $service1 = single_service($service); // @phpstan-ignore codeigniter.unknownServiceMethod - $service2 = single_service($service); // @phpstan-ignore codeigniter.unknownServiceMethod + $service1 = single_service($service); + $service2 = single_service($service); $this->assertNotNull($service1); @@ -62,8 +62,8 @@ public function testSingleServiceWithAtLeastOneParamSupplied(string $service): v $params[] = $method->getNumberOfParameters() === 1 ? true : $method->getParameters()[0]->getDefaultValue(); - $service1 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod - $service2 = single_service($service, ...$params); // @phpstan-ignore codeigniter.unknownServiceMethod + $service1 = single_service($service, ...$params); + $service2 = single_service($service, ...$params); $this->assertNotNull($service1); diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index 505f4bedcbcb..67a0e05fd18b 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -93,7 +93,7 @@ public static function provideLoadsVars(): iterable public function testLoadsHex2Bin(): void { putenv('encryption.key'); - unset($_ENV['encryption.key'], $_SERVER['encryption.key']); // @phpstan-ignore codeigniter.superglobalAccess + unset($_ENV['encryption.key'], $_SERVER['encryption.key']); $dotenv = new DotEnv($this->fixturesFolder, 'encryption.env'); $dotenv->load(); @@ -108,7 +108,7 @@ public function testLoadsHex2Bin(): void public function testLoadsBase64(): void { putenv('encryption.key'); - unset($_ENV['encryption.key'], $_SERVER['encryption.key']); // @phpstan-ignore codeigniter.superglobalAccess + unset($_ENV['encryption.key'], $_SERVER['encryption.key']); $dotenv = new DotEnv($this->fixturesFolder, 'base64encryption.env'); $dotenv->load(); diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 52d1de2f5a8b..5233a28deeaf 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -906,7 +906,7 @@ public function testCastEnumNullable(): void $entity->status = null; - $this->assertNull($entity->status); + $this->assertNotInstanceOf(StatusEnum::class, $entity->status); $entity->status = 'pending'; @@ -1573,7 +1573,7 @@ public function testDataCasterInitEmptyCasts(): void $getDataCaster = $this->getPrivateMethodInvoker($entity, 'dataCaster'); - $this->assertNull($getDataCaster()); + $this->assertNotInstanceOf(DataCaster::class, $getDataCaster()); $this->assertNull($this->getPrivateProperty($entity, 'dataCaster')); $this->assertSame('12345', $entity->first); diff --git a/tests/system/Models/DataConverterModelTest.php b/tests/system/Models/DataConverterModelTest.php index 7d647790d62b..eb9a36c4668d 100644 --- a/tests/system/Models/DataConverterModelTest.php +++ b/tests/system/Models/DataConverterModelTest.php @@ -36,7 +36,7 @@ public function testFindAsArray(): void $user = $this->model->find($id); - $this->assertIsInt($user['id']); // @phpstan-ignore offsetAccess.notFound + $this->assertIsInt($user['id']); $this->assertInstanceOf(Time::class, $user['created_at']); $this->assertSame('John Smith', $user['name']); // `name` is cast by custom CastBase64 handler. @@ -128,9 +128,9 @@ public function testFindAllAsArray(): void $users = $this->model->findAll(); - $this->assertIsInt($users[0]['id']); // @phpstan-ignore offsetAccess.notFound + $this->assertIsInt($users[0]['id']); $this->assertInstanceOf(Time::class, $users[0]['created_at']); - $this->assertIsInt($users[1]['id']); // @phpstan-ignore offsetAccess.notFound + $this->assertIsInt($users[1]['id']); $this->assertInstanceOf(Time::class, $users[1]['created_at']); } @@ -208,7 +208,7 @@ public function testFirstAsArray(): void $user = $this->model->first(); - $this->assertIsInt($user['id']); // @phpstan-ignore offsetAccess.notFound + $this->assertIsInt($user['id']); $this->assertInstanceOf(Time::class, $user['created_at']); } @@ -265,7 +265,7 @@ public function testInsertArray(): void $user = $this->model->find($id); - $this->assertSame(['joe@example.com'], $user['email']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame(['joe@example.com'], $user['email']); } public function testInsertObject(): void @@ -281,7 +281,7 @@ public function testInsertObject(): void $user = $this->model->find($id); - $this->assertSame(['joe@example.com'], $user['email']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame(['joe@example.com'], $user['email']); } public function testUpdateArray(): void @@ -290,14 +290,14 @@ public function testUpdateArray(): void $user = $this->model->find($id); $user['email'][] = 'private@example.org'; - $this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound + $this->model->update($user['id'], $user); $user = $this->model->find($id); $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); // @phpstan-ignore offsetAccess.notFound + ], $user['email']); } public function testUpdateObject(): void @@ -313,7 +313,7 @@ public function testUpdateObject(): void $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); // @phpstan-ignore offsetAccess.notFound + ], $user['email']); } public function testUpdateCustomObject(): void @@ -365,7 +365,7 @@ public function testSaveArray(): void $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); // @phpstan-ignore offsetAccess.notFound + ], $user['email']); } public function testSaveObject(): void @@ -381,7 +381,7 @@ public function testSaveObject(): void $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); // @phpstan-ignore offsetAccess.notFound + ], $user['email']); } public function testSaveCustomObject(): void diff --git a/tests/system/Models/TimestampModelTest.php b/tests/system/Models/TimestampModelTest.php index 9af7cd3b9547..e2b5feb2da14 100644 --- a/tests/system/Models/TimestampModelTest.php +++ b/tests/system/Models/TimestampModelTest.php @@ -98,7 +98,7 @@ public function testDoNotAllowDatesInsertArrayWithoutDatesSetsTimestamp(): void $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame($expected, $user['created_at']); $this->assertSame($expected, $user['updated_at']); } @@ -123,7 +123,7 @@ public function testDoNotAllowDatesInsertArrayWithDatesSetsTimestamp(): void $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame($expected, $user['created_at']); $this->assertSame($expected, $user['updated_at']); } @@ -143,7 +143,7 @@ public function testDoNotAllowDatesUpdateArrayUpdatesUpdatedAt(): void $user = $this->model->find($id); $user['country'] = 'CA'; - $this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound + $this->model->update($user['id'], $user); $user = $this->model->find($id); @@ -153,7 +153,7 @@ public function testDoNotAllowDatesUpdateArrayUpdatesUpdatedAt(): void $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame($expected, $user['created_at']); $this->assertSame($expected, $user['updated_at']); } @@ -208,7 +208,7 @@ public function testAllowDatesInsertArrayWithoutDatesSetsTimestamp(): void $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame($expected, $user['created_at']); $this->assertSame($expected, $user['updated_at']); } @@ -237,7 +237,7 @@ public function testAllowDatesInsertArrayWithDatesSetsTimestamp(): void $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame($expected, $user['created_at']); $this->assertSame($expected, $user['updated_at']); } @@ -261,7 +261,7 @@ public function testAllowDatesUpdateArrayUpdatesUpdatedAt(): void $user = $this->model->find($id); $user['country'] = 'CA'; - $this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound + $this->model->update($user['id'], $user); $user = $this->model->find($id); @@ -271,7 +271,7 @@ public function testAllowDatesUpdateArrayUpdatesUpdatedAt(): void $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound + $this->assertSame($expected, $user['created_at']); $this->assertSame($expected, $user['updated_at']); } diff --git a/utils/phpstan-baseline/argument.type.neon b/utils/phpstan-baseline/argument.type.neon index 9697915545a3..65d03b5b278d 100644 --- a/utils/phpstan-baseline/argument.type.neon +++ b/utils/phpstan-baseline/argument.type.neon @@ -1,4 +1,4 @@ -# total 78 errors +# total 76 errors parameters: ignoreErrors: @@ -177,21 +177,11 @@ parameters: count: 1 path: ../../tests/system/Log/Handlers/ChromeLoggerHandlerTest.php - - - message: '#^Parameter \#1 \$row of method CodeIgniter\\BaseModel\:\:save\(\) expects array\\|object, array\\> given\.$#' - count: 1 - path: ../../tests/system/Models/DataConverterModelTest.php - - message: '#^Parameter \#1 \$row of method CodeIgniter\\Model\:\:insert\(\) expects array\\|object\|null, array\\|string\> given\.$#' count: 3 path: ../../tests/system/Models/DataConverterModelTest.php - - - message: '#^Parameter \#2 \$row of method CodeIgniter\\Model\:\:update\(\) expects array\\|object\|null, array\\> given\.$#' - count: 1 - path: ../../tests/system/Models/DataConverterModelTest.php - - message: '#^Parameter \#1 \$format of method CodeIgniter\\RESTful\\ResourceController\:\:setFormat\(\) expects ''json''\|''xml'', ''Nonsense'' given\.$#' count: 1 diff --git a/utils/phpstan-baseline/codeigniter.getReassignArray.neon b/utils/phpstan-baseline/codeigniter.getReassignArray.neon deleted file mode 100644 index f663c67ee50e..000000000000 --- a/utils/phpstan-baseline/codeigniter.getReassignArray.neon +++ /dev/null @@ -1,18 +0,0 @@ -# total 3 errors - -parameters: - ignoreErrors: - - - message: '#^Re\-assigning arrays to \$_GET directly is discouraged\.$#' - count: 1 - path: ../../tests/system/HTTP/IncomingRequestTest.php - - - - message: '#^Re\-assigning arrays to \$_GET directly is discouraged\.$#' - count: 1 - path: ../../tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php - - - - message: '#^Re\-assigning arrays to \$_GET directly is discouraged\.$#' - count: 1 - path: ../../tests/system/Helpers/FormHelperTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalAccess.neon b/utils/phpstan-baseline/codeigniter.superglobalAccess.neon deleted file mode 100644 index 68f9316f8ee1..000000000000 --- a/utils/phpstan-baseline/codeigniter.superglobalAccess.neon +++ /dev/null @@ -1,123 +0,0 @@ -# total 29 errors - -parameters: - ignoreErrors: - - - message: '#^Accessing offset ''ANSICON'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - - - message: '#^Accessing offset ''NO_COLOR'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - - - message: '#^Accessing offset ''encryption\.key'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/Commands/Encryption/GenerateKey.php - - - - message: '#^Accessing offset ''REMOTE_ADDR'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/Common.php - - - - message: '#^Accessing offset ''REQUEST_METHOD'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/Common.php - - - - message: '#^Accessing offset string directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/Common.php - - - - message: '#^Accessing offset ''CI_ENVIRONMENT'' directly on \$_SERVER is discouraged\.$#' - count: 2 - path: ../../system/Config/AutoloadConfig.php - - - - message: '#^Accessing offset non\-falsy\-string directly on \$_SERVER is discouraged\.$#' - count: 4 - path: ../../system/Config/BaseConfig.php - - - - message: '#^Accessing offset string directly on \$_SERVER is discouraged\.$#' - count: 2 - path: ../../system/Config/DotEnv.php - - - - message: '#^Accessing offset string directly on \$_GET is discouraged\.$#' - count: 1 - path: ../../system/Superglobals.php - - - - message: '#^Accessing offset string directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/Superglobals.php - - - - message: '#^Accessing offset ''foo'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/CommonFunctionsSendTest.php - - - - message: '#^Accessing offset ''foo'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/CommonFunctionsTest.php - - - - message: '#^Accessing offset ''BAR'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Config/DotEnvTest.php - - - - message: '#^Accessing offset ''FOO'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Config/DotEnvTest.php - - - - message: '#^Accessing offset ''NULL'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Config/DotEnvTest.php - - - - message: '#^Accessing offset ''SPACED'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Config/DotEnvTest.php - - - - message: '#^Accessing offset ''SimpleConfig_simple_name'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Config/DotEnvTest.php - - - - message: '#^Accessing offset ''CODEIGNITER_SCREAM_DEPRECATIONS'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionsTest.php - - - - message: '#^Accessing offset ''QUERY_STRING'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php - - - - message: '#^Accessing offset ''CUSTOM_SERVER'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/SuperglobalsTest.php - - - - message: '#^Accessing offset ''TEST_KEY'' directly on \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/SuperglobalsTest.php - - - - message: '#^Accessing offset ''custom_get'' directly on \$_GET is discouraged\.$#' - count: 1 - path: ../../tests/system/SuperglobalsTest.php - - - - message: '#^Accessing offset ''test'' directly on \$_GET is discouraged\.$#' - count: 1 - path: ../../tests/system/SuperglobalsTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon b/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon deleted file mode 100644 index ab0d015d5677..000000000000 --- a/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon +++ /dev/null @@ -1,28 +0,0 @@ -# total 5 errors - -parameters: - ignoreErrors: - - - message: '#^Assigning string directly on offset string of \$_SERVER is discouraged\.$#' - count: 1 - path: ../../system/Config/DotEnv.php - - - - message: '#^Assigning ''1'' directly on offset ''CODEIGNITER_SCREAM_DEPRECATIONS'' of \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionsTest.php - - - - message: '#^Assigning ''test'' directly on offset ''HTTPS'' of \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/HomeTest.php - - - - message: '#^Assigning ''test'' directly on offset ''HTTPS'' of \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Test/FeatureTestAutoRoutingImprovedTest.php - - - - message: '#^Assigning ''test'' directly on offset ''HTTPS'' of \$_SERVER is discouraged\.$#' - count: 1 - path: ../../tests/system/Test/FeatureTestTraitTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalsGlobalAssign.neon b/utils/phpstan-baseline/codeigniter.superglobalsGlobalAssign.neon new file mode 100644 index 000000000000..e34453095d8e --- /dev/null +++ b/utils/phpstan-baseline/codeigniter.superglobalsGlobalAssign.neon @@ -0,0 +1,83 @@ +# total 17 errors + +parameters: + ignoreErrors: + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/BaseConfigTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/ServicesTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 2 + path: ../../tests/system/ControllerTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/Filters/FiltersTest.php + + - + message: '#^Direct global assignment to \$_COOKIE is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/IncomingRequestTest.php + + - + message: '#^Direct global assignment to \$_GET is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/IncomingRequestTest.php + + - + message: '#^Direct global assignment to \$_POST is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/IncomingRequestTest.php + + - + message: '#^Direct global assignment to \$_REQUEST is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/IncomingRequestTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/IncomingRequestTest.php + + - + message: '#^Direct global assignment to \$_GET is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php + + - + message: '#^Direct global assignment to \$_COOKIE is not allowed\.$#' + count: 1 + path: ../../tests/system/Helpers/CookieHelperTest.php + + - + message: '#^Direct global assignment to \$_GET is not allowed\.$#' + count: 1 + path: ../../tests/system/Helpers/FormHelperTest.php + + - + message: '#^Direct global assignment to \$_POST is not allowed\.$#' + count: 1 + path: ../../tests/system/Helpers/FormHelperTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/Helpers/URLHelper/SiteUrlCliTest.php + + - + message: '#^Direct global assignment to \$_SERVER is not allowed\.$#' + count: 1 + path: ../../tests/system/Helpers/URLHelper/SiteUrlTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalsOffsetAccess.neon b/utils/phpstan-baseline/codeigniter.superglobalsOffsetAccess.neon new file mode 100644 index 000000000000..81cec98356ff --- /dev/null +++ b/utils/phpstan-baseline/codeigniter.superglobalsOffsetAccess.neon @@ -0,0 +1,148 @@ +# total 35 errors + +parameters: + ignoreErrors: + - + message: '#^Direct access to \$_SERVER\[''argv''\] is not allowed\.$#' + count: 2 + path: ../../system/Boot.php + + - + message: '#^Direct access to \$_SERVER\[''ANSICON''\] is not allowed\.$#' + count: 1 + path: ../../system/CLI/CLI.php + + - + message: '#^Direct access to \$_SERVER\[''NO_COLOR''\] is not allowed\.$#' + count: 1 + path: ../../system/CLI/CLI.php + + - + message: '#^Direct access to \$_SERVER\[''argv''\] is not allowed\.$#' + count: 1 + path: ../../system/CLI/CLI.php + + - + message: '#^Direct access to \$_SERVER\[''REMOTE_ADDR''\] is not allowed\.$#' + count: 1 + path: ../../system/Common.php + + - + message: '#^Direct access to \$_SERVER\[''REQUEST_METHOD''\] is not allowed\.$#' + count: 1 + path: ../../system/Common.php + + - + message: '#^Direct access to \$_SERVER\[\$key\] is not allowed\.$#' + count: 1 + path: ../../system/Common.php + + - + message: '#^Direct access to \$_SERVER\[''CI_ENVIRONMENT''\] is not allowed\.$#' + count: 2 + path: ../../system/Config/AutoloadConfig.php + + - + message: '#^Direct access to \$_SERVER\["\{\$prefix\}\.\{\$property\}"\] is not allowed\.$#' + count: 1 + path: ../../system/Config/BaseConfig.php + + - + message: '#^Direct access to \$_SERVER\["\{\$prefix\}_\{\$underscoreProperty\}"\] is not allowed\.$#' + count: 1 + path: ../../system/Config/BaseConfig.php + + - + message: '#^Direct access to \$_SERVER\["\{\$shortPrefix\}\.\{\$property\}"\] is not allowed\.$#' + count: 1 + path: ../../system/Config/BaseConfig.php + + - + message: '#^Direct access to \$_SERVER\["\{\$shortPrefix\}_\{\$underscoreProperty\}"\] is not allowed\.$#' + count: 1 + path: ../../system/Config/BaseConfig.php + + - + message: '#^Direct access to \$_COOKIE\[\$this\-\>config\-\>cookieName\] is not allowed\.$#' + count: 5 + path: ../../system/Session/Session.php + + - + message: '#^Direct access to \$_SERVER\[''BAR''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/DotEnvTest.php + + - + message: '#^Direct access to \$_SERVER\[''FOO''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/DotEnvTest.php + + - + message: '#^Direct access to \$_SERVER\[''NULL''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/DotEnvTest.php + + - + message: '#^Direct access to \$_SERVER\[''SPACED''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/DotEnvTest.php + + - + message: '#^Direct access to \$_SERVER\[''SimpleConfig_simple_name''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Config/DotEnvTest.php + + - + message: '#^Direct access to \$_SERVER\[''QUERY_STRING''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php + + - + message: '#^Direct access to \$_COOKIE\[''custom_cookie''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_COOKIE\[''session''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_GET\[''custom_get''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_GET\[''test''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_POST\[''custom_post''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_POST\[''test''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_REQUEST\[''custom_request''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_REQUEST\[''test''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_SERVER\[''CUSTOM_SERVER''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php + + - + message: '#^Direct access to \$_SERVER\[''TEST_KEY''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/SuperglobalsTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon b/utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon new file mode 100644 index 000000000000..9012f8e762f8 --- /dev/null +++ b/utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon @@ -0,0 +1,28 @@ +# total 5 errors + +parameters: + ignoreErrors: + - + message: '#^Direct assignment of string\|null to \$_COOKIE\[''csrf_cookie_name''\] is not allowed\.$#' + count: 1 + path: ../../system/Test/Mock/MockSecurity.php + + - + message: '#^Direct assignment of ''1'' to \$_SERVER\[''CODEIGNITER_SCREAM_DEPRECATIONS''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Debug/ExceptionsTest.php + + - + message: '#^Direct assignment of ''test'' to \$_SERVER\[''HTTPS''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/HomeTest.php + + - + message: '#^Direct assignment of ''test'' to \$_SERVER\[''HTTPS''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Test/FeatureTestAutoRoutingImprovedTest.php + + - + message: '#^Direct assignment of ''test'' to \$_SERVER\[''HTTPS''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Test/FeatureTestTraitTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon b/utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon new file mode 100644 index 000000000000..bbdc3228eb79 --- /dev/null +++ b/utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon @@ -0,0 +1,33 @@ +# total 7 errors + +parameters: + ignoreErrors: + - + message: '#^Direct unset of \$_SERVER\[''encryption\.key''\] is not allowed\.$#' + count: 1 + path: ../../system/Commands/Encryption/GenerateKey.php + + - + message: '#^Direct unset of \$_COOKIE\[\$this\-\>config\-\>cookieName\] is not allowed\.$#' + count: 1 + path: ../../system/Session/Session.php + + - + message: '#^Direct unset of \$_SERVER\[''foo''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/CommonFunctionsSendTest.php + + - + message: '#^Direct unset of \$_SERVER\[''foo''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/CommonFunctionsTest.php + + - + message: '#^Direct unset of \$_SERVER\[''encryption\.key''\] is not allowed\.$#' + count: 2 + path: ../../tests/system/Config/DotEnvTest.php + + - + message: '#^Direct unset of \$_SERVER\[''CODEIGNITER_SCREAM_DEPRECATIONS''\] is not allowed\.$#' + count: 1 + path: ../../tests/system/Debug/ExceptionsTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 405c9a54ac16..d464ba204c47 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,13 +1,14 @@ -# total 2012 errors +# total 2035 errors includes: - argument.type.neon - arguments.count.neon - assign.propertyType.neon - - codeigniter.getReassignArray.neon - codeigniter.modelArgumentType.neon - - codeigniter.superglobalAccess.neon - - codeigniter.superglobalAccessAssign.neon + - codeigniter.superglobalsGlobalAssign.neon + - codeigniter.superglobalsOffsetAccess.neon + - codeigniter.superglobalsOffsetAssign.neon + - codeigniter.superglobalsOffsetUnset.neon - deadCode.unreachable.neon - empty.notAllowed.neon - function.resultUnused.neon diff --git a/utils/phpstan-baseline/property.nonObject.neon b/utils/phpstan-baseline/property.nonObject.neon index 33d6299465f8..26e874602857 100644 --- a/utils/phpstan-baseline/property.nonObject.neon +++ b/utils/phpstan-baseline/property.nonObject.neon @@ -28,57 +28,57 @@ parameters: path: ../../tests/system/Database/Live/GetTest.php - - message: '#^Cannot access property \$id on array\.$#' + message: '#^Cannot access property \$id on array\\.$#' count: 2 path: ../../tests/system/Models/FindModelTest.php - - message: '#^Cannot access property \$created_at on array\.$#' + message: '#^Cannot access property \$created_at on array\\.$#' count: 3 path: ../../tests/system/Models/InsertModelTest.php - - message: '#^Cannot access property \$created_at on array\.$#' + message: '#^Cannot access property \$created_at on array\\.$#' count: 1 path: ../../tests/system/Models/MiscellaneousModelTest.php - - message: '#^Cannot access property \$description on array\.$#' + message: '#^Cannot access property \$description on array\\.$#' count: 1 path: ../../tests/system/Models/SaveModelTest.php - - message: '#^Cannot access property \$country on array\.$#' + message: '#^Cannot access property \$country on array\\.$#' count: 2 path: ../../tests/system/Models/TimestampModelTest.php - - message: '#^Cannot access property \$created_at on array\.$#' + message: '#^Cannot access property \$created_at on array\\.$#' count: 2 path: ../../tests/system/Models/TimestampModelTest.php - - message: '#^Cannot access property \$id on array\.$#' + message: '#^Cannot access property \$id on array\\.$#' count: 2 path: ../../tests/system/Models/TimestampModelTest.php - - message: '#^Cannot access property \$updated_at on array\.$#' + message: '#^Cannot access property \$updated_at on array\\.$#' count: 2 path: ../../tests/system/Models/TimestampModelTest.php - - message: '#^Cannot access property \$value on list\\.$#' + message: '#^Cannot access property \$value on array\\|string, mixed\>\.$#' count: 1 path: ../../tests/system/Models/UpdateModelTest.php - - message: '#^Cannot access property \$key on array\.$#' + message: '#^Cannot access property \$key on array\\.$#' count: 7 path: ../../tests/system/Models/WhenWhenNotModelTest.php - - message: '#^Cannot access property \$value on array\.$#' + message: '#^Cannot access property \$value on array\\.$#' count: 1 path: ../../tests/system/Models/WhenWhenNotModelTest.php