forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclaude-update-config-parameters-docs.yml
More file actions
240 lines (185 loc) · 10.8 KB
/
claude-update-config-parameters-docs.yml
File metadata and controls
240 lines (185 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: "Claude Update Config Parameters Docs"
on:
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
fix:
name: "Update Config Parameters Docs"
runs-on: "ubuntu-latest"
timeout-minutes: 60
permissions:
contents: read
issues: read
pull-requests: write
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- name: "Checkout phpstan-dist"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: 2.2.x
repository: phpstan/phpstan
- name: "Checkout phpstan-src"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: 2.2.x
repository: phpstan/phpstan-src
path: __phpstan-src
- name: "Install Claude Code"
run: npm install -g @anthropic-ai/claude-code
- name: "Run Claude Code"
env:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_FORK_TOKEN }}
run: |
git config user.name "phpstan-bot"
git config user.email "ondrej+phpstanbot@mirtes.cz"
claude --model claude-opus-4-6 \
--dangerously-skip-permissions \
-p "$(cat << 'PROMPT_EOF'
You are a documentation agent for PHPStan. Your job is to find configuration parameters that exist in the schema but lack user-facing documentation, and to write documentation for them.
## Source files
- **Parameter schema**: `__phpstan-src/conf/parametersSchema.neon` (phpstan-src repo)
- **Config reference docs**: `website/src/config-reference.md` (checked out from `phpstan/phpstan`)
- **Source code for research**: `__phpstan-src/src/`, `__phpstan-src/conf/`, and `__phpstan-src/tests/` directories (phpstan-src repo)
## Task
### Step 1: Read both files
1. Read `__phpstan-src/conf/parametersSchema.neon` from the workspace
2. Read `website/src/config-reference.md` from the workspace
### Step 2: Identify user-facing parameters from the schema
Extract all parameter names from `parametersSchema.neon`. Note that some parameters are nested inside `structure()` blocks — these use dotted paths in the user's `phpstan.neon`. For example, the schema has:
```neon
exceptions: structure([
implicitThrows: bool(),
check: structure([
missingCheckedExceptionInThrows: bool(),
tooWideThrowType: bool(),
throwTypeCovariance: bool(),
tooWideImplicitThrowType: bool()
])
])
```
This means the user-facing parameters are `exceptions.implicitThrows`, `exceptions.check.missingCheckedExceptionInThrows`, `exceptions.check.tooWideThrowType`, etc. Similarly, `cache` has sub-keys like `cache.nodesByStringCountMax`. Make sure to extract ALL nested parameters, not just top-level ones.
**Skip these entirely:**
- The entire `featureToggles` section and all its sub-parameters
- Everything after the `# playground mode` comment — these are internal/irrelevant:
- `sourceLocatorPlaygroundMode`
- Nette parameters: `debugMode`, `productionMode`, `tempDir`, `__validate`
- DerivativeContainerFactory internals: `additionalConfigFiles`, `generateBaselineFile`, `analysedPaths`, `allConfigFiles`, `composerAutoloaderProjectPaths`, `analysedPathsFromConfig`, `usedLevel`, `cliAutoloadFile`
- Editor mode internals: `singleReflectionFile`, `singleReflectionInsteadOfFile`
Also skip these internal parameters that users should not configure directly:
- `strictRulesInstalled`, `deprecationRulesInstalled` (set by installing packages, not by users)
- `cliArgumentsVariablesRegistered` (internal CLI flag)
- `rootDir`, `currentWorkingDirectory` (auto-detected, not user-configurable)
- `sysGetTempDir` (internal)
- `parametersNotInvalidatingCache` (internal)
- `env` (internal environment variable mapping)
Also skip these level-only parameters — they exist purely to be toggled by rule levels in `conf/config.level*.neon` and are not configured by users directly:
- `checkThisOnly` (level 2)
- `checkMaybeUndefinedVariables` (level 1)
- `checkExtraArguments` (level 1)
- `reportMagicMethods` (level 1)
- `reportMagicProperties` (level 1)
- `checkClassCaseSensitivity` (level 2)
- `checkPhpDocMissingReturn` (level 2)
- `checkPhpDocMethodSignatures` (level 3)
- `checkAdvancedIsset` (level 4)
- `checkFunctionArgumentTypes` (level 5)
- `checkArgumentsPassedByReference` (level 5)
- `checkMissingVarTagTypehint` (level 6)
- `checkMissingTypehints` (level 6)
- `checkUnionTypes` (level 7)
- `reportMaybes` (level 7)
- `checkNullables` (level 8)
- `checkExplicitMixed` (level 9)
- `checkImplicitMixed` (level 10)
### Step 3: Determine which parameters are undocumented
Check which parameter names from the schema do NOT appear as documented parameters in `config-reference.md`. A parameter counts as "documented" if it appears as a heading (`###`), in a config key listing, or is explained in a section body.
Check ALL non-skipped parameters from the schema against the documentation. Do not look at git history or diffs — compare the entire `parametersSchema.neon` against `config-reference.md` and document every undocumented parameter you find.
If there are no undocumented parameters, stop and report that all parameters are documented. Do not create a PR.
### Step 4: Research each undocumented parameter
For each undocumented parameter, investigate what it does by reading files from the workspace (phpstan-src):
1. **Search the source code** in `__phpstan-src/src/` for where the parameter is used. Look for the parameter name in PHP files — it will typically appear in a service constructor or be read from the DI container.
2. **Check level configs** in `__phpstan-src/conf/config.level*.neon` to see which level enables the parameter and what its default value is.
3. **Check `__phpstan-src/conf/config.neon`** for the parameter's default value.
4. **Look at related rules and tests** to understand the behavior. Check `__phpstan-src/tests/` for test data files that exercise the parameter.
5. **Check if phpstan-strict-rules sets it** by searching for the parameter name in the codebase and noting if strict-rules is mentioned.
### Step 5: Write documentation
Edit the existing `website/src/config-reference.md` file to add the new documentation. Do NOT overwrite the file — use targeted edits to insert new parameter sections in the correct locations.
**Place each parameter in the correct existing section:**
- Boolean flags that enable stricter checks → "Stricter analysis" section (as `###` sub-headings)
- Parameters related to parallel processing → "Parallel processing" section
- Parameters related to caching → "Caching" section
- Other general settings → "Miscellaneous parameters" section
- Parameters related to exceptions → "Exceptions" section
**Follow the existing documentation conventions exactly:**
For parameters in "Stricter analysis", use this format:
```
### `parameterName`
**default**: `value` ([strict-rules](https://github.com/phpstan/phpstan-strict-rules) sets it to `otherValue`)
When set to `true/false`, it [concise description of what changes].
```
Include a short PHP code example only if it helps illustrate the behavior clearly. Keep descriptions concise — one or two sentences is ideal.
If the parameter was introduced in a specific PHPStan version (not 1.0), add a version badge:
```html
<div class="text-xs inline-block border border-green-600 text-green-600 bg-green-100 rounded px-1 mb-4">Available in PHPStan X.Y</div>
```
For parameters in "Miscellaneous parameters", use:
```
### `parameterName`
**default**: `value`
Description of what the parameter does.
```
## Step 6: Write a summary
After completing the fix, write two files:
1. /tmp/commit-message.txt - A concise commit message (first line: short summary under 72 chars, then a blank line, then a few bullet points describing key changes). Example:
Update error docs - added new `new.trait` identifier
More detailed description of the commit
2. /tmp/pr-description.md - A pull request description in this format:
What was the work involved in updating the docs.
These files are critical - they will be used for the commit message and PR description.
PROMPT_EOF
)"
- name: "Read Claude's summary"
id: claude-summary
run: |
if [ -f /tmp/commit-message.txt ]; then
delimiter="EOF_$(openssl rand -hex 16)"
{
echo "commit_message<<${delimiter}"
cat /tmp/commit-message.txt
echo "${delimiter}"
} >> "$GITHUB_OUTPUT"
else
echo "commit_message=Update error identifiers docs" >> "$GITHUB_OUTPUT"
fi
if [ -f /tmp/pr-description.md ]; then
delimiter="EOF_$(openssl rand -hex 16)"
{
echo "pr_body<<${delimiter}"
cat /tmp/pr-description.md
echo "${delimiter}"
} >> "$GITHUB_OUTPUT"
else
echo "pr_bodyUpdate error identifiers docs" >> "$GITHUB_OUTPUT"
fi
- name: "Delete __phpstan-src"
run: "rm -r __phpstan-src"
- name: "Create Pull Request"
id: create-pr
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
branch-token: ${{ secrets.PHPSTAN_BOT_FORK_TOKEN }}
token: ${{ secrets.PHPSTAN_BOT_PR_TOKEN }}
push-to-fork: phpstan-bot/phpstan
branch-suffix: random
delete-branch: true
base: 2.2.x
title: "Update Config Parameters Docs"
body: ${{ steps.claude-summary.outputs.pr_body }}
committer: "phpstan-bot <ondrej+phpstanbot@mirtes.cz>"
commit-message: ${{ steps.claude-summary.outputs.commit_message }}