-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from newsuk/chore/CPNT-2251-phpstan-config
chore(CPNT-2251): PHPStan config
- Loading branch information
Showing
8 changed files
with
569 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: 2.1 | ||
jobs: | ||
php-codescan: | ||
docker: | ||
- image: cimg/php:8.2-node | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install production dependencies | ||
command: composer install --no-dev -o | ||
- run: | ||
name: Composer validate | ||
command: composer validate --strict | ||
- run: | ||
name: PHPStan codescan install check | ||
command: | | ||
vendor/bin/phpstan --version | ||
if vendor/bin/phpstan --version | grep -q "PHP Static Analysis Tool"; then | ||
echo "PHPStan installed successfully." | ||
else | ||
echo "Error: PHPStan is not installed." | ||
exit 1 | ||
fi | ||
- persist_to_workspace: | ||
root: . | ||
paths: | ||
- vendor | ||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
- php-codescan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "composer" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @newsuk/tnl-wp-newspress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,36 @@ | ||
# nuk-wp-phpstan-config | ||
### NUK WP PHPStan config | ||
|
||
This library contains PHPStan configuration for NewsUK plugins and themes. | ||
|
||
## Installation | ||
|
||
Composer install: | ||
|
||
```bash | ||
composer require --dev newsuk/nuk-wp-phpstan-config | ||
``` | ||
|
||
## Using the ruleset | ||
Create a `phpstan.neon.dist` file in the root of your project and add the below config. Feel free to alter the `paths` based on your project requirements | ||
|
||
```yml | ||
parameters: | ||
level: max | ||
paths: | ||
# adjust the filename / directory name according to project needs. | ||
- plugin.php | ||
- includes/ | ||
``` | ||
## Composer scripts | ||
Add the following to `scripts` section in `composer.json` file and run `composer phpstan` | ||
|
||
```json | ||
"phpstan": "phpstan analyse --memory-limit=2048M" | ||
``` | ||
Add the following to generate baseline file for existing plugins and run `composer phpstan-baseline` | ||
|
||
```json | ||
"phpstan-baseline": "phpstan analyse -b --allow-empty-baseline" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "newsuk/nuk-wp-phpstan-config", | ||
"description": "PHPStan configuration for WordPress VIP plugins and themes", | ||
"type": "phpstan-extension", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Content Platforms", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"szepeviktor/phpstan-wordpress": "^1.3", | ||
"phpstan/extension-installer": "^1.3", | ||
"swissspidy/phpstan-no-private": "^0.2.0", | ||
"phpstan/phpstan-deprecation-rules": "^1.1", | ||
"phpstan/phpstan-strict-rules": "^1.5", | ||
"php": ">=7.4" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"phpstan/extension-installer": true | ||
} | ||
} | ||
} |
Oops, something went wrong.