Skip to content

Commit 3615846

Browse files
authored
Update doc (#1)
1 parent fd3b1b4 commit 3615846

File tree

5 files changed

+78
-27
lines changed

5 files changed

+78
-27
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ updates:
88
labels:
99
- "RFR"
1010
- "dependencies"
11+
- package-ecosystem: github-actions
12+
directory: "/"
13+
schedule:
14+
interval: daily

.github/workflows/php.code_quality.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Fetch latest changes
15-
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # renovate: tag=v3.0.0
15+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
1616
- name: Prepare/restore dependencies cache
17-
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # renovate: tag=v2.1.7
17+
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
1818
with:
1919
# NOTE: the allows to reuse it if the composer.json has not changed
2020
key: composer/${{ runner.os }}/${{ hashFiles('**/composer.json') }}
2121
path: |
2222
composer.lock
2323
vendor/
2424
- name: Install/update dependencies
25-
uses: php-actions/composer@d936bcb900310224b9089aff3337f2221a8df9a0 # renovate: tag=v6.0.0
25+
uses: php-actions/composer@8a65f0d3c6a1d17ca4800491a40b5756a4c164f3
2626
with:
2727
php_version: ${{ env.PHP_VERSION }}
2828
args: --ignore-platform-reqs
@@ -37,13 +37,13 @@ jobs:
3737
tool: [phpcs, phpmd, phpstan, phpunit]
3838
steps:
3939
- name: Setup PHP ${{ env.PHP_VERSION }} environment
40-
uses: shivammathur/setup-php@v2
40+
uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d
4141
with:
4242
php-version: ${{ env.PHP_VERSION }}
4343
- name: Fetch lastest changes
44-
uses: actions/checkout@v4
44+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
4545
- name: Restore dependencies cache
46-
uses: actions/cache@v4
46+
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2
4747
with:
4848
key: composer/${{ runner.os }}/${{ hashFiles('**/composer.json') }}
4949
path: |
@@ -52,7 +52,7 @@ jobs:
5252
- name: Run ${{ matrix.tool }}
5353
run: make ${{ matrix.tool }}-ci
5454
- name: Upload ${{ matrix.tool }} reports
55-
uses: actions/upload-artifact@v4
55+
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6
5656
if: always()
5757
with:
5858
name: ${{ matrix.tool }}-reports
@@ -70,18 +70,18 @@ jobs:
7070

7171
# NOTE: only phpunit, phpcs generate reports
7272
- name: Download phpunit reports
73-
uses: actions/download-artifact@v4
73+
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935
7474
with:
7575
name: phpunit-reports
7676
path: build/
7777
- name: Download phpcs reports
78-
uses: actions/download-artifact@v4
78+
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935
7979
with:
8080
name: phpcs-reports
8181
path: build/
8282

8383
- name: Report analisys results
84-
uses: mikepenz/action-junit-report@v4
84+
uses: mikepenz/action-junit-report@b1b7f659602565970688b2e2588738b9398e895d
8585
with:
8686
check_name: See PHP code quality reports
8787
report_paths: build/reports/*.xml

.github/workflows/security.gh-action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Fetch lastest changes
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
1414
- name: Ensure SHA pinned actions
15-
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@v3
15+
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@ba37328d4ea95eaf8b3bd6c6cef308f709a5f2ec

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ phpstan-ci: prepare-ci ## Run PHPStan (CI)
2424
EXTRA_ARGS="--error-format=github --no-progress" $(MAKE) phpstan
2525
.PHONY: phpstan phpstan-ci
2626

27-
#unit-tests: phpunit ## Run unit tests (alias to phpunit)
28-
#phpunit: ## Run PHPUnit
29-
# vendor/bin/phpunit --exclude-group=functional $(EXTRA_ARGS)
30-
#phpunit-ci: prepare-ci ## Run unit tests (CI)
31-
# EXTRA_ARGS="--log-junit $(REPORTS_DIR)/unit-tests.junit.xml" $(MAKE) unit-tests
32-
#.PHONY: unit-tests unit-tests-ci
27+
unit-tests: phpunit ## Run unit tests (alias to phpunit)
28+
phpunit: ## Run PHPUnit
29+
vendor/bin/phpunit --exclude-group=functional $(EXTRA_ARGS)
30+
phpunit-ci: prepare-ci ## Run unit tests (CI)
31+
EXTRA_ARGS="--log-junit $(REPORTS_DIR)/unit-tests.junit.xml" $(MAKE) unit-tests
32+
.PHONY: unit-tests unit-tests-ci
3333

3434
prepare-ci:
3535
@mkdir -p build/reports

README.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,73 @@
22

33
This is the coding style tools config I use everyday on my projects.
44

5-
## PHPCS
5+
it includes :
6+
- PHPCS for code sniffing.
7+
- PHPStan for static bug finding into code.
8+
- PHPMD for static performance analysis (complexity, unused expressions, optimizing).
69

7-
PHPCS for code sniffing :
10+
## Installation
811

12+
Installation with composer :
13+
14+
```bash
15+
composer require etsglobal/php-static-analysis --dev
16+
```
17+
18+
## Usage
19+
20+
### PHPCS
21+
22+
In your project, create a `phpcs.xml` file and fill it up with :
23+
24+
```xml
25+
<?xml version="1.0"?>
26+
<ruleset name="Arty Coding Standard"
27+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
28+
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd">
29+
<rule ref="./vendor/arty/php-coding-standard/lib/phpcs/phpcs.xml" />
30+
</ruleset>
31+
```
32+
33+
Run it with :
934
```bash
10-
$ ./vendor/bin/phpcs
35+
$ ./vendor/bin/phpcs src
1136
```
1237

13-
## PHPStan
38+
### PHPStan
1439

15-
PHPStan for static bug finding into code.
40+
In your project, create a `phpstan.neon` file and fill it up with :
41+
42+
```neon
43+
includes:
44+
- vendor/arty/php-coding-standard/lib/phpstan/phpstan.neon
45+
```
1646

47+
Run it with :
1748
```bash
18-
$ ./vendor/bin/phpstan
49+
$ ./vendor/bin/phpstan analyse --level=max src
1950
```
2051

21-
## PHPMD
52+
### PHPMD
2253

23-
PHPMD for static performance analysis (complexity, unused expressions, optimizing).
54+
In your project, create a `pphmd.xml` file and fill it up with :
55+
56+
```xml
57+
<?xml version="1.0"?>
58+
<ruleset name="Arty ruleset"
59+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
60+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
61+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
62+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
63+
<description>
64+
Arty ruleset
65+
</description>
66+
67+
<rule ref="./vendor/etsglobal/php-static-analysis/lib/phpmd/phpmd.xml"/>
68+
</ruleset>
69+
```
2470

71+
Run it with :
2572
```bash
26-
$ ./vendor/bin/phpmd
73+
$ ./vendor/bin/phpmd src text phpmd.xml
2774
```

0 commit comments

Comments
 (0)