Skip to content

Commit de64839

Browse files
committed
docs: update init command docs, config reference, and add PR template
The `init` command creates a minimal .phpantom.toml with just a JSON schema directive, but the documentation promised "all options documented and commented out." This corrects that mismatch and brings the config documentation up to date. - Update DEFAULT_CONFIG_CONTENT to include helpful comments pointing users to the schema and configuration reference, rather than leaving a bare schema line. - Rewrite the CLI.md init section to accurately describe the minimal file that gets created and explain the schema-driven discoverability approach. - Rewrite the SETUP.md Project Configuration section with complete reference tables for every config section: php, diagnostics (including ignore rules), indexing, formatting, phpstan, phpcs, mago, and laravel (schema and migrations). The previous version only covered php, diagnostics (partially), indexing, and formatting. - Add formatting.pint to config-schema.json, which was present in the Rust config struct but missing from the schema. - Add a PR template with a contributor checklist (inspired by jj-vcs) to remind contributors to update docs, schema, changelog, and tests. - Update README.md documentation link to mention configuration. Closes #275
1 parent 0016d24 commit de64839

6 files changed

Lines changed: 137 additions & 34 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
Please describe the changes in this PR in the commit message(s), with
3+
each commit representing one logical change. Address code review comments
4+
by rewriting commits rather than adding fixup commits on top.
5+
-->
6+
7+
# Checklist
8+
9+
If applicable:
10+
11+
- [ ] I have updated `CHANGELOG.md`
12+
- [ ] I have updated the documentation (`README.md`, `docs/`, `examples/`)
13+
- [ ] I have updated the config schema (`config-schema.json`)
14+
- [ ] I have added/updated tests to cover my changes
15+
- [ ] I fully understand the code that I am submitting (what it does,
16+
how it works, how it's organized), including any code drafted by an LLM.
17+
- [ ] For any prose generated by an LLM, I have proof-read and copy-edited with
18+
an eye towards deleting anything that is irrelevant, clarifying anything
19+
that is confusing, and adding details that are relevant. This includes,
20+
for example, commit descriptions, PR descriptions, and code comments.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ PHPantom understands Composer projects out of the box, but works without setup o
9191

9292
## Documentation
9393

94-
- **[Installation](docs/SETUP.md).** Editor-specific setup for Zed, Neovim, PHPStorm, and others.
94+
- **[Installation & Configuration](docs/SETUP.md).** Editor setup, project configuration (`.phpantom.toml`), and formatting.
9595
- **[CLI Reference](docs/CLI.md).** Batch diagnostics (`analyze`), automated fixes (`fix`), and CI integration.
9696
- **[Building from Source](docs/BUILDING.md).** Build, test, and debug instructions.
9797
- **[Architecture](docs/ARCHITECTURE.md).** Symbol resolution, stub loading, and inheritance merging.

config-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@
135135
"type": "object",
136136
"description": "Controls the formatting strategy. PHPantom ships a built-in formatter (PER-CS 2.0 style). Projects with php-cs-fixer or PHP_CodeSniffer in composer.json require-dev automatically use those tools instead. Explicit configuration here always takes priority.",
137137
"properties": {
138+
"pint": {
139+
"type": "string",
140+
"description": "Command or path to run Laravel Pint. Unset: auto-detect from composer.json require-dev. Empty string: disable Pint. Any other value: use as the command."
141+
},
138142
"php-cs-fixer": {
139143
"type": "string",
140144
"description": "Command or path to run php-cs-fixer. Unset: auto-detect from composer.json require-dev. Empty string: disable php-cs-fixer. Any other value: use as the command."

docs/CLI.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@ writes nothing.
260260

261261
## `init`
262262

263-
Creates a default `.phpantom.toml` in the current directory with all
264-
options documented and commented out. Safe to run if the file already
265-
exists (it will not overwrite).
263+
Creates a `.phpantom.toml` in the current directory with a JSON schema
264+
directive and a link to the configuration reference. The file is
265+
intentionally minimal — add only the settings you want to override.
266+
Editors with TOML schema support (Zed, VS Code + Even Better TOML,
267+
Neovim) provide autocomplete and hover documentation for all available
268+
options via the schema. Safe to run if the file already exists (it will
269+
not overwrite).
266270

267271
```sh
268272
phpantom_lsp init

docs/SETUP.md

Lines changed: 100 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -263,46 +263,116 @@ PHPantom works best with Composer projects. It reads `composer.json` to discover
263263

264264
### `.phpantom.toml`
265265

266-
PHPantom supports an optional per-project configuration file for settings like PHP version overrides and diagnostic toggles.
266+
PHPantom supports an optional per-project configuration file. A global
267+
config can also be placed at `$XDG_CONFIG_HOME/phpantom_lsp/.phpantom.toml`
268+
(typically `~/.config/phpantom_lsp/.phpantom.toml` on Linux). Project
269+
settings override global settings.
267270

268-
To generate a default config file with all options documented and commented out:
271+
To generate a starter config file:
269272

270273
```bash
271274
phpantom_lsp init
272275
```
273276

274-
This creates a `.phpantom.toml` in the current directory. Currently supported settings:
277+
This creates a minimal `.phpantom.toml` with a JSON schema directive.
278+
Editors with TOML schema support (Zed, VS Code + Even Better TOML,
279+
Neovim) provide autocomplete and hover documentation for every option
280+
via the schema. Only add settings you want to override — when absent,
281+
all settings use their defaults.
282+
283+
The full schema is at [`config-schema.json`](../config-schema.json).
284+
285+
#### `[php]`
286+
287+
| Key | Type | Default | Description |
288+
| --------- | ------ | --------------------------- | ----------- |
289+
| `version` | string | Inferred from composer.json | Override the detected PHP version (e.g. `"8.3"`). |
290+
291+
#### `[diagnostics]`
292+
293+
| Key | Type | Default | Description |
294+
| -------------------------- | ------ | ------- | ----------- |
295+
| `unresolved-member-access` | bool | `false` | Report `->`, `?->`, `::` on subjects whose type could not be resolved. Useful for type coverage, noisy on untyped codebases. |
296+
| `extra-arguments` | bool | `false` | Report calls that pass more arguments than the function accepts. |
297+
| `report-magic-properties` | bool | `false` | Report unknown property access on classes with `__get` when virtual properties are defined. Matches PHPStan's `reportMagicProperties`. |
298+
| `workspace` | bool | `true` | Compute diagnostics for the whole workspace in the background after startup. Requires the default `full` indexing strategy. |
299+
| `workspace-external` | bool | `true` | Run configured external tools (PHPStan, PHPCS, Mago) once over the whole project after workspace diagnostics finish. |
300+
301+
##### `[[diagnostics.ignore]]`
302+
303+
Rules that suppress matching diagnostics, similar to PHPStan's
304+
`ignoreErrors`. Each rule may constrain by `message` (regex), `path`
305+
(glob relative to workspace root), and/or `identifier` (diagnostic
306+
code). A diagnostic is suppressed when it matches every constraint
307+
present on a rule; omitted constraints match anything.
275308

276309
```toml
277-
[php]
278-
# Override the detected PHP version (default: inferred from composer.json, or 8.5).
279-
# version = "8.5"
280-
281-
[diagnostics]
282-
# Report member access on subjects whose type could not be resolved.
283-
# Useful for discovering gaps in type coverage. Off by default.
284-
# unresolved-member-access = true
285-
286-
[indexing]
287-
# How PHPantom discovers classes across the workspace.
288-
# "full" (default) - scan PHP files and background-parse user files
289-
# "composer" - use Composer classmap, self-scan on fallback
290-
# "self" - always self-scan, ignore Composer classmap
291-
# "none" - no proactive scanning, Composer classmap only
292-
# strategy = "full"
293-
294-
[formatting]
295-
# Explicit path to an external formatter: always use this tool and skip
296-
# require-dev auto-detection. Set to "" to disable that tool entirely.
297-
# pint = "/usr/local/bin/pint"
298-
# php-cs-fixer = "/usr/local/bin/php-cs-fixer"
299-
# phpcbf = "/usr/local/bin/phpcbf"
300-
301-
# Timeout for external formatters, in milliseconds (default: 10000).
302-
# timeout = 10000
310+
[[diagnostics.ignore]]
311+
path = "tests/**"
312+
313+
[[diagnostics.ignore]]
314+
identifier = "deprecated_usage"
315+
message = "^Call to deprecated function some_legacy_helper\\(\\)"
303316
```
304317

305-
The file is optional. When absent, all settings use their defaults. New settings will be added as features land. Unknown keys are silently ignored, so the file is forward-compatible.
318+
#### `[indexing]`
319+
320+
| Key | Type | Default | Description |
321+
| ---------- | ------ | -------- | ----------- |
322+
| `strategy` | string | `"full"` | Class discovery strategy: `"full"`, `"composer"`, `"self"`, or `"none"`. See [Indexing Strategy](#indexing-strategy) below. |
323+
324+
#### `[formatting]`
325+
326+
| Key | Type | Default | Description |
327+
| -------------- | ------- | ------- | ----------- |
328+
| `pint` | string | unset | Command or path for Laravel Pint. Unset: auto-detect from `require-dev`. `""`: disable. |
329+
| `php-cs-fixer` | string | unset | Command or path for php-cs-fixer. Unset: auto-detect from `require-dev`. `""`: disable. |
330+
| `phpcbf` | string | unset | Command or path for phpcbf. Unset: auto-detect from `require-dev`. `""`: disable. |
331+
| `timeout` | integer | `10000` | Max runtime in milliseconds per external formatting tool. |
332+
333+
#### `[phpstan]`
334+
335+
| Key | Type | Default | Description |
336+
| -------------- | ------- | -------- | ----------- |
337+
| `command` | string | unset | Command or path for PHPStan. Unset: auto-detect via `vendor/bin/phpstan` then `$PATH`. `""`: disable. |
338+
| `memory-limit` | string | `"1G"` | Memory limit passed to PHPStan via `--memory-limit`. |
339+
| `timeout` | integer | `60000` | Max runtime in milliseconds before PHPStan is killed. |
340+
341+
#### `[phpcs]`
342+
343+
| Key | Type | Default | Description |
344+
| ---------- | ------- | ------- | ----------- |
345+
| `command` | string | unset | Command or path for PHPCS. Unset: auto-detect via `vendor/bin/phpcs` then `$PATH`. `""`: disable. |
346+
| `standard` | string | unset | Coding standard to enforce (e.g. `"PSR12"`). Unset: PHPCS uses its own default detection. |
347+
| `timeout` | integer | `30000` | Max runtime in milliseconds before PHPCS is killed. |
348+
349+
#### `[mago]`
350+
351+
Mago is only activated when `mago.toml` exists at the workspace root.
352+
353+
| Key | Type | Default | Description |
354+
| ----------------- | ------- | ------- | ----------- |
355+
| `command` | string | unset | Command or path for Mago. Unset: auto-detect via `vendor/bin/mago` then `$PATH`. `""`: disable. |
356+
| `lint-timeout` | integer | `30000` | Max runtime in milliseconds before `mago lint` is killed. |
357+
| `analyze-timeout` | integer | `60000` | Max runtime in milliseconds before `mago analyze` is killed. |
358+
359+
#### `[laravel]`
360+
361+
##### `[laravel.schema]`
362+
363+
| Key | Type | Default | Description |
364+
| ------- | -------- | -------------------- | ----------- |
365+
| `enabled` | bool | `true` | Enable Laravel schema dump scanning for Eloquent model property inference. |
366+
| `paths` | string[] | `["database/schema"]` | Schema dump files or directories to scan, relative to the workspace root. |
367+
368+
##### `[laravel.migrations]`
369+
370+
| Key | Type | Default | Description |
371+
| ------- | -------- | ------- | ----------- |
372+
| `enabled` | bool | `true` | Enable Laravel migration scanning for Eloquent model property inference. |
373+
| `paths` | string[] | unset | Migration files or directories to scan. Defaults to non-vendor `database/migrations` directories. |
374+
375+
The file is optional. Unknown keys are silently ignored, so the file is forward-compatible.
306376

307377
### Code Formatting
308378

src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ const CONFIG_APP_DIR: &str = "phpantom_lsp";
515515

516516
/// Default content for a newly created `.phpantom.toml` file.
517517
pub const DEFAULT_CONFIG_CONTENT: &str = r#"#:schema https://github.com/PHPantom-dev/phpantom_lsp/raw/main/config-schema.json
518+
519+
# PHPantom configuration: only add settings you want to override.
520+
# Editors with TOML schema support (Zed, VS Code + Even Better TOML, Neovim)
521+
# provide autocomplete and hover documentation for all available options.
522+
# Full reference: https://github.com/PHPantom-dev/phpantom_lsp/blob/main/docs/SETUP.md#project-configuration
518523
"#;
519524

520525
/// Return the path to the global config file, if the platform's config

0 commit comments

Comments
 (0)