Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php override trait method and call it

trait A {
    function calc($v) {
        return $v+1;
    }
}

class MyClass {
    use A {
        calc as protected traitcalc;
    }

    function calc($v) {
        $v++;
        return $this->traitcalc($v);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #override #trait #method #call
ADD COMMENT
Topic
Name
9+3 =