pun migrate
Create pun.toml from Pint, PHP CS Fixer, Rector or PHPStan.
Create pun.toml from your old tool configs. Pun lists every rule it can’t move.
Usage
pun migrate [options]
pun migrate # pick configs from a list
pun migrate --from pint # only Pint
pun migrate --yes # every config found
pun migrate --dry-run # show the diff, write nothing
Options
| Option | Description |
|---|---|
--from <tools> |
Only these tools, comma-separated. |
-y, --yes |
Every config found, no questions. |
--dry-run |
Print a diff and write nothing. |
--config <path> |
The pint.json to read. Default: ./pint.json. |
--preset <name> |
Use this format preset instead of pint.json’s. |
--offer-preset |
Offer Pun’s closest analyse preset instead of the PHPStan level preset. |
What happens
-
Finds these configs in the project root:
Tool File Becomes Pint pint.json[format],[lint],[files]PHP-CS-Fixer .php-cs-fixer.php,.php-cs-fixer.dist.php[format],[lint],[files]Rector rector.php[lint]PHPStan phpstan.neon,phpstan.neon.dist,phpstan.dist.neon[analyse] -
Moves layout rules to
[format]and risky fixers to[lint]. -
Turns on each extension whose package is in
composer.lock. -
Rewrites
@php-cs-fixer-ignoreand@phpstan-ignorecomments to@pun-ignore. -
Prints each rule it skipped. Send a PR to add it.
-
Leaves your old configs and
composer.jsonalone. -
Does not copy PHPStan baselines. Run
pun analyse --generate-baselineinstead.
Reading .php-cs-fixer.php or rector.php runs project PHP code. Run it only on code you trust, after composer install.
Exit code 0 does not mean every rule moved. Read the warnings, then run pun check. Each tool has a mapping page.
Limitations
mago.tomlis detected but not converted.- Pint’s
symfonypreset is not supported. Migration stops with an error. - Custom rules, closures, null configs, and rules Pun doesn’t have are skipped with a warning.
- PHPStan custom rules,
phpstan.*services and your own included configs are skipped. Some PHPStan parameters have no Pun setting. Seepun analyse. - PHPStan baselines are not copied.
- If
pun.tomlalready exists and differs, migrate exits 2 and doesn’t overwrite it. Apun.tomlsymlink that leads outside the project also stops migrate with exit 2. - Ignore comments are rewritten only in files inside the project. Symlinked files are skipped.
Exit codes
| Code | Meaning |
|---|---|
| 0 | pun.toml written. |
| 2 | A config could not be read, pun.toml differs from what migrate would write, or another error. |