Skip to content

Commit d0f2078

Browse files
committed
make things work
1 parent 61f4b93 commit d0f2078

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

docs/codecontributions.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Code Quality
2+
3+
This project uses PHPStan for static analysis and Rector for automated code refactoring to maintain high code quality standards.
4+
5+
## PHPStan - Static Analysis
6+
7+
PHPStan analyzes the code for potential issues and type safety problems. The configuration is stored in `phpstan.neon.dist`.
8+
9+
### Generate a new baseline
10+
When introducing PHPStan to legacy code or after major refactoring, you can create a baseline to suppress existing errors:
11+
```bash
12+
vendor/bin/phpstan analyse --generate-baseline
13+
```
14+
15+
### Run analysis
16+
To analyze the codebase and find issues:
17+
```bash
18+
vendor/bin/phpstan analyse
19+
```
20+
21+
### Configuration
22+
- Configuration file: `phpstan.neon.dist`
23+
- Current analysis level: 5
24+
- Baseline file: `phpstan-baseline.neon` (suppresses known issues)
25+
26+
## Rector - Automated Refactoring
27+
28+
Rector automatically modernizes PHP code and applies coding standards. The configuration is stored in `rector.php`.
29+
30+
### Preview changes (recommended first step)
31+
Run a dry-run to see what changes Rector would make without actually modifying files:
32+
```bash
33+
vendor/bin/rector process --dry-run
34+
```
35+
36+
### Apply changes
37+
Apply the refactoring rules to actually modify the code:
38+
```bash
39+
vendor/bin/rector process
40+
```
41+
42+
### Debug mode
43+
To see detailed information about what Rector is doing:
44+
```bash
45+
vendor/bin/rector process --dry-run --debug
46+
```
47+
48+
### Finding new rules
49+
To discover additional Rector rules for your project, visit: https://getrector.com/find-rule
50+
51+
## Workflow
52+
53+
1. **Before making changes**: Run `vendor/bin/phpstan analyse` to check current code quality
54+
2. **Use Rector for improvements**: Run `vendor/bin/rector process --dry-run` to preview automated fixes
55+
3. **Apply safe changes**: Run `vendor/bin/rector process` to apply the changes
56+
4. **Verify with tests**: Run `make test` to ensure changes don't break functionality
57+
5. **Final analysis**: Run `vendor/bin/phpstan analyse` to confirm improvements
58+
59+
## CI/CD Integration
60+
61+
Both PHPStan and Rector are integrated into the CI pipeline to ensure:
62+
- No new PHPStan errors are introduced (beyond the baseline)
63+
- Code follows modern PHP practices through Rector

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
site_name: feed-io Documentation
22
theme:
33
name: material
4+
5+
nav:
6+
- Home: index.md
7+
- Code Quality: codecontributions.md

phpstan-baseline.neon.dist renamed to phpstan-baseline.neon

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
parameters:
22
ignoreErrors:
3+
-
4+
message: '#^Call to an undefined method FeedIo\\Feed\\ItemInterface\:\:setHostInContent\(\)\.$#'
5+
identifier: method.notFound
6+
count: 1
7+
path: src/FeedIo/Feed.php
8+
39
-
410
message: '#^Call to an undefined method FeedIo\\Feed\\ItemInterface\:\:setLinkForAnalysis\(\)\.$#'
511
identifier: method.notFound
@@ -18,8 +24,26 @@ parameters:
1824
count: 1
1925
path: src/FeedIo/Reader/Result.php
2026

27+
-
28+
message: '#^Offset float on list in isset\(\) does not exist\.$#'
29+
identifier: isset.offset
30+
count: 1
31+
path: src/FeedIo/Reader/Result/UpdateStats.php
32+
2133
-
2234
message: '#^Call to an undefined method FeedIo\\Feed\\NodeInterface\:\:getHostFromLink\(\)\.$#'
2335
identifier: method.notFound
2436
count: 1
2537
path: src/FeedIo/Rule/Atom/Link.php
38+
39+
-
40+
message: '#^Call to an undefined method FeedIo\\Feed\\NodeInterface\:\:getHostFromLink\(\)\.$#'
41+
identifier: method.notFound
42+
count: 1
43+
path: src/FeedIo/Rule/Link.php
44+
45+
-
46+
message: '#^PHPDoc tag @var with type FeedIo\\Reader\\FixerAbstract is not subtype of native type FeedIo\\Reader\\Fixer\\HttpLastModified\|FeedIo\\Reader\\Fixer\\PublicId\.$#'
47+
identifier: varTag.nativeType
48+
count: 1
49+
path: src/FeedIo/Specification.php

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- phpstan-baseline.neon.dist
2+
- phpstan-baseline.neon
33

44
parameters:
55
errorFormat: table

0 commit comments

Comments
 (0)