From 5b9feceff6ea6220d5cb868751a221b708ad3b8a Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Fri, 26 Jul 2024 12:04:01 +0200 Subject: [PATCH] Chore: Update phpcs and phpstan config --- .github/workflows/phpcs_activity.yml | 8 +++++--- .github/workflows/phpcs_entity.yml | 8 +++++--- .github/workflows/phpstan_activity.yml | 12 +++++++++--- .github/workflows/phpstan_entity.yml | 12 +++++++++--- modules/civiremote_activity/composer.json | 3 ++- modules/civiremote_activity/phpcs.xml.dist | 2 -- modules/civiremote_activity/phpstan.ci.neon | 2 -- modules/civiremote_activity/phpstan.neon.dist | 2 -- modules/civiremote_activity/phpstan.neon.template | 9 +++++++++ modules/civiremote_entity/composer.json | 3 ++- modules/civiremote_entity/phpcs.xml.dist | 5 +++-- modules/civiremote_entity/phpstan.ci.neon | 2 -- modules/civiremote_entity/phpstan.neon.dist | 3 --- modules/civiremote_entity/phpstan.neon.template | 9 +++++++++ .../src/Form/AbstractEntityForm.php | 3 ++- 15 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 modules/civiremote_activity/phpstan.neon.template create mode 100644 modules/civiremote_entity/phpstan.neon.template diff --git a/.github/workflows/phpcs_activity.yml b/.github/workflows/phpcs_activity.yml index 5e9a7d0..cb69df2 100644 --- a/.github/workflows/phpcs_activity.yml +++ b/.github/workflows/phpcs_activity.yml @@ -1,9 +1,11 @@ name: PHP_CodeSniffer - civiremote_activity on: - push: ~ pull_request: - branches: [ main ] + paths: + - 'modules/civiremote_activity/src/**.php' + - modules/civiremote_activity/composer.json + - modules/civiremote_activity/phpcs.xml.dist jobs: phpcs: @@ -19,7 +21,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none tools: cs2pr env: diff --git a/.github/workflows/phpcs_entity.yml b/.github/workflows/phpcs_entity.yml index 273de8d..5df7a25 100644 --- a/.github/workflows/phpcs_entity.yml +++ b/.github/workflows/phpcs_entity.yml @@ -1,9 +1,11 @@ name: PHP_CodeSniffer - civiremote_entity on: - push: ~ pull_request: - branches: [ main ] + paths: + - 'modules/civiremote_entity/src/**.php' + - modules/civiremote_entity/composer.json + - modules/civiremote_entity/phpcs.xml.dist jobs: phpcs: @@ -19,7 +21,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 coverage: none tools: cs2pr env: diff --git a/.github/workflows/phpstan_activity.yml b/.github/workflows/phpstan_activity.yml index eb0d116..64ed057 100644 --- a/.github/workflows/phpstan_activity.yml +++ b/.github/workflows/phpstan_activity.yml @@ -1,16 +1,22 @@ name: PHPStan - civiremote_activity on: - push: ~ pull_request: - branches: [ main ] + paths: + - 'modules/civiremote_activity/src/**.php' + - modules/civiremote_activity/composer.json + - modules/civiremote_activity/tools/phpstan/composer.json + - modules/civiremote_activity/ci/composer.json + - modules/civiremote_activity/phpstan.ci.neon + - modules/civiremote_activity/phpstan.neon.dist + - 'modules/civiremote_entity/src/**.php' jobs: phpstan: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.4', '8.0', '8.2'] + php-versions: ['7.4', '8.0', '8.3'] prefer: ['prefer-stable', 'prefer-lowest'] name: PHPStan with PHP ${{ matrix.php-versions }} ${{ matrix.prefer }} defaults: diff --git a/.github/workflows/phpstan_entity.yml b/.github/workflows/phpstan_entity.yml index 7679006..4ed7037 100644 --- a/.github/workflows/phpstan_entity.yml +++ b/.github/workflows/phpstan_entity.yml @@ -1,16 +1,22 @@ name: PHPStan - civiremote_entity on: - push: ~ pull_request: - branches: [ main ] + paths: + - 'modules/civiremote_entity/src/**.php' + - modules/civiremote_entity/composer.json + - modules/civiremote_entity/tools/phpstan/composer.json + - modules/civiremote_entity/ci/composer.json + - modules/civiremote_entity/phpstan.ci.neon + - modules/civiremote_entity/phpstan.neon.dist + - 'src/**.php' jobs: phpstan: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.4', '8.0', '8.2'] + php-versions: ['7.4', '8.0', '8.3'] prefer: ['prefer-stable', 'prefer-lowest'] name: PHPStan with PHP ${{ matrix.php-versions }} ${{ matrix.prefer }} defaults: diff --git a/modules/civiremote_activity/composer.json b/modules/civiremote_activity/composer.json index f701f6b..4acc1ba 100644 --- a/modules/civiremote_activity/composer.json +++ b/modules/civiremote_activity/composer.json @@ -25,7 +25,8 @@ "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "php-http/discovery": false } }, "repositories": [ diff --git a/modules/civiremote_activity/phpcs.xml.dist b/modules/civiremote_activity/phpcs.xml.dist index 64633e5..e77d39d 100644 --- a/modules/civiremote_activity/phpcs.xml.dist +++ b/modules/civiremote_activity/phpcs.xml.dist @@ -3,8 +3,6 @@ xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> src - - diff --git a/modules/civiremote_activity/phpstan.ci.neon b/modules/civiremote_activity/phpstan.ci.neon index d051f46..30083ea 100644 --- a/modules/civiremote_activity/phpstan.ci.neon +++ b/modules/civiremote_activity/phpstan.ci.neon @@ -4,5 +4,3 @@ includes: parameters: bootstrapFiles: - ci/vendor/autoload.php - scanFiles: - - ci/vendor/drupal/core/tests/Drupal/Tests/UnitTestCase.php diff --git a/modules/civiremote_activity/phpstan.neon.dist b/modules/civiremote_activity/phpstan.neon.dist index 4344a63..0a9b98d 100644 --- a/modules/civiremote_activity/phpstan.neon.dist +++ b/modules/civiremote_activity/phpstan.neon.dist @@ -1,8 +1,6 @@ parameters: paths: - src - #- tests - #- civiremote_activity.module bootstrapFiles: - vendor/autoload.php scanDirectories: diff --git a/modules/civiremote_activity/phpstan.neon.template b/modules/civiremote_activity/phpstan.neon.template new file mode 100644 index 0000000..60ce96d --- /dev/null +++ b/modules/civiremote_activity/phpstan.neon.template @@ -0,0 +1,9 @@ +# Copy this file to phpstan.neon and replace {VENDOR_DIR} with the vendor +# directory of your Drupal project. + +includes: + - phpstan.neon.dist + +parameters: + bootstrapFiles: + - {VENDOR_DIR}/autoload.php diff --git a/modules/civiremote_entity/composer.json b/modules/civiremote_entity/composer.json index 9031a0a..a7bd57f 100644 --- a/modules/civiremote_entity/composer.json +++ b/modules/civiremote_entity/composer.json @@ -25,7 +25,8 @@ "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "php-http/discovery": false } }, "repositories": [ diff --git a/modules/civiremote_entity/phpcs.xml.dist b/modules/civiremote_entity/phpcs.xml.dist index 40ce349..0e4b1e5 100644 --- a/modules/civiremote_entity/phpcs.xml.dist +++ b/modules/civiremote_entity/phpcs.xml.dist @@ -3,8 +3,6 @@ xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> src - - @@ -15,6 +13,9 @@ + + + diff --git a/modules/civiremote_entity/phpstan.ci.neon b/modules/civiremote_entity/phpstan.ci.neon index d051f46..30083ea 100644 --- a/modules/civiremote_entity/phpstan.ci.neon +++ b/modules/civiremote_entity/phpstan.ci.neon @@ -4,5 +4,3 @@ includes: parameters: bootstrapFiles: - ci/vendor/autoload.php - scanFiles: - - ci/vendor/drupal/core/tests/Drupal/Tests/UnitTestCase.php diff --git a/modules/civiremote_entity/phpstan.neon.dist b/modules/civiremote_entity/phpstan.neon.dist index 84c7638..5abd8e3 100644 --- a/modules/civiremote_entity/phpstan.neon.dist +++ b/modules/civiremote_entity/phpstan.neon.dist @@ -1,8 +1,6 @@ parameters: paths: - src - #- tests - #- civiremote_entity.module bootstrapFiles: - vendor/autoload.php scanDirectories: @@ -22,7 +20,6 @@ parameters: ignoreErrors: # Note paths are prefixed with ""*/" to work with inspections in PHPStorm because of: # https://youtrack.jetbrains.com/issue/WI-63891/PHPStan-ignoreErrors-configuration-isnt-working-with-inspections - - '/^Parameter #1 \$form \(array\) of method [^\s]+::(build|validate|submit)Form\(\) should be contravariant with parameter \$form \(array\) of method Drupal\\Core\\Form\\(FormInterface|FormBase)::(build|validate|submit)Form\(\)$/' - message: '/^Parameter #1 \$value of static method Drupal\\civiremote_entity\\Api\\[^:]+::fromApiResultValue\(\) expects array\{.+\}, array given.$/' path: */Api/AbstractEntityApi.php diff --git a/modules/civiremote_entity/phpstan.neon.template b/modules/civiremote_entity/phpstan.neon.template new file mode 100644 index 0000000..60ce96d --- /dev/null +++ b/modules/civiremote_entity/phpstan.neon.template @@ -0,0 +1,9 @@ +# Copy this file to phpstan.neon and replace {VENDOR_DIR} with the vendor +# directory of your Drupal project. + +includes: + - phpstan.neon.dist + +parameters: + bootstrapFiles: + - {VENDOR_DIR}/autoload.php diff --git a/modules/civiremote_entity/src/Form/AbstractEntityForm.php b/modules/civiremote_entity/src/Form/AbstractEntityForm.php index 85eaeb5..93b810a 100644 --- a/modules/civiremote_entity/src/Form/AbstractEntityForm.php +++ b/modules/civiremote_entity/src/Form/AbstractEntityForm.php @@ -39,7 +39,8 @@ abstract class AbstractEntityForm extends AbstractJsonFormsForm { protected FormResponseHandlerInterface $formResponseHandler; - public function __construct(FormArrayFactoryInterface $formArrayFactory, + public function __construct( + FormArrayFactoryInterface $formArrayFactory, FormValidatorInterface $formValidator, FormValidationMapperInterface $formValidationMapper, FormRequestHandlerInterface $formRequestHandler,