我最近遇到一个奇怪的问题,同一对象但缺少一个属性值,在此属性的settter方法上被调用。有什么原因会发生这种情况?
OrganizationAwareTrait.php:20:string 'get--->' (length=7)
OrganizationAwareTrait.php:20:string 'userId:6' (length=8)
OrganizationAwareTrait.php:20:string '0000000058b398cc0000000054844e07' (length=32)
OrganizationAwareTrait.php:20:int 2
OrganizationAwareTrait.php:20:string '<----get' (length=8)
vendor/symfony/security/Core/Authentication/Token/Storage/TokenStorage.php:42:int 2
OrganizationAwareTrait.php:20:string 'get--->' (length=7)
OrganizationAwareTrait.php:20:string 'userId:6' (length=8)
OrganizationAwareTrait.php:20:string '0000000058b398cc0000000054844e07' (length=32)
OrganizationAwareTrait.php:20:int 2
OrganizationAwareTrait.php:20:string '<----get' (length=8)
OrganizationAwareTrait.php:20:string 'get--->' (length=7)
OrganizationAwareTrait.php:20:string 'userId:6' (length=8)
OrganizationAwareTrait.php:20:string '0000000058b398cc0000000054844e07' (length=32)
OrganizationAwareTrait.php:20:int 2
OrganizationAwareTrait.php:20:string '<----get' (length=8)
OrganizationAwareTrait.php:20:string 'get--->' (length=7)
OrganizationAwareTrait.php:20:string 'userId:6' (length=8)
OrganizationAwareTrait.php:20:string '0000000058b398cc0000000054844e07' (length=32)
OrganizationAwareTrait.php:20:int 2
OrganizationAwareTrait.php:20:string '<----get' (length=8)
OrganizationAwareTrait.php:20:string 'get--->' (length=7)
OrganizationAwareTrait.php:20:string 'userId:6' (length=8)
OrganizationAwareTrait.php:20:string '0000000058b398cc0000000054844e07' (length=32)
OrganizationAwareTrait.php:20:null
OrganizationAwareTrait.php:20:string '<----get' (length=8)
组织特质
trait OrganizationAwareTrait
{
/**
* @var OrganizationInterface
*
*/
private $organization;
/**
* @return OrganizationInterface|null
*/
public function getOrganization()
{
var_dump('get--->','userId:'.$this->getId(), spl_object_hash($this), $this->organization? $this->organization->getId(): null, '<----get');
return $this->organization;
}
/**
* @param OrganizationInterface|null $organization
* @return $this
*/
public function setOrganization(?OrganizationInterface $organization)
{
var_dump('set--->', $this->getId(), spl_object_hash($this), $organization? $organization->getId(): null, '<----get');
$this->organization = $organization;
return $this;
}
}
User.php,也不会调用用户类的序列化和反序列化。
class User {
use OrganizationTrait;
protected $otherPropertiesAreFine;
}