PHP code example of dobryprogramator / doctrine-safe-types
1. Go to this page and download the library: Download dobryprogramator/doctrine-safe-types library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dobryprogramator / doctrine-safe-types example snippets
// src/Entity/User.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Safe\DateTimeImmutable as SafeDateTimeImmutable;
/**
* @ORM\Entity
*/
class User
{
...
/**
* @ORM\Column(type="date_immutable")
*/
private SafeDateTimeImmutable $birthday;
...
public function setBirthday(SafeDateTimeImmutable $birthday): void
{
$this->birthday = $birthday;
}
public function getBirthday(): SafeDateTimeImmutable
{
return $this->birthday;
}
}