Hi, how are you? I'm having a problem with NULL
with Doctrine
. What happens: I have some fields in a database table where I save some values for future validations, these fields are nullable = true
. I'll give an example: When I generate a token
, I automatically generate a date for it, and when this token
is used, I pass values NULL
to the validateToken
field, which stores the date that was generated , as well as token
. To set this NULL
in setter
is quiet, the problem is when I search for getter
getValidateToken()
or getTonken()
to do some checking and it is NULL
in this case it tells me that I need to return a DateTime
in getValidateToken()
and string
in getToken()
and is returning NULL
. Below is my code and error.
/**
* @var string
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $validateToken;
/**
* @return string
*/
public function getToken(): string
{
return $this->token;
}
/**
* @param string $token
*
* @return User
*/
public function setToken(string $token = null): User
{
$this->token = $token;
return $this;
}
/**
* @return \DateTime
*/
public function getValidateToken(): \DateTime
{
return $this->validateToken;
}
/**
* @param \DateTime $validateToken
*
* @return User
*/
public function setValidateToken(\DateTime $validateToken = null): User
{
$this->validateToken = $validateToken;
return $this;
}
I know I can remove the: string and o: \ DateTime but must have a way to do it without removing.
Thanks