[英]Type hinting with doctrine: Is the type attribute still required on @ORM\Column annotation when using PHP 7.4 with type hints?
@ORM\Column的 doctrine 文档说需要类型属性。 PHP 7.4 仍然适用吗? 直接在 PHP 中使用类型提示,我觉得注释中的类型属性是多余的。 有没有办法不提供类型属性并使 doctrine 从 PHP 类型提示中推断出来?
例子:
而不是使用此代码
class Client
{
/** @ORM\Column(name="code" , type="string" , length=20 , unique=true) */ private string $code;
/** @ORM\Column(name="moduleX", type="boolean", nullable=true ) */ private ?bool $moduleX;
// [...]
我想写以下内容:
class Client
{
/** @ORM\Column(name="code" , length=20, unique=true) */ private string $code;
/** @ORM\Column(name="moduleX", ) */ private ?bool $moduleX;
// [...]
如果没有,是否正在讨论该功能 - 还是有办法提出建议?
Doctrine 类型是PHP 和 SQL 类型之间的转换。 即使是简单的 PHP 类型(如string
)也可以是数据库中的 VARCHAR、DECIMAL 或 CLOB。
并且类型提示也可以是 object:
private UuidInterface $id;
如何将它存储在数据库中? 字符串,二进制,integer?
Doctrine 不了解您的应用程序业务逻辑,因此我认为反射不是注释的良好替代品。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.