Skip to content

Commit 30bba81

Browse files
authored
Rules for protected properties and const (#1)
* Added rules for protected properties and constants * Added github workflow
1 parent 4b11c1e commit 30bba81

File tree

17 files changed

+2427
-0
lines changed

17 files changed

+2427
-0
lines changed

.github/workflows/checks.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Checks
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- "main"
7+
jobs:
8+
checks:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
steps:
13+
-
14+
name: Checkout repo
15+
uses: actions/checkout@v4
16+
-
17+
name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: 8.2
21+
-
22+
name: Install dependencies
23+
run: composer install --no-progress --prefer-dist --no-interaction
24+
25+
-
26+
name: Check formatting
27+
run: vendor/bin/ecs
28+
29+
tests:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
php-version: ['8.2', '8.3']
35+
dependency-version: [ prefer-lowest, prefer-stable ]
36+
steps:
37+
-
38+
name: Checkout repo
39+
uses: actions/checkout@v4
40+
-
41+
name: Setup PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: ${{ matrix.php-version }}
45+
-
46+
name: Install dependencies
47+
run: composer update --no-progress --${{ matrix.dependency-version }} --prefer-dist --no-interaction
48+
-
49+
name: Run PHPUnit tests
50+
run: composer test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
/.idea/
3+
/.phpunit.cache/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# phpstan-rules
22
Set of additional PHPStan rules
3+
4+
- check if property and constant shouldn't be set as protected (when is not inherited or class is not abstract)
5+
- check if property name starts with underscore
6+
- check if constant name is uppercase

composer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "pmarki/phpstan-rules",
3+
"type": "phpstan-extension",
4+
"description": "Set of additional PHPStan rules",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Piotr Markiewicz",
9+
"email": "email@markiewicz.xyz"
10+
}
11+
],
12+
"keywords": [
13+
"static analysis"
14+
],
15+
"extra": {
16+
"phpstan": {
17+
"includes": [
18+
"extension.neon"
19+
]
20+
}
21+
},
22+
"require": {
23+
"php": "^8.2",
24+
"phpstan/phpstan": "^2.0"
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "^10.1 || ^11.0 || ^12.0",
28+
"symplify/easy-coding-standard": "^12.5"
29+
},
30+
"autoload": {
31+
"psr-4": {"PMarki\\PHPStanRules\\": "src"}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {"PMarki\\PHPStanRules\\Tests\\": "tests"},
35+
"classmap": ["tests/fixtures"]
36+
},
37+
"scripts": {
38+
"ecs": "vendor/bin/ecs --fix",
39+
"test": "vendor/bin/phpunit --colors=always"
40+
},
41+
"config": {
42+
"allow-plugins": {
43+
"dealerdirect/phpcodesniffer-composer-installer": true
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)