JSON Output

The regex command prints JSON when it is given --format=json or --json. It ships in php-regex/regex-cli (composer require --dev php-regex/regex-cli, installed with the CLI guide). These documents are part of the backward compatibility promise: for all of 2.x, a key keeps its name, its type and its meaning. A minor release adds keys and values, and may improve messages; see What a minor release may change. This page lists every key of every document.

command document
regex lint the lint report
regex lint --generate-baseline=<file> the baseline file, written to <file>
regex analyze the analyze document
regex debug the debug document
regex redos the benchmark document
regex transpile the transpile document
regex format the format document
regex validate the validate document
regex explain the explain document

Symfony’s and Laravel’s regex:lint print the same lint report, and their regex:transpile the same transpile document without php_target and range (the bridges judge one PHP version), with the same error envelope — the commands come with their bundles (Symfony, Laravel). Three bridge commands print a report of their own, under the same rules and the same promise:

command document
Symfony’s regex:analyze the Symfony analyze report
Laravel’s regex:routes the Laravel routes report
Laravel’s regex:compare the Laravel compare document

An argument error their console framework catches before the command runs, such as an unknown option or a missing argument, is reported by the framework in its own form, not as the envelope.

The Rules

One document on stdout

  • Every run in JSON mode prints exactly one JSON document on stdout: pretty-printed, slashes and Unicode unescaped, ending with one newline.
  • Status lines, progress and notes go to stderr. --quiet silences them; it never silences the document.
  • The same holds for every machine format of lint: the JSON, GitHub, Checkstyle and JUnit reports are printed under --quiet, by regex lint and by Symfony’s and Laravel’s regex:lint. --quiet silences the human status lines only.
  • A failure prints the error envelope instead, with the exit code the command uses anyway (see Exit Codes).
  • PHP’s own diagnostics (warnings, notices) go to stderr in JSON mode, never into the document. A fatal error, such as redos running out of --time-limit between two matches, prints the envelope with stage internal and exits with 1. An exception the command does not handle prints the envelope with stage internal and exits with 1 too. A process killed from outside, by a hard limit or a signal, cannot print anything: stdout is then empty, and the exit code is the one the system gives.
  • redos running out of --time-limit during a single match can be such a kill. PHP cannot stop a running preg_match() call: it gives the call hard_timeout more seconds to return (2 by default, a setting of php.ini only), and the fatal error above follows when it does. A call still running then has PHP end the process itself, with Maximum execution time of … seconds exceeded (terminated) on stderr, nothing on stdout and exit code 124.
  • JSON mode is read before anything else: --format=json, --format json and --json count wherever they sit on the command line, so a mistake in another option is reported as JSON too. An unknown command, or --json placed before the command, is reported as JSON as well. "format": "json" in regex.json asks for JSON once lint reads its options: the report and the errors lint finds are JSON, but an error in a global option, read before regex.json, is reported as text unless the command line asks for JSON too.
  • --format values are case-insensitive: --format=JSON is --format=json. When the command line holds several --format or --json options, the last one wins, on a failure as on a success.
  • An unknown --format value does not ask for JSON: it is a usage error printed as text.

Keys and values

  • Every key is snake_case.
  • Every key a table lists is present, null when it does not apply. A key whose type says “optional” may be absent.
  • A value listed as one of a few words (a severity, a stage, a category) is an open set: a minor release may add a value. Treat a value you do not know as you would the closest one you do, or ignore it.
  • Messages, hints and tips are for people. Their wording is not frozen and may improve in any release. Match on issue_id, error_code, stage or severity, never on a message.

Strings are written as they are

A string is written as itself: a pattern holding a newline or a control byte comes out with JSON’s own escape for it (\n, \u0001), which decodes back to the same text. The one exception is a byte that is not valid UTF-8, which JSON cannot carry: each such byte is written as the four characters \xNN (uppercase hex) and the rest of the string is kept. Such a string is a display form, so a document can always be encoded, even for a byte-mode pattern.

The caret of caret_snippet is placed by counting the raw bytes of the pattern. A byte written as \xNN takes four characters in the snippet but counts as one, so the caret of a pattern holding such a byte sits to the left of the place it means, by three columns for each such byte before it.

Positions

Every position counts bytes.

