I know it is very uncommon to use protected methods or constructors. I have read discussions about this on SO and other sites. The task I've got is rather simple. I have to access protected methods/constructors from my program. All attributes/methods must be declared as protected.
My code can be reduced to this. I'm basically asked to do this with the easiest/simplest way. All solutions I can think of either use some more advanced technique ("friends" etc) or a public function, which is against the rules.
Thank you.
class one
{
protected $attribute1;
}
class two extends one
{
protected $attribute2;
protected $attribute3;
protected function __construct($arg1, $arg2, $arg3)
{
$this->attribute1= $arg1;
$this->attribute2= $arg2;
$this->attribute3= $arg3;
}
}
$object = new two(" 1", "2", "3");