{"record":{"id":"b2e5cb2bf181f295","repo":"symfony/process","slug":"process-must-be-started-before-calling-s","errorCode":null,"errorMessage":"Process must be started before calling \"%s()\".","messagePattern":"Process must be started before calling \"(.+?)\\(\\)\"\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"Process.php","lineNumber":1658,"sourceCode":"        }\n\n        $cmd = $comSpec.' /V:ON /E:ON /D /C ('.str_replace(\"\\n\", ' ', $cmd).')';\n        foreach ($this->processPipes->getFiles() as $offset => $filename) {\n            $cmd .= ' '.$offset.'>\"'.$filename.'\"';\n        }\n\n        return $cmd;\n    }\n\n    /**\n     * Ensures the process is running or terminated, throws a LogicException if the process has a not started.\n     *\n     * @throws LogicException if the process has not run\n     */\n    private function requireProcessIsStarted(string $functionName): void\n    {\n        if (!$this->isStarted()) {\n            throw new LogicException(\\sprintf('Process must be started before calling \"%s()\".', $functionName));\n        }\n    }\n\n    /**\n     * Ensures the process is terminated, throws a LogicException if the process has a status different than \"terminated\".\n     *\n     * @throws LogicException if the process is not yet terminated\n     */\n    private function requireProcessIsTerminated(string $functionName): void\n    {\n        if (!$this->isTerminated()) {\n            throw new LogicException(\\sprintf('Process must be terminated before calling \"%s()\".', $functionName));\n        }\n    }\n\n    /**\n     * Escapes a string to be used as a shell argument.\n     */","sourceCodeStart":1640,"sourceCodeEnd":1676,"githubUrl":"https://github.com/symfony/process/blob/99b85026db14a68f02c6f3eeb01a1170ca25c491/Process.php#L1640-L1676","documentation":"requireProcessIsStarted() guards APIs that need a live or at least started process. Calling wait(), waitUntil() or any output reader before start()/run() throws a LogicException naming the called function.","triggerScenarios":"Calling $process->wait() or $process->getOutput() before $process->start(); calling wait() after constructing a Process without running it.","commonSituations":"Misordered code where start() is conditional but wait() is not, reading output before run(), tests forgetting to start the process.","solutions":["Call start() or run() before wait()/getOutput()","Use run() instead of separate start()+wait() when possible","Add an isStarted() guard before calling these methods"],"exampleFix":"// before\n$process = new Process(['ls']);\n$process->wait();\n// after\n$process = new Process(['ls']);\n$process->run();\n// or $process->start(); ... $process->wait();","handlingStrategy":"validation","validationCode":"if (!$process->isStarted()) {\n    $process->start();\n}\n$process->wait();","typeGuard":null,"tryCatchPattern":"try { $process->wait(); } catch (LogicException $e) { $process->run(); }","preventionTips":["Prefer run() over manual start()+wait() for simple cases","Wrap process execution in a helper that enforces lifecycle order","Never call wait()/getOutput() on a freshly constructed Process"],"tags":["php","process","lifecycle","not-started"],"backgroundTag":"invalid-state-transition","analyzedSha":"99b85026db14a68f02c6f3eeb01a1170ca25c491","analyzedAt":"2026-09-14T11:23:33.683Z","contentChangedAt":"2026-09-14T11:23:33.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}