{"record":{"id":"510685ab892971e7","repo":"rectorphp/rector","slug":"an-invalid-bound","errorCode":null,"errorMessage":"an invalid bound","messagePattern":"an invalid bound","errorType":"validation","errorClass":"InvalidEregException","httpStatus":null,"severity":"error","filePath":"rules/Php70/EregToPcreTransformer.php","lineNumber":262,"sourceCode":"            return '\\\\' . $content;\n        }\n        return $content;\n    }\n    /**\n     * @param array<int, mixed> $r\n     */\n    private function processCurlyBracket(string $s, int $i, array &$r, int $rr): int\n    {\n        $ii = strpos($s, '}', $i);\n        if ($ii === \\false) {\n            throw new InvalidEregException('\"{\" does not have a matching \"}\"');\n        }\n        $start = $i + 1;\n        $length = $ii - ($i + 1);\n        $bound = Strings::substring($s, $start, $length);\n        $matches = Strings::match($bound, self::BOUND_REGEX);\n        if ($matches === null) {\n            throw new InvalidEregException('an invalid bound');\n        }\n        if (isset($matches[self::MAXIMAL_NUMBER_PART])) {\n            if ($matches[self::MINIMAL_NUMBER_PART] > $matches[self::MAXIMAL_NUMBER_PART]) {\n                throw new InvalidEregException('an invalid bound');\n            }\n            $r[$rr] .= '{' . $matches[self::MINIMAL_NUMBER_PART] . ',' . $matches[self::MAXIMAL_NUMBER_PART] . '}';\n        } elseif (isset($matches['comma'])) {\n            $r[$rr] .= '{' . $matches[self::MINIMAL_NUMBER_PART] . ',}';\n        } else {\n            $r[$rr] .= '{' . $matches[self::MINIMAL_NUMBER_PART] . '}';\n        }\n        return $ii + 1;\n    }\n    /**\n     * @return int[]|string[]\n     */\n    private function processCharacterClass(string $content, int $i, string $cls): array\n    {","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/Php70/EregToPcreTransformer.php#L244-L280","documentation":"processCurlyBracket() extracted the text between '{' and '}' and validated it against BOUND_REGEX, which accepts only a minimum of 0-255 optionally followed by a comma and a maximum of 0-255 (or empty after the comma). Anything else — letters, spaces, numbers above 255, malformed commas — fails the match and InvalidEregException('an invalid bound') is thrown (EregToPcreTransformer.php:262), stopping the ereg-to-preg conversion.","triggerScenarios":"Rector (Php70 set / EregToPregMatchRector, target PHP >= 7.0) encounters an ereg-family call whose literal pattern has a syntactically complete but semantically invalid bound: `ereg('a{x}', $s)`, `split('a{2,3,4}', $s)`, `ereg('a{ 2}', $s)`, or out-of-range counts like `ereg('a{300}', $s)` / `ereg('a{1,999}', $s)` — BOUND_REGEX caps both parts at 25[0-5].","commonSituations":"Placeholder braces misread as quantifiers ('{name}', '{0}'); counts written for other regex dialects that allow larger or negative bounds; patterns edited so stray characters landed between the braces.","solutions":["Rewrite the bound to the accepted form in the flagged file: 'a{x}' -> 'a{2}', 'a{300}' -> repeat the atom or use '*'/'+' plus custom logic, 'a{2,3,4}' -> 'a{2,3}'.","If the braces are literal text, escape them: 'a\\{x\\}'.","Re-run rector; preflight literal ereg patterns for '{...}' content that is not a 1-3 digit number, optionally followed by a comma and 0-3 digits, with values <= 255."],"exampleFix":"// before - bound content not 0-255[/0-255]\nereg('a{300}', $subject);\n\n// after - valid bound\nereg('a{2}', $subject); // rector: preg_match('#a{2}#m', $subject)","handlingStrategy":"validation","validationCode":"// quick lint: bound body must be 1-3 digits, optional comma and 0-3 digits, values <= 255\nfunction boundValid(string $body): bool {\n    if (!preg_match('~^([0-9]{1,3})(,([0-9]{0,3}))?$~', $body, $m)) return false;\n    if ((int) $m[1] > 255) return false;\n    return !isset($m[3]) || $m[3] === '' || (int) $m[3] <= 255;\n}","typeGuard":null,"tryCatchPattern":"try {\n    $pcre = $eregToPcreTransformer->transform($pattern, $ignoreCase);\n} catch (InvalidEregException $e) {\n    // bound body not '0-255[,0-255]' — rewrite it or escape literal braces\n    continue;\n}","preventionTips":["Keep {min,max} counts within 0-255; restructure the pattern for larger repetitions.","Escape braces used as placeholders ('\\{name\\}') so they are not parsed as bounds.","Avoid spaces or extra commas inside bounds; ERE accepts none."],"tags":["rector","php","regex","posix-ere","quantifier","bound","migration"],"backgroundTag":"invalid-regex-syntax","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}