Req #63911 [Opn]: Ignore conflicting trait methods originationg from identical sub traits

From: Date: Sun, 06 Jan 2013 10:31:40 +0000
Subject: Req #63911 [Opn]: Ignore conflicting trait methods originationg from identical sub traits
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175783@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63911&edit=1

 ID:                 63911
 User updated by:    bitluni at bitluni dot net
 Reported by:        bitluni at bitluni dot net
 Summary:            Ignore conflicting trait methods originationg from
                     identical sub traits
 Status:             Open
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   debian
 PHP Version:        5.4.10
 Block user comment: N
 Private report:     N

 New Comment:

@necktrox

I know there is 'insteadof' but see my example, there is just one function implemented yet
still I get collision error. The traits are just usable very flat at the moment. If you have an
hirachical stucture of traits like I do, you have to do potentally exponetial count of
'insteadof's in the top level class even there's not one dublicate function
implemented.


Previous Comments:
------------------------------------------------------------------------
[2013-01-06 02:36:02] necktrox at gmail dot com

# from http://php.net/manual/de/language.oop5.traits.php

trait A {
    public function smallTalk() {
        echo 'a';
    }
    public function bigTalk() {
        echo 'A';
    }
}

trait B {
    public function smallTalk() {
        echo 'b';
    }
    public function bigTalk() {
        echo 'B';
    }
}

class Talker {
    use A, B {
        B::smallTalk insteadof A;
        A::bigTalk insteadof B;
    }
}

------------------------------------------------------------------------
[2013-01-05 18:39:11] bitluni at bitluni dot net

same issue for properties

------------------------------------------------------------------------
[2013-01-05 18:27:56] bitluni at bitluni dot net

Description:
------------
When extracting traits I would like to extract some general functions into sub traits and
'use' them in the traits where needed.
But when I compose a class out of multiple traits with sub traits I have to do obsolete statements
regardless if the colliding methods originate from same sub trait.

Just add a check if a method collides with itself

Test script:
---------------
trait A
{
    public function a(){}
}
trait B
{
    use A;
}
trait C
{
    use A;
}
class D
{
    use B, C;
}

Actual result:
--------------
Fatal error: Trait method a has not been applied, because there are collisions with other trait
methods on D in


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63911&edit=1


Thread (21 messages)

« previous php.bugs (#175783) next »