dobryprogramator/doctrine-safe-types
最新稳定版本:v2.0.0
Composer 安装命令:
composer require dobryprogramator/doctrine-safe-types
包简介
Doctrine types for thecodingmachine/safe package
README 文档
README
Library implementing thecodingmachine/safe DateTime and DateTimeImmutable into Doctrine.
Motivation
In PHP >= 7.4 when you use Doctrine's types and Safe property type you'll get into trap of error
Typed property App\Entity\User::$birthDate must be an instance of Safe\DateTimeImmutable, DateTimeImmutable used.
For example this entity will generate the mentioned error:
// 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; } }
This library provides safe doctrine types. The annotation would transform from @ORM\Column(type="date_immutable")
into @ORM\Column(type="safe_date_immutable")
Installation
composer require dobryprogramator/doctrine-safe-types
Put following configuration into config/packages/doctrine.yaml:
doctrine: dbal: ... types: safe_date: DobryProgramator\DoctrineSafeTypes\Type\SafeDateType safe_date_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeDateImmutableType safe_datetime: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeType safe_datetime_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeImmutableType safe_datetimetz: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeTzType safe_datetimetz_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeDateTimeTzImmutableType safe_time: DobryProgramator\DoctrineSafeTypes\Type\SafeTimeType safe_time_immutable: DobryProgramator\DoctrineSafeTypes\Type\SafeTimeImmutableType
统计信息
- 总下载量: 10.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-12