mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
Do not use DateTimeImmutable.
This commit is contained in:
@@ -22,6 +22,7 @@ namespace Chill\PersonBundle\Entity;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use ArrayIterator;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||
@@ -29,9 +30,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Symfony\Component\VarDumper\VarDumper;
|
||||
|
||||
/**
|
||||
* Person
|
||||
@@ -128,14 +127,14 @@ class Person implements HasCenterInterface {
|
||||
*/
|
||||
private $fullnameCanonical;
|
||||
|
||||
public function __construct(\DateTimeImmutable $opening = null) {
|
||||
public function __construct(\DateTime $opening = null) {
|
||||
$this->accompanyingPeriods = new ArrayCollection();
|
||||
$this->spokenLanguages = new ArrayCollection();
|
||||
$this->addresses = new ArrayCollection();
|
||||
$this->altNames = new ArrayCollection();
|
||||
|
||||
if ($opening === null) {
|
||||
$opening = new \DateTimeImmutable();
|
||||
$opening = new \DateTime();
|
||||
}
|
||||
|
||||
$this->open(new AccompanyingPeriod($opening));
|
||||
@@ -747,18 +746,17 @@ class Person implements HasCenterInterface {
|
||||
/**
|
||||
* By default, the addresses are ordered by date, descending (the most
|
||||
* recent first)
|
||||
*
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getAddresses(): ArrayCollection
|
||||
{
|
||||
return $this->addresses;
|
||||
}
|
||||
|
||||
public function getLastAddress(?DateTimeImmutable $from = null): ?Address
|
||||
public function getLastAddress(DateTime $from = null)
|
||||
{
|
||||
$from ??= new DateTimeImmutable('now');
|
||||
$from ??= new DateTime('now');
|
||||
|
||||
/** @var ArrayIterator $addressesIterator */
|
||||
$addressesIterator = $this->getAddresses()
|
||||
->filter(static fn (Address $address): bool => $address->getValidFrom() <= $from)
|
||||
->getIterator();
|
||||
|
Reference in New Issue
Block a user