Answers for "php override trait method and call it"

PHP
1

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);
    }
}
Posted by: Guest on May-05-2020

Code answers related to "php override trait method and call it"

Browse Popular Code Answers by Language