Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Trait method "x" was already imported. #71

Open
POPSuL opened this issue Oct 11, 2015 · 2 comments
Open

Fatal error: Trait method "x" was already imported. #71

POPSuL opened this issue Oct 11, 2015 · 2 comments

Comments

@POPSuL
Copy link

POPSuL commented Oct 11, 2015

Example:

TraitA.php

<?php

namespace T;

trait TraitA
{

    abstract public function x();
}

TraitB.php

<?php

namespace T;

trait TraitB
{

    abstract public function x();
}

TraitAggregate.php

<?php

namespace T;

trait TraitAggregate
{

    use TraitA, TraitB;
}

T.php

<?php

namespace T;

class T
{
    use TraitAggregate;

    public function x() {
        echo "foo";
    }
}

And test.php:

<?php

use TokenReflection\Broker;

require 'vendor/autoload.php';

$t = new \T\T();
$t->x();

$broker = new Broker(new Broker\Backend\Memory());
$broker->processDirectory('./src');

$class = $broker->getClass('T\T');
var_dump($class->getMethods());

Result:

 % php ./test.php
fooPHP Fatal error:  Uncaught exception 'TokenReflection\Exception\RuntimeException' with message 'Trait method "x" was already imported.' in /home/popsul/projects/traits/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php on line 734
Thrown when working with "T\TraitAggregate".

Stack trace:
#0 /home/popsul/projects/traits/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php(607): TokenReflection\ReflectionClass->getTraitMethods()
#1 /home/popsul/projects/traits/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php(701): TokenReflection\ReflectionClass->getMethods(NULL)
#2 /home/popsul/projects/traits/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php(607): TokenReflection\ReflectionClass->getTraitMethods()
#3 /home/popsul/projects/traits/test.php(14): TokenReflection\ReflectionClass->getMethods()
#4 {main}

  thrown in /home/popsul/projects/traits/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php on line 734
@POPSuL
Copy link
Author

POPSuL commented Oct 11, 2015

This issue related to #60

@yoosefi
Copy link

yoosefi commented Sep 20, 2016

Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants