Skip to content

Commit

Permalink
PES-2371: PHPstan - Packetery/Module lvl 2 and Packetery/Core strict …
Browse files Browse the repository at this point in the history
…rules (#647)

* PES-2325: Move phpstan from its own composer to main composer

* PES-2325: Change phpstan bootstrap path in unit tests

* PES-2325: Remove composer from phpstan folder, we don't need it anymore

* PES-2325: Remove phpstan/vendor from .gitignore, its unnecessary

* PES-2325: Change path to woocommerce stubs in phpstan config

* PES-2325: Split phpstan configurations so we can check different levels for different folders

* PES-2325: Fix phpstan errors in Packetery/Module on level 1

* PES-2325: Fix phpstan errors in Packetery/Module on level 2

* PES-2325: Set level 2 for Packetery/Module directory

* PES-2325: Add phpstan/phpstan-strict-rules

* PES-2325: Fix phpstan error in Packetery/Core with strict rules

* PES-2325: Add phpstan strict rules in config for Packetery/Core and disable for Packetery/Module

* PES-2325: Remove phpstan/vendor from .ecrc

* PES-2325: PHPStan composer from github action

* PES-2325: Update PHPStan newer version

* PES-2325: Add phpstan var type for array
- For some reason this array without var type causes a performance issue when checking phpstan

* PES-2325: Add src/Packetery/Core scan directory

* PES-2325: Update .lock

* PES-2371: Add latest woocommerce stubs

* PES-2371: PHPStan doesnt need to scan deps and bootstrap files for Packetery/Core

* PES-2371: More readable code in the isPacketaShippingMethodActive method

* PES-2371: Use constant instead string

* PES-2371: Shortened if isset notation

* PES-2371: Revert the changes to the dashboard widget to avoid unnecessarily altering the logic when it's not needed, while still satisfying PHPStan

* PES-2371: Removing unnecessary variable

* PES-2371: Nicer formating function setStoredUntil

* PES-2371: Use of shorthand if statements instead longer

---------

Co-authored-by: Adam Karpita <adam.karpita@packeta.com>
  • Loading branch information
Adam Karpita and Karpec authored Nov 18, 2024
1 parent 2d5e500 commit 95854e2
Show file tree
Hide file tree
Showing 53 changed files with 516 additions and 515 deletions.
1 change: 0 additions & 1 deletion .ecrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"^.git\/",
"^deps\/",
"^tests-coverage\/",
"^phpstan\/vendor\/",
"^public\/libs\/",
"^public\/block\/index.asset.php",
"^public\/block\/index.js",
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/run-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
run: php -v

- name: Install Composer dependencies
working-directory: phpstan
run: composer install

- name: Run PHPStan with php version 7.2
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/run-phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ jobs:
- name: Install Composer dependencies
run: composer install

- name: Install Composer dev dependencies
working-directory: phpstan
run: composer install

- name: Run PHPUnit
run: composer run tests-unit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/.idea/
/vendor
/phpcs/vendor
/phpstan/vendor
/temp/*
!/temp/.gitignore
/log/
Expand Down
53 changes: 44 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
"composer/composer": "^2.6",
"wpify/scoper": "3.2.13",
"phpunit/phpunit": "10.4.2",
"php-stubs/woocommerce-stubs": "^9.1",
"php-stubs/woocommerce-stubs": "^9.3",
"editorconfig-checker/editorconfig-checker": "^10.6",
"slevomat/coding-standard": "^8.15",
"wp-cli/wp-cli-bundle": "^2.11"
"wp-cli/wp-cli-bundle": "^2.11",
"phpstan/extension-installer": "^1.4",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/phpstan-strict-rules": "^1.6",
"phpstan/phpstan": "^1.2"
},
"scripts": {
"build:deps": "bash build-deps.sh",
Expand All @@ -19,12 +23,42 @@
"wpify-scoper": "wpify-scoper",
"check:phpcs": "vendor/bin/phpcs",
"fix:phpcbf": "vendor/bin/phpcbf",
"phpstan:php72": "phpstan/vendor/bin/phpstan -cphpstan/php72.neon analyse",
"phpstan:php74": "phpstan/vendor/bin/phpstan -cphpstan/php74.neon analyse",
"phpstan:php80": "phpstan/vendor/bin/phpstan -cphpstan/php80.neon analyse",
"phpstan:php81": "phpstan/vendor/bin/phpstan -cphpstan/php81.neon analyse",
"phpstan:php82": "phpstan/vendor/bin/phpstan -cphpstan/php82.neon analyse",
"phpstan:php83": "phpstan/vendor/bin/phpstan -cphpstan/php83.neon analyse",
"phpstan:php72": [
"@phpstan:php72-core",
"@phpstan:php72-module"
],
"phpstan:php74": [
"@phpstan:php74-core",
"@phpstan:php74-module"
],
"phpstan:php80": [
"@phpstan:php80-core",
"@phpstan:php80-module"
],
"phpstan:php81": [
"@phpstan:php81-core",
"@phpstan:php81-module"
],
"phpstan:php82": [
"@phpstan:php82-core",
"@phpstan:php82-module"
],
"phpstan:php83": [
"@phpstan:php83-core",
"@phpstan:php83-module"
],
"phpstan:php72-core": "phpstan analyse -c phpstan/php72-core.neon",
"phpstan:php74-core": "phpstan analyse -c phpstan/php74-core.neon",
"phpstan:php80-core": "phpstan analyse -c phpstan/php80-core.neon",
"phpstan:php81-core": "phpstan analyse -c phpstan/php81-core.neon",
"phpstan:php82-core": "phpstan analyse -c phpstan/php82-core.neon",
"phpstan:php83-core": "phpstan analyse -c phpstan/php83-core.neon",
"phpstan:php72-module": "phpstan analyse -c phpstan/php72-module.neon --memory-limit 2G",
"phpstan:php74-module": "phpstan analyse -c phpstan/php74-module.neon --memory-limit 2G",
"phpstan:php80-module": "phpstan analyse -c phpstan/php80-module.neon --memory-limit 2G",
"phpstan:php81-module": "phpstan analyse -c phpstan/php81-module.neon --memory-limit 2G",
"phpstan:php82-module": "phpstan analyse -c phpstan/php82-module.neon --memory-limit 2G",
"phpstan:php83-module": "phpstan analyse -c phpstan/php83-module.neon --memory-limit 2G",
"tests-unit": "vendor/bin/phpunit tests",
"tests-coverage": "export XDEBUG_MODE=coverage && php -d memory_limit=200M ./vendor/bin/phpunit tests --coverage-html ./tests-coverage",
"check:all": [
Expand All @@ -45,7 +79,8 @@
},
"allow-plugins": {
"wpify/scoper": true,
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"autoload": {
Expand Down
220 changes: 219 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions phpstan/base.neon
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
parameters:
bootstrapFiles:
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
- vendor/php-stubs/woocommerce-stubs/woocommerce-packages-stubs.php
- ../constants.php
level: 8
fileExtensions:
- php
paths:
- ../src/Packetery/Core
scanDirectories:
- ../deps
- ../src/Packetery/Module
15 changes: 0 additions & 15 deletions phpstan/composer.json

This file was deleted.

Loading

0 comments on commit 95854e2

Please sign in to comment.