{"record":{"id":"ec84ece0b2cf2c5e","repo":"nikic/PHP-Parser","slug":"precedence-adaptation-must-have-trait","errorCode":null,"errorMessage":"Precedence adaptation must have trait","messagePattern":"Precedence adaptation must have trait","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"lib/PhpParser/Builder/TraitUseAdaptation.php","lineNumber":97,"sourceCode":"     *\n     * @return $this The builder instance (for fluid interface)\n     */\n    public function makePrivate() {\n        $this->setModifier(Modifiers::PRIVATE);\n        return $this;\n    }\n\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) {","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/nikic/PHP-Parser/blob/fbd47f7ebcbb450138d92642a0a53b72a5285dda/lib/PhpParser/Builder/TraitUseAdaptation.php#L79-L115","documentation":"Error \"Precedence adaptation must have trait\" thrown in nikic/PHP-Parser.","triggerScenarios":"Thrown at lib/PhpParser/Builder/TraitUseAdaptation.php:97 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"}