string(6) "foobar"
string(6) "barfoo"
<?php | |
class HasProtectedProperty { | |
protected $myProtectedProperty; | |
public function __construct() | |
{ | |
$this->myProtectedProperty = 'foobar'; | |
} | |
public function getProtectedProperty(HasProtectedProperty $hasProtectedProperty) | |
{ | |
return $hasProtectedProperty->myProtectedProperty; | |
} | |
} | |
$newProtectedProperty = new HasProtectedProperty(); | |
$readProtectedProperty = new HasProtectedProperty(); | |
var_dump($readProtectedProperty->getProtectedProperty($newProtectedProperty)); | |
class HasPrivateProperty { | |
private $myPrivateProperty; | |
public function __construct() | |
{ | |
$this->myPrivateProperty = 'barfoo'; | |
} | |
public function getPrivateProperty(HasPrivateProperty $hasPrivateProperty) | |
{ | |
return $hasPrivateProperty->myPrivateProperty; | |
} | |
} | |
$newPrivateProperty = new HasPrivateProperty(); | |
$readPrivateProperty = new HasPrivateProperty(); | |
var_dump($readPrivateProperty->getPrivateProperty($newPrivateProperty)); |