Skip to content

Commit

Permalink
Merge pull request #1 from newsuk/chore/CPNT-2251-phpstan-config
Browse files Browse the repository at this point in the history
chore(CPNT-2251): PHPStan config
  • Loading branch information
mohanrajpac authored Jan 15, 2024
2 parents 1718793 + ac957b1 commit a31a725
Show file tree
Hide file tree
Showing 8 changed files with 569 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .circleci/config.yml
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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @newsuk/tnl-wp-newspress
37 changes: 36 additions & 1 deletion README.md
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"
```
25 changes: 25 additions & 0 deletions composer.json
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
}
}
}
Loading

0 comments on commit a31a725

Please sign in to comment.