You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ca39127
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CLAUDE.md
+52-11Lines changed: 52 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,12 +19,49 @@ just quality-tools # Auto-format code with rustfmt
19
19
20
20
### Running the Tool
21
21
22
+
**Single file mode** — refactor one PHP file:
22
23
```bash
23
-
cargo run -- path/to/file.php
24
-
# or
25
-
./target/debug/php-refactor path/to/file.php
24
+
cargo run -- app.php
25
+
./target/debug/php-refactor app.php
26
26
```
27
27
28
+
**Directory mode** — refactor all PHP files in a directory (recursive):
29
+
```bash
30
+
cargo run -- src/
31
+
./target/debug/php-refactor tests/
32
+
```
33
+
34
+
**Config mode** — refactor multiple directories defined in a TOML config file:
35
+
```bash
36
+
cargo run -- config.toml
37
+
./target/debug/php-refactor target/config.toml
38
+
```
39
+
40
+
### Config File Format
41
+
42
+
Create a `config.toml` file to process multiple directories at once:
43
+
44
+
```toml
45
+
[source]
46
+
paths = ["src", "tests", "app"]
47
+
```
48
+
49
+
Paths can be:
50
+
- Relative to the project root (where you run the command): `"src"`, `"./app"`
51
+
- Absolute: `"/home/user/project/src"`
52
+
- Nested: `"src/components/php"`
53
+
54
+
The tool will recursively walk each path and apply all rules to every `.php` file found.
55
+
56
+
## How Rules Work
57
+
58
+
Rules receive a **path** (file, directory, or config file) and are responsible for:
59
+
1. Expanding it to actual PHP files (single file, directory walk, config parsing)
60
+
2. Reading each file, applying transformations, writing back if changed
61
+
3. Returning stats: how many files changed and how many were analyzed
62
+
63
+
This design keeps `main.rs` simple — it just passes the input path to each rule in sequence. Each rule is autonomous and can process different subsets of files if needed.
64
+
28
65
## How to Find What You Need
29
66
30
67
-**Writing or modifying a rule?** → See `.claude/rules/rule-contract.md` (function contract, return semantics)
@@ -34,21 +71,25 @@ cargo run -- path/to/file.php
34
71
-**Looking at architecture in `src/`?** → `.claude/rules/architecture.md` (loaded automatically when working in src/)
35
72
-**Understanding test fixtures in `tests/`?** → `.claude/rules/testing-patterns.md` (loaded automatically when working in tests/)
0 commit comments