diff --git a/.github/workflows/quality-assurance.yaml b/.github/workflows/quality-assurance.yaml new file mode 100644 index 0000000..a9c5aaf --- /dev/null +++ b/.github/workflows/quality-assurance.yaml @@ -0,0 +1,35 @@ +name: Quality Assurance + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +env: + APP_ENV: test + PHP_EXTENSIONS: mbstring, bcmath, sqlite3, gd, intl + +jobs: + coding-standards: + name: "Coding Standards" + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: [ 'ubuntu-latest' ] + php-versions: [ '7.4', '8.0' ] + steps: + - name: "Install PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.PHP_EXTENSIONS }} + + - name: "Checkout" + uses: actions/checkout@v2 + + - name: "Composer Install" + run: composer install --no-interaction --no-progress --no-suggest + + - name: "Easy coding standard" + run: ./vendor/bin/ecs check ./src diff --git a/composer.json b/composer.json index e1fb47c..0fe35d4 100644 --- a/composer.json +++ b/composer.json @@ -10,14 +10,17 @@ } ], "require": { - "php": "^7.4" + "php": ">=7.4 || 8.0" }, "require-dev": { "antiseptikk/dev-kit": "^1.0", "phpcompatibility/phpcompatibility-wp": "^2.1.0", "phpunit/phpunit": "^7.3.0", "brain/monkey": "^2.2.0", - "giacocorsiglia/wordpress-stubs": "^4.9.5" + "giacocorsiglia/wordpress-stubs": "^4.9.5", + "szepeviktor/phpstan-wordpress": "^0.7.4", + "humanmade/psalm-plugin-wordpress": "^2.0", + "php-stubs/wordpress-stubs": "^5.7" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..6921f00 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,9 @@ +includes: + - vendor/szepeviktor/phpstan-wordpress/extension.neon + +parameters: + level: 5 + paths: + - plugin.php + - uninstall.php + - src/ diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..74c131d --- /dev/null +++ b/psalm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Encore.php b/src/Encore.php index e401c4d..7bf59ee 100644 --- a/src/Encore.php +++ b/src/Encore.php @@ -33,7 +33,7 @@ class Encore */ private string $rootUrl = ''; - public function __construct($outputPath, $version, $url, $themePath = null) + public function __construct(string $outputPath, string $version, string $url, ?string $themePath = null) { $this->outputPath = $outputPath; $this->version = $version;