Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

pun migrate

Convert existing tool configs to pun.toml and report what it skips.

pun migrate writes pun.toml from your existing configs and reports what it skips. Exit code 0 doesn’t mean every rule migrated, so review the warnings before you remove your old tools.

pun migrate
pun migrate --from pint
pun migrate --yes
pun migrate --dry-run

Reading .php-cs-fixer.php or rector.php runs project code, and Pun loads vendor/autoload.php first. Run pun migrate only on a checkout you trust.

If a config can’t be read, the error names the file and the tool that read it, for example can't read rector.php with Rector: .... Warnings that Rector or the config print, such as a deprecated set, don’t stop migration.

Options

Flag What it does
--from <tools> Migrate only these tools, comma-separated, without a prompt.
-y, --yes Migrate every detected config without a prompt.
--dry-run Print a diff and write nothing.
--config <path> The pint.json to read.
--preset <name> Use this preset instead of pint.json’s.

Config discovery

Tool Files in the project root Becomes
Pint pint.json or --config [files], [format], and [lint.rules]
PHP-CS-Fixer .php-cs-fixer.php, .php-cs-fixer.dist.php Same as Pint
Rector rector.php [lint]
PHPStan phpstan.neon, phpstan.neon.dist, phpstan.dist.neon [analyse]
Mago mago.toml Detected, not translated

On a terminal, you pick configs from a checklist. Otherwise, under an agent, or with --yes, Pun migrates every detected config that --from allows. If you select both Pint and PHP-CS-Fixer, Pint supplies the format config.

If you leave Pint and PHP-CS-Fixer out (for example, --from phpstan,rector because you keep PHP-CS-Fixer as your formatter), pun.toml gets no [format] section. pun format then uses Pint’s defaults, as Pint does without a pint.json. @php-cs-fixer-ignore comments stay as they are.

With no source config, Pun offers a starter based on the laravel preset or --preset. The starter puts the preset’s risky and code-deleting rules under lint, so run pun check --fix to apply everything.

Pint and PHP-CS-Fixer

Migration resolves Pint’s extend, --config, and --preset. It reads .php-cs-fixer.php through PHP-CS-Fixer, with system PHP.

  • Layout rules go to [format.rules]. Risky and code-deleting fixers go to [lint.rules] at "error".
  • Finder paths and exclude go to [files], so lint and analyse skip those folders too. notName and notPath become format exclusions. Two exclusion details differ from Pint.
  • per and rule sets such as @PER-CS expand to explicit rules over preset = "empty". Pint’s symfony preset is not supported: migration stops with an error.
  • Options are renamed to Pun names and values.
  • These Finder calls are reported and skipped: name() other than *.php, path(), depth(), contains(), notContains(), size(), date(), filter(), append(), followLinks(), and ignoreVCSIgnored(). A Finder other than Symfony’s is skipped too.
  • setIndent() and setLineEnding() are ignored without a warning. Pun always indents with four spaces and writes \n line endings.

See the Pint mapping and the PHP-CS-Fixer mapping.

Rector

Run composer install first: migration needs system PHP and the project’s Rector.

  • Prepared sets map to lint sets. type-declaration maps to types.
  • Explicit rules, set differences, and path skips become rule settings, exclusions, and path overrides.
  • Configured rule keys use kebab-case. Lists use items.
  • Custom rules, closures, null configurations, and out-of-scope upgrade rules are skipped.

Rector rules that only change layout, such as ReplaceMultipleBooleanNotRector, are format rules in Pun. Migration never writes format settings. It names each one your format config doesn’t run, so you can turn it on in [format.rules]. The laravel preset runs all of them except NewMethodCallWithoutParenthesesRector and ShellExecFunctionCallOverBackticksRector.

See the Rector mapping.

PHPStan and Larastan

Run composer install first if an include is under vendor/, such as Larastan’s extension.neon. If it’s missing, Pun skips phpstan.neon with a warning and migrates the rest. A missing include outside vendor/ stops migration with exit code 2.

The level becomes an analyse preset plus rule differences. Paths, exclusions, stubs, ignore entries, and supported extension settings carry over. phpVersion becomes [php] version. The range form uses min, because [php] version holds one version. Custom rules under rules:, services tagged phpstan.rules.rule or another phpstan.* tag, and your own included configs are reported and skipped. Some PHPStan parameters have no Pun setting. See analysis limitations, the PHPStan mapping, and the Larastan mapping.

PHPStan baselines aren’t copied. Run pun analyse --generate-baseline, then set [analyse] baseline.

Ignore comments

@php-cs-fixer-ignore becomes @pun-ignore-file. Known @phpstan-ignore identifiers become Pun rule IDs. @phpstan-ignore-next-line becomes @pun-ignore-next-line, and @phpstan-ignore-line becomes @pun-ignore, naming the rules of the errors pun analyse reports on the line they cover. Text after the tag becomes the reason.

A comment stays as it is, and migration names its file, line and reason, when:

  • an identifier is unknown or belongs to a format rule,
  • pun analyse reports no error on the covered line, or doesn’t check the file,
  • the Pun comment would cover a different line, as a @phpstan-ignore-next-line followed by more tags in a docblock does,
  • one comment holds two ignore tags.

pun analyse still reads a PHPStan comment that stays, as PHPStan does. See ignore comments.

File changes and errors

Extensions

Migration turns on each extension whose package composer.lock locks, in [extensions]: laravel for laravel/framework, pest for pestphp/pest, and phpunit for phpunit/phpunit. Each extension brings its own rules, so pun.toml lists only the rules your configs change. Nothing else turns an extension on: delete its line, or set it to "off", to drop its rules. Blade formatting stays off unless pint.json turns it on.

Migration leaves the source configs, composer.json, and composer.lock alone. The package commands keep reading Composer’s files. Migration may rewrite ignore comments in PHP files. It doesn’t edit scripts, CI, hooks, or editor settings.

A second run leaves an identical pun.toml alone and refuses to overwrite a different one.

Writes aren’t transactional, so a write error can leave earlier changes in place. Exit code 2 means migration couldn’t finish.

Last updated on

Was this page helpful?