field base counted from
line 1 the first line of the file
column 1 the first byte of the line; null when unknown
file_offset 0 the first byte of the file
position, validation.offset 0 the first byte of the pattern body
hotspot start, end 0 the first byte of the pattern body
  • line, column and file_offset of a lint result point at the start of the PHP expression that holds the pattern: the opening quote of its first string literal. file_offset is null, and column too, when the pattern does not come from a PHP string, as a route requirement read from YAML.
  • A pattern the call reads through a constant, a local variable or a property of the same file is placed at the literal that declares it, not at the call, and reported once however many calls use it: its source is the first of those calls in the file, and its location the name that call reads it through (see location).
  • A pattern argument built at run time, listed under --report-dynamic, is placed at the first byte of the argument, the $ of $pattern, and its issue has no position.
  • The pattern body is what sits between the delimiters. In /(a/, offset 0 is the (. This is the coordinate PCRE2’s own error offsets use. An error in the modifiers counts on past the body and its closing delimiter.
  • A hotspot’s end is exclusive: the span is start to end - 1.
  • Editors count in UTF-16 code units. An editor integration should use the language server, which converts, rather than these byte offsets.

Paths

file is relative to the working directory, with / separators, when the file lies under it, and absolute otherwise. regex lint src and regex lint "$PWD/src" print the same file values. The baseline file uses the same rule, with its . and .. segments resolved and \ read as a separator, so regex lint ./src and regex lint src share a baseline.

Order

  • The lint report lists its results by file (compared byte by byte), then line, then column (null first), then file_offset, then source.
  • The issues of a result are listed by position (null first), then issue_id.
  • The issues of the baseline file are sorted like the results.
  • lint.target.range lists the floor first, then the other PHP versions in ascending order.

The order is the same whatever the number of workers (--jobs). Timing fields (duration_ms, wall_ms, avg_ms, cpu_ms) differ between two runs, so two runs may not print the same bytes.

What a minor release may change

  • Add a key to any object, and add an optional key to the error envelope.
  • Add a value to an open set: a stage, a severity, a category, an issue_id, an error_code.
  • Improve a message, a hint, a tip or the escaping of a display string.
  • Add an entry to lint.target.range: a PHP version a rule of the library changes at, learned in that release, which the project’s require.php allows.

It never renames or removes a key, changes a key’s type, or turns a success document into one with a top-level error.

Versions

No document carries a version key. The package version is the schema version: regex --version prints it. redos_analysis.analysis_version is something else, the version of the ReDoS model behind a verdict.

The Error Envelope

A run that cannot produce its document prints the envelope instead:

{
    "error": "Unknown option: --bogus",
    "stage": "usage"
}

A success document never has a top-level error key, so testing for it tells the two apart.

Error envelope: error

key type meaning
error string What went wrong, for people. A string for all of 2.x; its wording is not frozen
stage string Where the run stopped, from the open set below
validation object, optional Present when the pattern given is invalid: why, as a validation object

stage is an open vocabulary. Today it is one of:

stage meaning
usage The command line cannot be used: an unknown command or option, a missing pattern or value, an invalid --php-version, a path argument that does not exist, a --baseline file that is missing, cannot be read or is not a baseline, a --generate-baseline or --output file that cannot be written
config The configuration cannot be used: a regex.json that is not valid JSON, an unknown or removed key, a path it lists that does not exist; for Symfony’s regex:analyze, a security configuration it cannot read (exit code 2)
target lint was asked to judge for a PHP it does not judge: PHP 7.2 and earlier, which ship PCRE1, named outright or as a composer.json that allows no PHP of 7.3 or later; exit code 2. A require.php that also allows 7.3 or later is judged from there instead, with a Note: line on stderr
collect lint could not read the files or the patterns in them
analyze lint read the patterns but could not analyse them: a worker process failed or exited, named with the files it was reading; exit code 1
pattern The command cannot act on the pattern it was given, such as an invalid one
internal The command failed for another reason, a PHP fatal error included; exit code 1. Apart from a time limit you set, this is a bug worth reporting

Other keys may come next to error and stage in a minor release, as validation did.

Invalid Patterns

An invalid pattern is a finding, not a failure, for the commands that report on patterns:

  • lint reports it as an issue of severity error. Its issue_id is the error code, such as regex.group.unclosed, and its validation says why.
  • analyze prints its document with parse.ok false, validation saying why, and redos and explain null. The exit code is 1.
  • debug prints its document with validation saying why and analysis null. The exit code is 1.

The commands that act on a pattern, transpile and redos, cannot. They print the envelope with stage pattern, carrying the same validation object, and exit with 1. redos judges the pattern given with --safe the same way: an invalid one stops it with the envelope, stage pattern. redos stops so in JSON only: its console output still measures a pattern PHP refuses. format prints the envelope with stage pattern too, without a validation key, for a pattern that does not parse. explain stops like transpile: the envelope, stage pattern, carrying validation, exit code

  1. validate is the one command whose document is the verdict itself: an invalid pattern is its document, validation.is_valid false, exit code 1.

Lint Report

regex lint --format=json prints one report for the whole run. --json is short for --format=json.

{
    "target": {
        "php": "8.2",
        "pcre": "10.40",
        "locale": "C",
        "source": "composer.json require.php",
        "range": [{"php": "8.2", "pcre": "10.40"}, {"php": "8.3", "pcre": "10.42"}, {"php": "8.4", "pcre": "10.44"}, {"php": "8.4.25", "pcre": "10.44"}, {"php": "8.5", "pcre": "10.44"}, {"php": "8.5.10", "pcre": "10.44"}]
    },
    "host": {"php": "8.4.26", "pcre": "10.49"},
    "stats": {"errors": 1, "warnings": 0, "optimizations": 0, "redos_errors": 0, "infos": 0, "lint_errors": 0, "parser_fallbacks": 0, "not_analyzed": 0, "arguments_constant": 1, "arguments_finite_set": 0, "arguments_quoted_shell": 0, "arguments_raw_shell": 0, "arguments_opaque": 0},
    "results": [
        {
            "file": "src/Example.php",
            "line": 3,
            "column": 12,
            "file_offset": 18,
            "source": "preg_match()",
            "pattern": "/(a/",
            "expression": null,
            "location": null,
            "issues": [
                {
                    "severity": "error",
                    "file": "src/Example.php",
                    "line": 3,
                    "column": 12,
                    "file_offset": 18,
                    "position": 2,
                    "issue_id": "regex.group.unclosed",
                    "docs_url": null,
                    "message": "Expected ) at end of input (found eof).",
                    "hint": null,
                    "tip": null,
                    "source": "preg_match()",
                    "validation": {
                        "is_valid": false,
                        "error": "Expected ) at end of input (found eof).",
                        "complexity_score": 0,
                        "category": "syntax",
                        "offset": 2,
                        "caret_snippet": "Line 1: (a\n          ^",
                        "hint": null,
                        "error_code": "regex.group.unclosed"
                    },
                    "analysis": null,
                    "target": null
                }
            ],
            "optimizations": []
        }
    ]
}

Lint report: lint

key type meaning
target object The PHP, PCRE2 and locale the patterns were judged for, and every PHP and PCRE2 they were validated at
host object The PHP and PCRE2 that ran the lint
stats object The counts of the run
results list of objects One entry per pattern with at least one issue or optimization, and, under --report-dynamic, one per pattern argument built at run time; [] when there is nothing to report

Target: lint.target

key type meaning
php string The PHP version, as major.minor, or major.minor.patch when its patch is not 0 (8.4.30 for ^8.4.30, the running PHP’s patch for running PHP); always the first range entry’s php
pcre string The PCRE2 release, as major.minor
locale string The LC_CTYPE locale the patterns were judged under, as the C library names it: C for PCRE2’s own character tables; the same at every range entry
source string Where the target came from, such as --php-version, regex.json, composer.json require.php or running PHP, then where the PCRE2 release and the locale came from when it was elsewhere (running PHP; --locale)
range list of objects Every PHP and PCRE2 the patterns were validated at, the floor first; a single entry, the target, unless the PHP is a range: read from composer.json require.php, or named by --php-version or phpVersion as a constraint or {min, max}

php, pcre and source name the floor: the lint rules and the ReDoS analysis judge every pattern there. When the PHP is a range, each pattern is also validated (parsed and checked, without the lint rules) at every PHP version above the floor that a rule of the library changes at and that the range allows, and at the lowest version of each branch of an OR constraint above the floor (~8.3.0 || >=8.5.3 adds 8.5.3), unless a version already judged with the same PCRE2 stands for its stretch between two rule changes (8.1.0 || 8.1.1 || 8.1.2 is judged at 8.1 alone), with the PCRE2 the target order gives it: the release pinned, else the running one for the running PHP’s minor, else the one that PHP bundles. See Several PHP versions.

Host: lint.host

key type meaning
php string The running PHP, as PHP_VERSION spells it (8.4.26): under iu its mbstring tables give a character’s other case
pcre string The PCRE2 release the running PHP links, as 10.49: it compiles the patterns and answers what only the engine knows

The host is not the target: a lint for PHP 8.2 may run on 8.4. It says which Unicode data a caseless verdict was computed with, see Verdicts that depend on the running PHP.

Target range entry: lint.target.range[]

key type meaning
php string The PHP version, as major.minor, or major.minor.patch when the version is a patch release a rule changes at (8.4.25), the floor’s own patch (8.4.30 for ^8.4.30, the running PHP’s patch for running PHP) or the lowest patch of an OR branch when no other version judged with the same PCRE2 stands for its stretch between two rule changes (8.5.3 for ~8.3.0 \|\| >=8.5.3)
pcre string The PCRE2 release, as major.minor

Stats: lint.stats

Every count is present on every run, 0 when there is none.

key type meaning
errors int Issues of severity error: invalid patterns, ReDoS errors and lint rules of error severity
warnings int Issues of severity warning
optimizations int Optimization entries
redos_errors int ReDoS issues of severity error, counted among errors
infos int Issues of severity info
lint_errors int Lint rules of error severity that fired, counted among errors
parser_fallbacks int Files the PHP parser could not read, read with the tokenizer instead; their patterns are linted, and the count is no error (--verbose names each file)
not_analyzed int Patterns past one of the library’s own limits, counted among warnings: no verdict on them, and the exit code stays what the warnings leave
arguments_constant int Pattern arguments read as one pattern. An empty literal, preg_match('', $s), is counted here: the file writes it whole, and it is no pattern, so no rule runs on it
arguments_finite_set int Pattern arguments read as several patterns, each of them linted: the arms of a ternary or a match, the values the target of a foreach takes, the values of a constant of the platform
arguments_quoted_shell int Pattern arguments not verified, built around a preg_quote() text: the around preg_quote() figure of the console
arguments_raw_shell int Pattern arguments not verified, built around another part known at run time only: the around a dynamic part figure of the console
arguments_opaque int Pattern arguments not verified, of which the file proves nothing: the dynamic figure of the console

The five arguments_* counts are about the pattern arguments of the PHP calls the lint reads, not about the results: an argument is counted where it is written, so a constant two calls name counts twice and is reported once, and each item of an array written in the call counts once. Each argument is in one of the five, for all of 2.x, so their sum is the number of arguments read. A pattern that is no argument of a PHP call, the matches operator of a Twig template for one, is in none. The last three are the arguments no rule ran on; --report-dynamic lists each of them as a result (see Arguments built at run time).

Result: lint.results[]

key type meaning
file string The file the pattern was read from (see Paths)
line int The line of the pattern, 1-based
column int | null The column of the pattern, 1-based, in bytes; null when unknown
file_offset int | null The byte offset of the pattern in the file, 0-based; null when unknown
source string | null What the pattern was read from: the call, as preg_match() or Preg::match(); a constructor, as new RegexIterator() or new Regex(); an attribute, as #[Regex]; a framework source, as route:<name>:<parameter>; or twig:matches for the operator of a Twig template
pattern string | null The pattern as written; null for a result no pattern holds: an inline marker or a baseline entry that silences nothing (regex.ignore.unmatched), or a pattern argument built at run time, listed under --report-dynamic
expression string | null For a pattern argument built at run time, the argument as the file writes it, byte for byte ('/^' . $prefix . '\d+$/'), the result’s line, column and file_offset being those of its first byte; null for every other result
location string | null How the pattern was reached when the file and line do not say it alone: a route’s name and controller, or, for a pattern a call reads through a name, via and that name as the first call writes it (via self::RE, via static::RE, via Patterns::RE, via RE, via $re, via $this->re); null for a pattern written in the call
issues list of objects The issues found in the pattern, possibly empty
optimizations list of objects The optimizations suggested for the pattern, possibly empty

Under --report-dynamic, preg_match('/^' . $prefix . '\d+$/', $text) on line 12 of app/Search.php, where $prefix is a parameter, is this result:

{
    "file": "app/Search.php",
    "line": 12,
    "column": 33,
    "file_offset": 261,
    "source": "preg_match()",
    "pattern": null,
    "expression": "'/^' . $prefix . '\\d+$/'",
    "location": null,
    "issues": [
        {
            "severity": "info",
            "file": "app/Search.php",
            "line": 12,
            "column": 33,
            "file_offset": 261,
            "position": null,
            "issue_id": "regex.lint.source.dynamicPart",
            "docs_url": "https://php-regex.com/reference/rules/#pattern-around-a-part-built-at-run-time",
            "message": "The pattern holds a part built at run time: it is not verified.",
            "hint": null,
            "tip": null,
            "source": "preg_match()",
            "validation": null,
            "analysis": null,
            "target": null
        }
    ],
    "optimizations": []
}

Issue: lint.results[].issues[]

An issue repeats the location of its result, so it can be read alone.

key type meaning
severity string error for a finding that fails the run (an invalid pattern, a lint rule of error severity, a ReDoS verdict confirmed at high or above), warning for one that warns, info for a lint rule of style, performance or info severity; an open set
file string As in the result
line int As in the result
column int | null As in the result
file_offset int | null As in the result
position int | null Where in the pattern body the issue lies, 0-based, in bytes; null when it concerns the whole pattern
issue_id string | null What was found: a lint rule (regex.lint.quantifier.nested), the ReDoS verdict (regex.lint.redos), the cost of an unanchored search (regex.lint.redos.search), a complexity warning (regex.lint.complexity), a pattern argument built at run time (regex.lint.source.dynamic, regex.lint.source.dynamicPart, regex.lint.source.quotedPart), an inline marker or a baseline entry that silences nothing (regex.ignore.unmatched), a @regex-target marker that cannot be read (regex.target.invalid) or keeps no version judged (regex.target.empty), or the error code of an invalid pattern (regex.group.unclosed); an open set, and a baseline matches on it. Every issue the library reports today carries one; null is kept for an invalid pattern without an error code
docs_url string | null The page of php-regex.com that explains what was found, as https://php-regex.com/reference/rules/#useless-quantifier: every lint rule, the ReDoS verdict and the search cost, the complexity warning, a file the lint could not read, a marker that silences nothing or cannot be read; null for the error code of an invalid pattern, which Diagnostics: Error Codes lists. For people: a link may move with the docs, so match on issue_id
message string The finding, for people; not frozen
hint string | null How to fix it, for people
tip string | null A further suggestion for an invalid pattern
source string | null As in the result
validation object | null For an invalid pattern, why: a validation object; null otherwise
analysis object | null For a ReDoS issue, the verdict: a ReDoS analysis, whose search_cost holds the attack of a regex.lint.redos.search issue, or every_match_search_cost for one raised at a call that looks for every match; null otherwise
target object | null For a pattern valid on the floor and refused by a later PHP of lint.target.range, the lowest PHP and PCRE2 that refuse it; for a pattern a guard or a @regex-target marker narrows, the version that reported the issue, with the constraint (see Issue target); null for every other issue, which the floor reports

An issue whose target is not null has severity error, and its validation is the verdict of that target. A pattern the floor refuses is reported once, by the floor, and not validated at the other versions. A baseline does not match on target.

Issue target: lint.results[].issues[].target

key type meaning
php string The PHP version, written as in lint.target.range[]
pcre string The PCRE2 release, as major.minor
guard string | null For a pattern a guard on PHP_VERSION_ID or a @regex-target marker narrows, the PHP versions it keeps, as a Composer constraint (>=8.4, >=8.2 <8.4, <8.3 \|\| >=8.5); null when nothing narrows the versions judged
guard_pcre string | null For a pattern a @regex-target pcre… marker narrows, the PCRE2 releases it keeps, as a Composer constraint (>=10.43); null otherwise

A pattern narrowed by a guard or a marker is judged from the lowest version the guard keeps: every issue it gets names the version that reported it in target, the lowest kept for an issue of that floor, with the constraint in guard. A guard or a marker that keeps no version leaves the pattern unjudged; a marker that does is reported as regex.target.empty, one whose constraint cannot be read as regex.target.invalid.

Optimization entry: lint.results[].optimizations[]

key type meaning
file string As in the result
line int As in the result
column int | null As in the result
file_offset int | null As in the result
optimization object The rewrite
savings int How many bytes shorter the rewrite is
source string | null As in the result

Optimization: lint.results[].optimizations[].optimization

key type meaning
original string The pattern before the rewrite
optimized string The pattern after the rewrite
changes list of strings What changed, for people

Analyze

regex analyze <pattern> --format=json reports on one pattern. On an invalid pattern, parse.ok is false, validation says why, redos and explain are null, and the exit code is 1.

Analyze: analyze

key type meaning
pattern string The pattern given
runtime object The PCRE the command ran on: a runtime object
parse object Whether the pattern parses
validation object The verdict on the pattern: a validation object
redos object | null The ReDoS verdict: a ReDoS analysis; null for an invalid pattern
explain string | null The pattern explained in plain language; null for an invalid pattern
target object The PHP versions the pattern was judged for, as lint’s target: the command’s own output is the floor’s
range list of objects The verdict of each PHP version judged, the floor first: one range point each

Parse: analyze.parse

key type meaning
ok bool true when the pattern parses and is valid, false otherwise

Debug

regex debug <pattern> --format=json reports the ReDoS analysis in depth. It always carries validation; on an invalid pattern analysis is null and the exit code is 1.

Debug: debug

key type meaning
pattern string The pattern given
runtime object The PCRE the command ran on: a runtime object
validation object The verdict on the pattern: a validation object, is_valid true when it is valid
analysis object | null The ReDoS verdict: a ReDoS analysis; null for an invalid pattern
input object The subject to try the pattern on
target object The PHP versions the pattern was judged for, as lint’s target: the command’s own output is the floor’s
range list of objects The verdict of each PHP version judged, the floor first: one range point each

Debug input: debug.input

key type meaning
value string | null The subject given with --input, or one generated from the verdict; null when there is neither
source string | null user for --input, auto for a generated subject, null without one; an open set

No subject is generated for a pattern proven safe: with no --input, both keys are null, as the analysis names no culprit to build one from.

Redos

regex redos <pattern> --format=json times the pattern against a subject, and a safer pattern given with --safe against the same subject. An invalid pattern, or an invalid --safe pattern, stops it with the envelope (see Invalid Patterns).

Benchmark document: redos

key type meaning
pattern string The pattern given
safe_pattern string | null The pattern given with --safe; null without it
runtime object The PCRE the benchmark ran on, --jit and the limit options applied: a runtime object
input object The subject both patterns ran against
settings object How the benchmark ran
bench object One measurement per pattern
summary object | null The comparison of the two patterns; null without --safe
target object The PHP versions the pattern was judged for, as lint’s target: the command’s own output is the floor’s
range list of objects The verdict of each PHP version judged, the floor first: one range point each
safe_range list of objects, optional Present with --safe: the verdict of each PHP version judged on the safe pattern, the floor first, one range point each

Benchmark input: redos.input

key type meaning
source string user for --input, file for --input-file, auto for one generated from the ReDoS verdict, default when none could be generated; an open set
base_length int The length of the base input, in bytes
final_length int The length of the subject, prefix, repeats and suffix included, in bytes
repeat int How many times the base input is repeated (--repeat), into 8 MiB at most
prefix string The text before the repeats (--prefix)
suffix string The text after the repeats (--suffix)
preview string | null The subject, shortened for display; null with --show-input
value string | null The whole subject with --show-input; null otherwise
note string | null Why the subject is not what was asked, as when none could be generated

Benchmark settings: redos.settings

key type meaning
iterations int The timed runs of each pattern (--iterations)
warmup int The untimed runs before them (--warmup)

Measurements: redos.bench

key type meaning
vuln object The measurement of the pattern: a benchmark object
safe object, optional The measurement of the --safe pattern; absent without --safe

Benchmark: benchmark

One measurement, under redos.bench.vuln and redos.bench.safe.

key type meaning
label string vuln or safe
result string What the last preg_match() returned: match, no or error
wall_ms float The wall time of all the timed runs, in milliseconds
avg_ms float The wall time of one run, on average
cpu_ms float | null The CPU time (user and system) of the timed runs; null where PHP cannot measure it
mem_bytes int How much the memory PHP holds grew during the runs, in bytes
peak_bytes int How much the peak memory grew during the runs, in bytes
err_msg string preg_last_error_msg() after the runs; - when there was no error
err_code int preg_last_error() after the runs; 0 when there was no error
iterations int The timed runs made; fewer than asked when a run failed

Comparison: redos.summary

key type meaning
result_parity string same when both patterns gave the same result, different otherwise
speedup float | null The pattern’s avg_ms divided by the safe pattern’s; null when the safe pattern took no measurable time
delta_ms float | null The pattern’s avg_ms minus the safe pattern’s; null when speedup is

Transpile

regex transpile <pattern> --format=json rewrites a pattern for another regex dialect. Symfony’s and Laravel’s regex:transpile --format=json print the same document, without php_target and range: the bridges judge one PHP version.

The pattern is validated first. An invalid pattern stops the command with the envelope, stage pattern, carrying validation, a semantic error such as /(?<=a+)b/ included. A valid pattern that uses a construct the target has no equivalent for stops it with the envelope too, stage pattern, without a validation key. Both exit with 1:

{
    "error": "Subroutine calls are not supported in JavaScript.",
    "stage": "pattern"
}

Transpile: transpile

key type meaning
target string The dialect, by its full name: javascript, html-pattern or python; an open set
source string The PCRE pattern given
pattern string The pattern body in the target dialect
flags string The target’s flags
literal string The pattern as a literal of the target language, as /a+b/i
constructor string Code that builds the pattern in the target language, as new RegExp("a+b", "i")
warnings list of strings Where the target matches differently from PCRE
notes list of strings What was rewritten on the way, matching the same
php_target object The PHP versions the pattern was judged for, as lint’s target: the rewrite is the floor’s; target names the dialect
range list of objects The verdict of each PHP version judged, the floor first: one range point each

Without u, PCRE takes one byte for a set where the targets take one character. A pattern holding a set that reaches past ASCII (the dot, a negated class, \D, \W, \S, \h, \v, a property) is written all the same, and warnings names the first such set and its offset in the pattern, once per pattern: the two differ on a subject holding a character outside ASCII, and agree under u for UTF-8 subjects.

{
    "target": "javascript",
    "source": "/^\\S+$/D",
    "pattern": "^[^\\t-\\r ]+$",
    "flags": "",
    "literal": "/^[^\\t-\\r ]+$/",
    "constructor": "new RegExp(\"^[^\\\\t-\\\\r ]+$\", \"\")",
    "warnings": [
        "Without the u flag \"\\S\" at offset 1 takes one byte in PCRE and one character in this target, so the two differ on a subject holding a character outside ASCII; under u, for UTF-8 subjects, they agree. Add u."
    ],
    "notes": [
        "Applied /D: \"$\" is written for the end of the subject alone."
    ],
    "php_target": {
        "php": "8.4.27",
        "pcre": "10.49",
        "locale": "C",
        "source": "running PHP",
        "range": [
            {
                "php": "8.4.27",
                "pcre": "10.49"
            }
        ]
    },
    "range": [
        {
            "php": "8.4.27",
            "pcre": "10.49",
            "is_valid": true,
            "error": null,
            "error_code": null,
            "parses_differently": false
        }
    ]
}

Format

regex format <pattern> --format=json lays a pattern out over lines under x, or compacts it to one line with --compact. --json is short for --format=json. With --width=24, a short date pattern breaks:

{
    "pattern": "/^(?<year>\\d{4})-(?<month>\\d{2})$/",
    "formatted": "/\n    ^\n    (?<year>\\d{4})\n    -\n    (?<month>\\d{2})\n    $\n/x",
    "changed": true,
    "refusal": null,
    "target": {
        "php": "8.4.27",
        "pcre": "10.49",
        "locale": "C",
        "source": "running PHP",
        "range": [
            {
                "php": "8.4.27",
                "pcre": "10.49"
            }
        ]
    },
    "range": [
        {
            "php": "8.4.27",
            "pcre": "10.49",
            "is_valid": true,
            "error": null,
            "error_code": null,
            "parses_differently": false
        }
    ]
}

A pattern that does not parse stops the command with the envelope, stage pattern, and exits with 1. A --width that is not a whole number of 1 or more is a usage error, stage usage, exit code 2. A pattern the formatter writes back as a different pattern is a bug: the command never prints that output, and stops with the envelope, stage internal, exit code 1, its message naming the error code regex.formatting.unsafe.

Format: format

key type meaning
pattern string The pattern given, delimiters and flags included
formatted string The pattern laid out or compacted; the pattern given, as it was written, when it already fits (and holds no raw line break) or was refused
changed bool Whether formatted differs from pattern
refusal string | null Why the pattern was given back as it was written: newline_convention, spaced_quantifier, extended_mode_switched_off, line_break_in_name, parenthesis_in_comment or delimiter_misread; an open set. null when it was not refused
target object The PHP versions the pattern was judged for, as lint’s target: the command’s own output is the floor’s
range list of objects The verdict of each PHP version judged, the floor first: one range point each

Validate

regex validate <pattern> --format=json prints the verdict of the target PHP on the pattern. --json is short for --format=json. The document is the same for a valid and an invalid pattern; the exit code tells them apart, 0 and 1:

{
    "pattern": "/(a/",
    "validation": {
        "is_valid": false,
        "error": "Expected ) at end of input (found eof).",
        "complexity_score": 0,
        "category": "syntax",
        "offset": 2,
        "caret_snippet": "Line 1: (a\n          ^",
        "hint": null,
        "error_code": "regex.group.unclosed"
    },
    "target": {
        "php": "8.4.27",
        "pcre": "10.49",
        "locale": "C",
        "source": "running PHP",
        "range": [
            {
                "php": "8.4.27",
                "pcre": "10.49"
            }
        ]
    },
    "range": [
        {
            "php": "8.4.27",
            "pcre": "10.49",
            "is_valid": false,
            "error": "Expected ) at end of input (found eof).",
            "error_code": "regex.group.unclosed",
            "parses_differently": false
        }
    ]
}

A pattern past one of the library’s own limits is not a verdict: validation.category is limit, is_valid false, exit code 1, as the console’s NOT ANALYZED. A --format other than console or json is a usage error, exit code 2.

Validate: validate

key type meaning
pattern string The pattern given, delimiters and flags included
validation object The verdict, as a validation object
target object The PHP versions the pattern was judged for, as lint’s target: the command’s own output is the floor’s
range list of objects The verdict of each PHP version judged, the floor first: one range point each

The MCP server’s regex_validate tool answers this document as its structured content.

Explain

regex explain <pattern> --format=json prints the pattern explained in plain language, the text the console prints. --json is short for --format=json; --format=html keeps printing the HTML fragment, as before.

{
    "pattern": "/a+/",
    "explanation": "Regex matches\n  'a', one or more times",
    "target": {
        "php": "8.4.27",
        "pcre": "10.49",
        "locale": "C",
        "source": "running PHP",
        "range": [
            {
                "php": "8.4.27",
                "pcre": "10.49"
            }
        ]
    },
    "range": [
        {
            "php": "8.4.27",
            "pcre": "10.49",
            "is_valid": true,
            "error": null,
            "error_code": null,
            "parses_differently": false
        }
    ]
}

Only a valid pattern is explained: a pattern the target refuses, a semantic error included, stops the command with the envelope, stage pattern, carrying validation, exit code 1.

Explain: explain

key type meaning
pattern string The pattern given, delimiters and flags included
explanation string The explanation, as Regex::explain() writes it; its wording is not frozen
target object The PHP versions the pattern was judged for, as lint’s target: the command’s own output is the floor’s
range list of objects The verdict of each PHP version judged, the floor first: one range point each

The MCP server’s regex_explain tool answers this document as its structured content.

Symfony Analyze

Symfony’s bin/console regex:analyze --format=json runs the bundle’s analyzers, the route conflicts and the security.yaml checks, and prints one report. It ships in php-regex/regex-symfony (Symfony guide). Each analyzer writes one or more sections; a section’s facts are labels for people, written as {label, value} rows rather than as keys:

{
    "sections": [
        {
            "id": "routes",
            "title": "Routes",
            "meta": [
                {"label": "Routes", "value": 2},
                {"label": "Mode", "value": "Shadowed only"},
                {"label": "Shadowed", "value": 1},
                {"label": "Overlaps", "value": 0}
            ],
            "summary": [
                {"severity": "fail", "message": "1 shadowed routes detected."}
            ],
            "warnings": [],
            "issues": [
                {
                    "kind": "shadowed",
                    "severity": "fail",
                    "title": "api_user_show (#1) ↳ api_user_list (#2)",
                    "details": [
                        {"label": "Route", "value": "/users/{id}", "kind": "text"},
                        {"label": "Conflict", "value": "/users/list", "kind": "text"},
                        {"label": "Scope", "value": "any", "kind": "text"},
                        {"label": "Example", "value": "/users/list", "kind": "example"}
                    ],
                    "notes": ["Less specific route declared BEFORE more specific route."]
                }
            ],
            "suggestions": [
                "Reorder routes: move \"api_user_list\" before \"api_user_show\".",
                "Add a requirement for {id} in \"api_user_show\" (e.g. \"\\d+\")."
            ]
        }
    ]
}

The exit code is 1 when an issue of a kind --fail-on names was found, 0 otherwise. An option it cannot use (an unknown --only analyzer, --fail-on kind or --redos-threshold) prints the error envelope, stage usage, and exits with 2. A security configuration it cannot read (a --config file that is missing or not YAML, a parameter nothing defines, a configuration the SecurityBundle refuses) prints the envelope with stage config, and exits with 2.

Symfony analyze: symfony_analyze

key type meaning
sections list The sections, in the order the analyzers ran, the objects below

Section: symfony_analyze.sections[]

key type meaning
id string What the section checks: routes, security_access or security_firewall; an open set
title string The section’s title, for people
meta list The section’s facts, as the rows below: what was read and counted
summary list The section’s verdicts, as the notices below
warnings list What the section could not check, as the notices below, such as a firewall without a pattern
issues list The conflicts and findings, the objects below
suggestions list of strings What to change, for people
debug list, optional Present under --debug or -v: timings, solver counts and why each route, rule, firewall or file left out was left out, as rows like meta’s

Fact: symfony_analyze.sections[].meta[]

The rows of meta and of debug.

key type meaning
label string What the value counts or names, for people, such as Routes or ReDoS >=
value int | string The count or the setting

Notice: symfony_analyze.sections[].summary[]

The entries of summary and of warnings.

key type meaning
severity string pass, warn, fail or critical; an open set
message string The verdict, for people

Issue: symfony_analyze.sections[].issues[]

key type meaning
kind string shadowed (a rule or route another one before it always takes), overlap (one it sometimes takes, under --show-overlaps) or redos (a firewall pattern at or above --redos-threshold); an open set, and what --fail-on names
severity string warn, fail or critical; an open set
title string The routes, rules or firewall the issue is about, with their places, for people
details list What the issue rests on, the objects below
notes list of strings Context, for people

Detail: symfony_analyze.sections[].issues[].details[]

key type meaning
label string What the value is, for people, such as Route, Example, Severity or Attack
value string The value
kind string How to show it: text, pattern (a regex) or example (a string that triggers the issue); an open set

Laravel Routes

Laravel’s php artisan regex:routes --format=json lists the routes that have a regex constraint, with --validate a verdict on each. It ships in php-regex/regex-laravel (Laravel guide). With --validate, the exit code is 1 when a constraint is invalid:

{
    "routes": [
        {
            "name": "users.show",
            "uri": "users/{id}",
            "methods": ["GET", "HEAD"],
            "action": "App\\Http\\Controllers\\UserController@show",
            "constraints": [
                {"parameter": "id", "pattern": "[0-9]+", "valid": true, "error": null}
            ]
        }
    ],
    "issues": [],
    "summary": {"total_routes": 1, "routes_with_constraints": 1, "total_issues": 0}
}

Laravel routes: laravel_routes

key type meaning
routes list Every route of the application, the objects below
issues list One entry per invalid constraint, the objects below; empty without --validate
summary object The counts below

Route: laravel_routes.routes[]

key type meaning
name string The route’s name, or its URI when it has none
uri string The route’s URI, as Laravel writes it
methods list of strings The HTTP methods the route answers
action string The controller action, Closure, or Unknown
constraints list The route’s regex constraints, the objects below

Constraint: laravel_routes.routes[].constraints[]

key type meaning
parameter string The route parameter the constraint applies to
pattern string The constraint as written in where()
valid bool | null Whether it compiles as the router matches it; null without --validate
error string | null Why it does not, for people; null when it does or was not validated

Invalid constraint: laravel_routes.issues[]

key type meaning
route string The route’s name, or its URI
parameter string The route parameter
pattern string The constraint as written
error string Why it does not compile, for people

Route counts: laravel_routes.summary

key type meaning
total_routes int The routes listed
routes_with_constraints int The routes that have a regex constraint
total_issues int The invalid constraints

Laravel Compare

Laravel’s php artisan regex:compare <pattern1> <pattern2> --format=json compares two patterns as languages: --method=intersection (the default) asks whether they share a string, subset whether every string of the first is one of the second, equivalence whether they match the same strings. Every key is printed whatever the method, null where the method fills none. The exit code is 0 when the check passes (disjoint, a subset, equivalent) and 1 when it fails:

{
    "pattern1": "/ab?/",
    "pattern2": "/a/",
    "method": "equivalence",
    "disjoint": null,
    "subset": null,
    "equivalent": false,
    "example": null,
    "counterexample": "ab",
    "left_only_example": "ab",
    "right_only_example": null,
    "algorithms": {"minimizer": "hopcroft", "determinizer": "subset-indexed"},
    "elapsed_ms": 1.52
}

An unknown --method, --minimizer or --determinizer prints the error envelope, stage usage, exit code 2. An invalid pattern prints it with stage pattern and a validation object, exit code 1; so does a valid pattern the automata cannot read, such as one with a backreference, without validation.

Laravel compare: laravel_compare

key type meaning
pattern1 string The first pattern given
pattern2 string The second pattern given
method string intersection, subset or equivalence
disjoint bool | null Under intersection: whether no string matches both; null otherwise
subset bool | null Under subset: whether every string of pattern1 matches pattern2; null otherwise
equivalent bool | null Under equivalence: whether they match the same strings; null otherwise
example string | null Under intersection: a string both match; null when they are disjoint or under another method
counterexample string | null Under subset and equivalence: a string that proves the check fails; null when it passes or under intersection
left_only_example string | null Under equivalence: a string only pattern1 matches, or null
right_only_example string | null Under equivalence: a string only pattern2 matches, or null
algorithms object The automata algorithms used, below
elapsed_ms float How long the comparison took; differs between two runs

Algorithms: laravel_compare.algorithms

key type meaning
minimizer string hopcroft or moore
determinizer string subset or subset-indexed

Shared Objects

Range point: range_point

regex validate, analyze, explain, redos, format, transpile and debug judge their pattern for the PHP versions --php-version names, a range included, read as regex lint reads it; else for the running PHP alone. They read no composer.json, and no regex.json for their target (debug reads it for its ReDoS defaults only). Their own output is computed once, at the floor; the pattern is also validated at the later versions the lint judges for the same range, those lint.target.range lists: each version above the floor where a rule of the library changes, and the lowest version of each branch of an OR constraint above the floor (`~8.3.0 ||

=8.5.3 adds 8.5.3), unless a version already judged with the same PCRE2 stands for its stretch between two rule changes (8.1.0 || 8.1.1 || 8.1.2 is judged at 8.1 alone). range` gives each version’s verdict, the floor first. A later version that refuses a pattern the floor accepts makes the command exit with 1; a pattern the floor refuses keeps the exit code the command gives it at a single version, and a version that reads the pattern otherwise does not change the exit code. What a later version finds is also said on stderr in lint’s words, as on the console: stdout holds the document alone.

key type meaning
php string The PHP version, as in a target range entry
pcre string The PCRE2 release it was judged with, as major.minor
is_valid bool Whether that version accepts the pattern
error string | null Why it refuses the pattern; null when it accepts it
error_code string | null The refusal’s error code, as in a validation object; null when it accepts the pattern
parses_differently bool Whether that version reads the pattern into another tree than the floor, where both accept it; false for the floor and for a version that refuses it

Runtime: runtime

The PCRE a command ran on, in analyze, debug and redos.

key type meaning
version string The PCRE2 version PHP reports, date included, as 10.49 2026-09-28
jit bool The pcre.jit setting, read as PHP reads it; the setting, not whether JIT is available
backtrack_limit int The pcre.backtrack_limit setting
recursion_limit int The pcre.recursion_limit setting

Validation: validation

The verdict on a pattern, in analyze, debug, a lint issue and the error envelope. It is the JSON form of ValidationResult: json_encode() of one gives these keys, in this order.

key type meaning
is_valid bool Whether PHP accepts the pattern
error string | null Why it does not, for people; not frozen
complexity_score int A rough measure of the pattern’s complexity
category string | null syntax, semantic, pcre-runtime or limit (the library stopped at one of its own limits, no verdict on the pattern); an open set
offset int | null Where the error lies, 0-based, in bytes from the first byte of the pattern body; null without an error or a place
caret_snippet string | null The pattern with a caret under the error, as the console shows it; the caret counts raw bytes (see Strings)
hint string | null How to fix it, for people
error_code string | null Why it does not, as a stable code such as regex.group.unclosed; an open set

ReDoS analysis: redos_analysis

A ReDoS verdict: analyze.redos, debug.analysis and the analysis of a lint issue. It is the JSON form of RedosAnalysis; the ReDoS guide explains how to read it.

key type meaning
severity string safe, low, medium, high, critical or unknown; an open set
score int The severity as a number from 0 to 10
mode string off, theoretical or confirmed: whether the verdict was replayed on the running PCRE
confirmed bool Whether the replay made PCRE fail
confidence string low, medium or high; an open set
vulnerable_part string | null The sub-pattern at fault
trigger string | null The construct at fault, as quantifier +
false_positive_risk string | null How likely the verdict is wrong, for people
suggested_rewrite string | null A rewrite to try, for people; verify it
recommendations list of strings Advice, for people
error string | null Why the analysis could not finish
findings list of objects Each problem the structural heuristics found; empty when one attempt is proven linear, see below
hotspots list of objects Each span the structural heuristics point at; empty when one attempt is proven linear, see below
confirmation object | null The replay in confirmed mode; null otherwise
complexity string linear, polynomial, exponential or unknown; an open set
degree int | null The degree of a polynomial verdict, 2 or more; null otherwise
proof string proven, heuristic, budget_exceeded or not_analyzed; an open set
witness object | null The attack of a proven vulnerable verdict
replayed bool | null Whether the witness made the running PCRE fail; null when it was not replayed
abstractions list of strings What the model analysed differently from the pattern as written
pcre_version string The PCRE2 release the verdict was computed for, as 10.49
php_version string The PHP release that ran the analysis, as 8.4.26: under iu the proof reads a character’s other case from its mbstring tables
analysis_version string The version of the model; a verdict is the same for the same release and model version
search_cost object | null The cost of an unanchored search whose every attempt is proven linear: a search cost; null when no witness was found, which does not prove the search linear
upper_bound_degree int | null The degree d of a proven bound n^d on the steps of one attempt, with or without an attack; null when no polynomial bound is proven. A ceiling, not the verdict: it may be above 1 next to a linear one
every_match_search_cost object | null The cost of the search of the functions that look for every match, which PHP retries after an empty match, when search_cost is null: a search cost; null when no witness was found

Finding: redos_analysis.findings[]

The findings and the hotspots come from the structural heuristics, the verdict from the proof when there is one. A proof that one attempt is linear settles the verdict: next to "proof": "proven" and "complexity": "linear" the analysis carries no finding and no hotspot, and vulnerable_part, trigger, false_positive_risk and suggested_rewrite are null and recommendations empty. /a+/, which the heuristics alone call medium, is safe (proven) with none of them.

key type meaning
severity string As in the analysis
message string The problem, for people
pattern string The sub-pattern at fault
trigger string | null The construct at fault
suggested_rewrite string | null A rewrite to try; verify it
confidence string As in the analysis
false_positive_risk string | null How likely the finding is wrong, for people

Hotspot: redos_analysis.hotspots[]

key type meaning
start int Where the span starts, 0-based, in bytes from the first byte of the pattern body
end int Where it ends, exclusive
severity string As in the analysis
pattern string The sub-pattern in the span
trigger string | null The construct at fault

Witness: redos_analysis.witness

The attack is the prefix, then the pump repeated, then the suffix. Each part is written as the body of a PHP double-quoted string, so "<prefix>" . str_repeat("<pump>", $n) . "<suffix>" builds it.

key type meaning
prefix string What comes before the repeated part
pump string The part repeated to grow the attack
suffix string What comes after, to make the match fail

Search cost: redos_analysis.search_cost

One attempt is proven linear, but an unanchored search starts one at each position of a run, and each reads to the end of the run before it fails: on the run repeated n times then the breaker, PCRE2’s interpreter takes a number of steps quadratic in n. preg_match_all(), preg_replace() and preg_split() retry the same way. It is looked for only when one attempt is proven linear: a worse per-attempt verdict already covers the search. The JIT may avoid the cost for some patterns; it is not measured, as the analysis never runs a pattern under the JIT.

key type meaning
degree int The degree of the search’s cost in the length of the run: 2
witness object The attack: a search witness
replayed bool | null Whether the step replay without the JIT found attempts that take more steps the further they start from the end of the run; null when no replay was made (theoretical mode, or a confirmed analysis whose threshold is above medium)

Search witness: redos_analysis.search_cost.witness

Each part is written as the body of a PHP double-quoted string, like the witness: "<prefix>" . str_repeat("<run>", $n) . "<breaker>" builds the attack.

key type meaning
prefix string What comes before the run, often empty: the first attempt fails on it where it would match the bare run ("!" for /^\s+\|\s+$/)
run string The part repeated: every attempt started in it reads to its end
breaker string What comes after the run and fails every attempt; it holds the last code unit PCRE2 requires, read as its compiler reads it, when the run does not, as PCRE2 gives up at once on a subject without it (">" for /\s*=>/), with a character after it when an alternative would match it at the end ("!b!" for /a+b\|b$/)

Every-match search cost: redos_analysis.every_match_search_cost

The search of preg_match() stops at an empty match inside the run, and preg_match_all(), preg_replace(), preg_filter(), preg_replace_callback(), preg_replace_callback_array() and preg_split() go on after it. PHP retries the same offset with PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED, then moves one character on, and each retry reads to the end of the run before it fails. On the run repeated n times then the breaker, those functions take a number of steps quadratic in n, as /(?:a+\d)?/ does on "a" x n.

It is looked for only when one attempt is proven linear and search_cost is null. The JIT does not avoid this cost: PHP runs the retry in PCRE2’s interpreter whatever pcre.jit. The linter, PHPStan and the language server report it as regex.lint.redos.search at the calls that run such a loop, and nowhere else.

key type meaning
degree int The degree of the cost in the length of the run: 2
witness object The attack: an every-match search witness
replayed bool | null Whether the step replay of the retry, pinned and refusing an empty match at its start without the JIT, found retries that take more steps the further they start from the end of the run; null when no replay was made (theoretical mode, or a confirmed analysis whose threshold is above medium)

Every-match search witness: redos_analysis.every_match_search_cost.witness

Written as the search witness is: "<prefix>" . str_repeat("<run>", $n) . "<breaker>" builds the attack.

key type meaning
prefix string What comes before the run, often empty
run string The part repeated: the search of preg_match() stops at an empty match inside it, and each retry after an empty match reads to its end
breaker string What comes after the run and fails every retry, often empty

Confirmation: redos_analysis.confirmation

key type meaning
confirmed bool Whether a replay made PCRE fail
samples list of objects Each subject tried
jit_setting bool | null The pcre.jit setting the replay ran under: the setting, not JIT availability; false, as the replay runs without JIT, but true for a heuristic verdict on a pattern holding (*SKIP:NAME), which is replayed under the JIT
backtrack_limit int | null The backtrack limit the replay ran under
recursion_limit int | null The recursion limit the replay ran under
iterations int The runs per subject
timeout_ms float The time budget of the replay, in milliseconds
timed_out bool Whether the replay ran out of time
evidence string | null What the replay showed, for people
note string | null How the replay was made, for people
error string | null Why the replay could not run

Confirmation sample: redos_analysis.confirmation.samples[]

key type meaning
input_length int The length of the subject, in bytes
duration_ms float How long the match took, in milliseconds
input_preview string | null The subject, shortened for display
preg_error_code int | null preg_last_error() after the match
preg_error string | null preg_last_error_msg() after the match

Baseline File

regex lint --generate-baseline=<file> writes the issues of the run to <file>: one JSON document, its issues sorted like the report, ending with a newline. --baseline=<file> then hides the issues it lists. An issue matches an entry by issue_id, file and pattern_hash, so a pattern that moves down its file or a reworded message does not bring it back; line only decides between entries that share all three, and an issue’s target plays no part. One entry hides one issue. A run with --baseline still reports column and file_offset for the issues left.

A baseline that is missing or does not hold this object, a plain list of entries included, is a usage error (exit code 2, stage: "usage").

{
    "version": 1,
    "issues": [
        {
            "file": "src/Example.php",
            "line": 3,
            "column": 12,
            "issue_id": "regex.group.unclosed",
            "message": "Expected ) at end of input (found eof).",
            "severity": "error",
            "pattern": "/(a/",
            "expression": null,
            "pattern_hash": "280856e984a6cedd308bdb41caaa4672"
        }
    ]
}

Baseline file: baseline

key type meaning
version int The format of the file, 1; every 2.x reads a file of version 1
issues list One entry per issue of the run, the entries below

Baseline entry: baseline.issues[]

key type meaning
file string As in the issue (see Paths); what a baseline matches on
line int As in the issue; decides between entries that match the same issues
column int | null As in the issue
issue_id string As in the issue, or "" for an issue without one; what a baseline matches on
message string As in the issue, for people
severity string As in the issue
pattern string The pattern of the issue’s result, for people; "" for an entry that has an expression
expression string | null For an issue on a pattern argument built at run time, the argument as the file writes it; null for every other entry
pattern_hash string A hash of the exact bytes of the pattern, or of the expression of an entry that has one; what a baseline matches on

A baseline written before expression existed has no such key: it is read as it was, each entry matching on its pattern.

Edit on GitHub Feedback