From 9c8c8e9d16dd3563b0fe662b45298e9a12ad03ef Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 16 Nov 2024 16:04:32 +0530 Subject: [PATCH] Fix errors reported by phpstan --- .gitattributes | 1 + .github/workflows/ci.yml | 34 ++++----------------------- .phive/phars.xml | 5 ++++ phpstan.neon | 4 +++- src/Command/InstallCommand.php | 2 +- src/View/Helper/OptionsAwareTrait.php | 4 +--- 6 files changed, 16 insertions(+), 34 deletions(-) create mode 100644 .phive/phars.xml diff --git a/.gitattributes b/.gitattributes index 1fa4f435..583c8faf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,3 +9,4 @@ tests export-ignore .github export-ignore phpstan.neon export-ignore psalm.xml export-ignore +.phive export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40117ba5..6a3006b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,34 +13,10 @@ permissions: jobs: testsuite: - uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@5.x - secrets: inherit + uses: ADmad/.github/workflows/testsuite-with-db.yml@5.x + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} cs-stan: - name: Coding Standard & Static Analysis - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: mbstring, intl - coverage: none - tools: cs2pr, vimeo/psalm:5, phpstan:1.10 - - - name: Composer Install - run: composer install - - - name: Run phpcs - run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr - - - name: Run psalm - if: always() - run: psalm --output-format=github - - - name: Run phpstan - if: always() - run: phpstan analyse + uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x + secrets: inherit diff --git a/.phive/phars.xml b/.phive/phars.xml new file mode 100644 index 00000000..d311bfa5 --- /dev/null +++ b/.phive/phars.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/phpstan.neon b/phpstan.neon index 05039f8c..e6aa6bea 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,9 @@ parameters: level: 8 - checkMissingIterableValueType: false bootstrapFiles: - tests/bootstrap.php paths: - src/ + ignoreErrors: + - + identifier: missingType.iterableValue diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index c07f2471..e8c5a5ad 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -59,7 +59,7 @@ public function installPackages(Arguments $args, ConsoleIo $io): void $output = []; $return = 0; $this->_runNPMInstall($output, $return, $io, $args->getOption('latest') === true); - $io->out($output); + $io->out($output); // @phpstan-ignore argument.type if ($return !== 0) { $io->error('Package installation failed.'); diff --git a/src/View/Helper/OptionsAwareTrait.php b/src/View/Helper/OptionsAwareTrait.php index 8aa771e2..941e8bc0 100644 --- a/src/View/Helper/OptionsAwareTrait.php +++ b/src/View/Helper/OptionsAwareTrait.php @@ -119,9 +119,7 @@ public function removeClasses(array|string $classes, array $options): array foreach ($classes as $class) { $indices = array_keys($options['class'], $class); foreach ($indices as $index) { - if ($index !== false) { - unset($options['class'][$index]); - } + unset($options['class'][$index]); } }