nikic/PHP-Parser · error · LogicException
Cannot add overwritten traits for not precedence adaptation
Error message
Cannot add overwritten traits for not precedence adaptation buider
What it means
Error "Cannot add overwritten traits for not precedence adaptation buider" thrown in nikic/PHP-Parser.
Source
Thrown at lib/PhpParser/Builder/TraitUseAdaptation.php:104
/**
* Adds overwritten traits.
*
* @param Node\Name|string ...$traits Traits for overwrite
*
* @return $this The builder instance (for fluid interface)
*/
public function insteadof(...$traits) {
if ($this->type === self::TYPE_UNDEFINED) {
if (is_null($this->trait)) {
throw new \LogicException('Precedence adaptation must have trait');
}
$this->type = self::TYPE_PRECEDENCE;
}
if ($this->type !== self::TYPE_PRECEDENCE) {
throw new \LogicException('Cannot add overwritten traits for not precedence adaptation buider');
}
foreach ($traits as $trait) {
$this->insteadof[] = BuilderHelpers::normalizeName($trait);
}
return $this;
}
protected function setModifier(int $modifier): void {
if ($this->type === self::TYPE_UNDEFINED) {
$this->type = self::TYPE_ALIAS;
}
if ($this->type !== self::TYPE_ALIAS) {
throw new \LogicException('Cannot set access modifier for not alias adaptation buider');
}
View on GitHub (pinned to fbd47f7ebc)
When it happens
Trigger: Thrown at lib/PhpParser/Builder/TraitUseAdaptation.php:104 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nikic/PHP-Parser@fbd47f7ebc (2026-08-17).
Data as JSON: /api/errors/31dc2cafca07e129.
Report an issue: GitHub.