{"record":{"id":"0a7692b7ec41efbb","repo":"flarum/framework","slug":"errno-errstr-in-errfile-errline","errorCode":null,"errorMessage":"[$errno] $errstr in $errfile:$errline","messagePattern":"\\[\\$errno\\] \\$errstr in \\$errfile:\\$errline","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extensions/realtime/src/Websocket/Console/ServeCommand.php","lineNumber":123,"sourceCode":"            return (new WebsocketLogger($this->output))\n                ->enable($debug)\n                ->verbose($this->output->isVerbose());\n        });\n\n        $this->getLaravel()->bind(ConnectionLogger::class, function () use ($debug) {\n            return (new ConnectionLogger($this->output))\n                ->enable($debug)\n                ->verbose($this->output->isVerbose());\n        });\n    }\n\n    public function errorHandler(int $errno, string $errstr, string $errfile, int $errline): bool\n    {\n        // Don't throw exceptions for deprecation notices, warnings, or notices in debug mode\n        // Just log them to output instead\n        if (in_array($errno, [E_DEPRECATED, E_USER_DEPRECATED, E_NOTICE, E_USER_NOTICE])) {\n            if ($this->option('debug')) {\n                $this->warn(\"[$errno] $errstr in $errfile:$errline\");\n            }\n\n            return true;\n        }\n\n        // Throw exceptions for actual errors\n        throw new \\Exception(\"$errno, $errstr, $errfile:$errline\");\n    }\n\n    /**\n     * Expire stale index-typing presence and emit falling-edge \"stopped typing\"\n     * signals, so list dots clear without each client running its own per-discussion\n     * timer. Swept faster than the TTL (6s) to keep the clear-lag small.\n     */\n    protected function sweepIndexTyping(LoopInterface $loop): void\n    {\n        $presence = $this->getLaravel()->make(IndexTypingPresence::class);\n","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/extensions/realtime/src/Websocket/Console/ServeCommand.php#L105-L141","documentation":"ServeCommand's custom PHP error handler intercepts PHP warnings/notices/deprecations raised while the websocket server runs. For low-severity levels (E_DEPRECATED, E_USER_DEPRECATED, E_NOTICE, E_USER_NOTICE) it does NOT convert them to exceptions; in --debug mode it instead logs `[$errno] $errstr in $errfile:$errline` and returns true to suppress PHP's default handling. Higher severities are still thrown as exceptions.","triggerScenarios":"Running the realtime/websocket serve command (with --debug) triggers PHP code that emits a deprecation, notice, or warning — e.g. deprecated function usage in bundled dependencies or userland notices — producing this log line.","commonSituations":"PHP 8.x upgrades making previously-silent deprecations loud (e.g. dynamic properties, null-to-non-nullable args); outdated packages not yet compatible with the PHP version; debug mode enabled so the messages become visible.","solutions":["Update the package/file named in $errfile to a version compatible with your PHP version.","If the deprecation comes from your own code, replace the deprecated call per the message.","Run without --debug in production if the log noise is undesirable (still fix the source).","Confirm the message is only a deprecation/notice (errno in the low-severity set) — otherwise it would have thrown.","Pin a known-good PHP version for the server process."],"exampleFix":"// before (PHP 8.2)\n$strpos = strpos($haystack, $needle, null);\n// after\n$strpos = strpos($haystack, $needle);","handlingStrategy":"fallback","validationCode":"// Before running the server, scan for known deprecations:\n$report = error_reporting(E_ALL);\nset_error_handler(function ($no, $str, $file) { var_dump([$no, $str, $file]); return true; });\nrequire 'vendor/autoload.php';\nrestore_error_handler();","typeGuard":"$lowSeverity = in_array($errno, [E_DEPRECATED, E_USER_DEPRECATED, E_NOTICE, E_USER_NOTICE], true);\nif (!$lowSeverity) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }","tryCatchPattern":"try {\n  $server->run();\n} catch (ErrorException $e) {\n  $this->logger->warning(sprintf('[%d] %s in %s:%d', $e->getSeverity(), $e->getMessage(), $e->getFile(), $e->getLine()));\n}","preventionTips":["Run CI against the target PHP version to surface deprecations before deploy.","Keep packages updated for each PHP major upgrade.","Avoid --debug in production; log deprecations to a monitored channel instead.","Replace deprecated PHP APIs flagged in the log promptly.","Set a consistent error_reporting level across environments."],"tags":["php","deprecation","websocket","debug"],"backgroundTag":"deprecated-api-usage","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}