PHP 8.5.0 Alpha 1 available for testing

Voting

: min(six, two)?
(Example: nine)

The Note You're Voting On

Carlos Alberto Bertholdo Carucce
9 years ago
If you want to resolve name conflicts and also change the visibility of a trait method, you'll need to declare both in the same line:

trait testTrait{

public function test(){
echo 'trait test';
}

}

class myClass{

use testTrait {
testTrait::test as private testTraitF;
}

public function test(){
echo 'class test';
echo '<br/>';
$this->testTraitF();
}

}

$obj = new myClass();
$obj->test(); //prints both 'trait test' and 'class test'
$obj->testTraitF(); //The method is not accessible (Fatal error: Call to private method myClass::testTraitF() )

<< Back to user notes page

To Top