Skip to content

Commit da40b50

Browse files
committed
refactor: bump to phpstan-codeigniter v2.1
1 parent b08160c commit da40b50

50 files changed

Lines changed: 183 additions & 411 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ structarmed.php export-ignore
2626
phpmetrics.json export-ignore
2727
phpstan-baseline.php export-ignore
2828
phpstan-bootstrap.php export-ignore
29-
phpstan.neon.dist export-ignore
29+
phpstan.dist.neon export-ignore
3030
phpunit.dist.xml export-ignore
3131
psalm-baseline.xml export-ignore
3232
psalm.xml export-ignore

.github/workflows/test-phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- 'tests/**.php'
1414
- 'utils/**.php'
1515
- composer.json
16-
- phpstan.neon.dist
16+
- phpstan.dist.neon
1717
- phpstan-baseline.php
1818
- '.github/workflows/test-phpstan.yml'
1919

@@ -27,7 +27,7 @@ on:
2727
- 'tests/**.php'
2828
- 'utils/**.php'
2929
- composer.json
30-
- phpstan.neon.dist
30+
- phpstan.dist.neon
3131
- phpstan-baseline.php
3232
- '.github/workflows/test-phpstan.yml'
3333

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require-dev": {
2020
"boundwize/structarmed": "0.13.4",
21-
"codeigniter/phpstan-codeigniter": "^1.5",
21+
"codeigniter/phpstan-codeigniter": "^2.1",
2222
"fakerphp/faker": "^1.24",
2323
"kint-php/kint": "^6.1",
2424
"mikey179/vfsstream": "^1.6.12",

phpstan-bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
// Analyse under the testing environment so the Tests\Support namespace is
4+
// registered and its migrations are discovered for schema introspection.
5+
$_SERVER['CI_ENVIRONMENT'] = 'testing';
6+
37
require __DIR__ . '/system/util_bootstrap.php';
48

59
defined('OCI_COMMIT_ON_SUCCESS') || define('OCI_COMMIT_ON_SUCCESS', 32);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ parameters:
4747
additionalModelNamespaces:
4848
- Tests\Support\Models
4949
checkArgumentTypeOfModel: false
50+
schemaCacheDirectory: build/schema-cache
5051
shipmonkBaselinePerIdentifier:
5152
directory: %currentWorkingDirectory%

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
__DIR__ . '/phpstan-bootstrap.php',
7878
])
7979
->withPHPStanConfigs([
80-
__DIR__ . '/phpstan.neon.dist',
80+
__DIR__ . '/phpstan.dist.neon',
8181
__DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon',
8282
__DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
8383
__DIR__ . '/vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon',

system/BaseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* - process various callbacks
5050
* - allow intermingling calls to the db connection
5151
*
52-
* @phpstan-type row_array array<int|string, float|int|null|object|string|bool>
52+
* @phpstan-type row_array array<array-key, mixed>
5353
* @phpstan-type event_data_beforeinsert array{data: row_array}
5454
* @phpstan-type event_data_afterinsert array{id: int|string, data: row_array, result: bool}
5555
* @phpstan-type event_data_beforefind array{id?: int|string, method: string, singleton: bool, limit?: int, offset?: int}

system/Boot.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,11 @@ protected static function initializeConsole(): Console
426426
{
427427
$console = new Console();
428428

429+
$args = service('superglobals')->server('argv', []);
430+
429431
// Show basic information before we do anything else.
430-
if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) {
431-
unset($_SERVER['argv'][$suppress]);
432+
if (is_int($suppress = array_search('--no-header', $args, true))) {
433+
unset($args[$suppress]);
432434
$suppress = true;
433435
}
434436

system/CLI/CLI.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,9 @@ public static function streamSupports(string $function, $resource): bool
707707
public static function hasColorSupport($resource): bool
708708
{
709709
// Follow https://no-color.org/
710-
if (isset($_SERVER['NO_COLOR']) || getenv('NO_COLOR') !== false) {
710+
$noColor = service('superglobals')->server('NO_COLOR');
711+
712+
if (isset($noColor) || getenv('NO_COLOR') !== false) {
711713
return false;
712714
}
713715

@@ -716,9 +718,11 @@ public static function hasColorSupport($resource): bool
716718
}
717719

718720
if (is_windows()) {
721+
$ansicon = service('superglobals')->server('ANSICON');
722+
719723
// @codeCoverageIgnoreStart
720724
return static::streamSupports('sapi_windows_vt100_support', $resource)
721-
|| isset($_SERVER['ANSICON'])
725+
|| isset($ansicon)
722726
|| getenv('ANSICON') !== false
723727
|| getenv('ConEmuANSI') === 'ON'
724728
|| getenv('TERM') === 'xterm';
@@ -887,7 +891,7 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft =
887891
*/
888892
protected static function parseCommandLine()
889893
{
890-
$args = $_SERVER['argv'] ?? [];
894+
$args = service('superglobals')->server('argv') ?? [];
891895
array_shift($args); // scrap invoking program
892896
$optionValue = false;
893897

system/Commands/Encryption/GenerateKey.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public function run(array $params)
101101

102102
// force DotEnv to reload the new env vars
103103
putenv('encryption.key');
104-
unset($_ENV['encryption.key'], $_SERVER['encryption.key']);
104+
unset($_ENV['encryption.key']);
105+
service('superglobals')->unsetServer('encryption.key');
105106
$dotenv = new DotEnv((new Paths())->envDirectory ?? ROOTPATH); // @phpstan-ignore nullCoalesce.property
106107
$dotenv->load();
107108

0 commit comments

Comments
 (0)