{"record":{"id":"31dc2cafca07e129","repo":"nikic/PHP-Parser","slug":"cannot-add-overwritten-traits-for-not-precedence-a","errorCode":null,"errorMessage":"Cannot add overwritten traits for not precedence adaptation buider","messagePattern":"Cannot add overwritten traits for not precedence adaptation buider","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"lib/PhpParser/Builder/TraitUseAdaptation.php","lineNumber":104,"sourceCode":"\n    /**\n     * Adds overwritten traits.\n     *\n     * @param Node\\Name|string ...$traits Traits for overwrite\n     *\n     * @return $this The builder instance (for fluid interface)\n     */\n    public function insteadof(...$traits) {\n        if ($this->type === self::TYPE_UNDEFINED) {\n            if (is_null($this->trait)) {\n                throw new \\LogicException('Precedence adaptation must have trait');\n            }\n\n            $this->type = self::TYPE_PRECEDENCE;\n        }\n\n        if ($this->type !== self::TYPE_PRECEDENCE) {\n            throw new \\LogicException('Cannot add overwritten traits for not precedence adaptation buider');\n        }\n\n        foreach ($traits as $trait) {\n            $this->insteadof[] = BuilderHelpers::normalizeName($trait);\n        }\n\n        return $this;\n    }\n\n    protected function setModifier(int $modifier): void {\n        if ($this->type === self::TYPE_UNDEFINED) {\n            $this->type = self::TYPE_ALIAS;\n        }\n\n        if ($this->type !== self::TYPE_ALIAS) {\n            throw new \\LogicException('Cannot set access modifier for not alias adaptation buider');\n        }\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/nikic/PHP-Parser/blob/fbd47f7ebcbb450138d92642a0a53b72a5285dda/lib/PhpParser/Builder/TraitUseAdaptation.php#L86-L122","documentation":"Error \"Cannot add overwritten traits for not precedence adaptation buider\" thrown in nikic/PHP-Parser.","triggerScenarios":"Thrown at lib/PhpParser/Builder/TraitUseAdaptation.php:104 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":"fbd47f7ebcbb450138d92642a0a53b72a5285dda","analyzedAt":"2026-08-17T03:58:32.123Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}