{"record":{"id":"1e9ae1ae8bfed5eb","repo":"Seldaek/monolog","slug":"failed-to-run-preg-replace-callback-code-m","errorCode":null,"errorMessage":"Failed to run preg_replace_callback: ${code} / ${message}","messagePattern":"Failed to run preg_replace_callback: (.+?) / (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/BrowserConsoleHandler.php","lineNumber":246,"sourceCode":"\n        $style = preg_replace_callback('/macro\\s*:(.*?)(?:;|$)/', function (array $m) use ($string, &$colors, &$labels) {\n            if (trim($m[1]) === 'autolabel') {\n                // Format the string as a label with consistent auto assigned background color\n                if (!isset($labels[$string])) {\n                    $labels[$string] = $colors[\\count($labels) % \\count($colors)];\n                }\n                $color = $labels[$string];\n\n                return \"background-color: $color; color: white; border-radius: 3px; padding: 0 2px 0 2px\";\n            }\n\n            return $m[1];\n        }, $style);\n\n        if (null === $style) {\n            $pcreErrorCode = preg_last_error();\n\n            throw new \\RuntimeException('Failed to run preg_replace_callback: ' . $pcreErrorCode . ' / ' . preg_last_error_msg());\n        }\n\n        return $style;\n    }\n\n    /**\n     * @param  mixed[] $dict\n     * @return mixed[]\n     */\n    private static function dump(string $title, array $dict): array\n    {\n        $script = [];\n        $dict = array_filter($dict, fn ($value) => $value !== null);\n        if (\\count($dict) === 0) {\n            return $script;\n        }\n        $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title));\n        foreach ($dict as $key => $value) {","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/BrowserConsoleHandler.php#L228-L264","documentation":"Error \"Failed to run preg_replace_callback: ${code} / ${message}\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/BrowserConsoleHandler.php:246 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}