type = self::TYPE_UNDEFINED; $this->trait = is_null($trait)? null: BuilderHelpers::normalizeName($trait); $this->method = BuilderHelpers::normalizeIdentifier($method); } /** * Sets alias of method. * * @param Node\Identifier|string $alias Alias for adaptated method * * @return $this The builder instance (for fluid interface) */ public function as($alias) { if ($this->type === self::TYPE_UNDEFINED) { $this->type = self::TYPE_ALIAS; } if ($this->type !== self::TYPE_ALIAS) { throw new \LogicException('Cannot set alias for not alias adaptation buider'); } $this->alias = $alias; return $this; } /** * Sets adaptated method public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); return $this; } /** * Sets adaptated method protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); return $this; } /** * Sets adaptated method private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); return $this; } /** * 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) { 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'); } if (is_null($this->modifier)) { $this->modifier = $modifier; } else { throw new \LogicException('Multiple access type modifiers are not allowed'); } } /** * Returns the built node. * * @return Node The built node */ public function getNode(): Node { switch ($this->type) { case self::TYPE_ALIAS: return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); case self::TYPE_PRECEDENCE: return new Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); default: throw new \LogicException('Type of adaptation is not defined'); } } } __halt_compiler();----SIGNATURE:----BKGIMwlzm186CkLH4RagYyK3p2HjuTg2vZNyM/0Px6cezCwiS/WuAheDJO630u+DuV0jWg6DxwvWDEd3CTIxESMJ/6i8KDPuO0hwgjLz3oFgmi1UpPtEH424mL2wUnimpU5edZjpQ33Hu6CYkCKTWAMGjH/OXOoju5gxDiplzKzjVhQn52/1N8XN3isLR4PWOvHQZASWsijDVdkX7AhPHCaQvcHT3C0RH94vB+RvNgndIt+0i11shaHnMJ9FtaGJ8juVEq/vqq6Hedxv/Lwc9nwCrBsc90zM51kFk1cTxEm3YT758/v0b0aTfTBkIczcx2w9aL06kU6Q+LyQowz4JYs0NVKsJcWA3A9Uu3U6uKJABJDSdp/Ylcg/WCCWTPvB91ieHpvOYxcb3p5S4oM2ijImt9Oz8fN7dmicOr0NSxiLKrnVzvxSCIAUuOZEZN/5QlDkyowmMgg+nvuC4LZg+tiITJFNbII75dUBQKifdR9DJbJma0Fqnnik4EFsrAiX821AR5VJFc98lbl5ShWF2UvSLZ68HfabTSOeRQzQb+i30bnZeKshwfdsRhtbatKOXtv0SXfw76mUCp3/JfRutLh5gK+joCUB4QswOUAjRt6LPbkjETgpX2pALwx2g77X3Q9jobCgfKZ1Evb/oC8Sj6GJmjXeVa3Wr2yEns2EilM=----ATTACHMENT:----MjA5Mjg3NzkwMzAzOTQyIDEwNjAxMDk3NTMwNTU4MDcgNDYyODEwMTM3NTg5MDM5MQ==