Skip to content

addTraitAlias error, Invalid Alias: Method name already exists on this class #97

Open
@titrxw

Description

@titrxw

throw new Exception\InvalidArgumentException('Invalid Alias: Method name already exists on this class.');

throw new Exception\RuntimeException(sprintf(

trait TestTrait {
	public function instance() {

	}
}

class Test {
	use TestTrait {
		instance as InstanceAs;
	}
}

$classGenerator = ClassGenerator::fromReflection(new ClassReflection(Test::class));
$classGenerator->addTrait(TestTrait::class);
$classGenerator->addTraitAlias([
	'traitName' => 'TestTrait',
	'method' => 'instance'
], 'InstanceAs');

Trigger an exception. The exception message is

PHP Fatal error:  Uncaught Laminas\Code\Generator\Exception\InvalidArgumentException: Invalid Alias: Method name already exists on this class. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions