Open issues in Doctrine Helper

Open issues in Doctrine Helper

Known bugs and inconsistencies of the current version of ufo-tech/doctrine-helper (1.1.0). Fixed ones are on the Fixed issues page.

AutoIncrementIdTrait is incompatible with IHaveAutoincrementId

Open

Affected versions: 1.0.0 — 1.1.0 (current). Verified by running on PHP 8.4.

Symptom. A class that implements IHaveAutoincrementId and uses AutoIncrementIdTrait does not load:

Fatal error: Declaration of App\Entity\Customer::getId(): ?int must be compatible with
Ufo\DoctrineHelper\Interfaces\IHaveAutoincrementId::getId(): int

Cause. AutoIncrementIdTrait::getId() returns ?int (there is no identifier before flush()), while the interface requires int.

Workaround. Do not implement the interface, or override the method in the class — a class method takes precedence over a trait method:

#[ORM\Entity]
class Customer implements IHaveAutoincrementId
{
    use AutoIncrementIdTrait;

    public function getId(): int
    {
        return $this->id ?? throw new \LogicException('Customer is not persisted yet.');
    }
}

AbstractEnumType does not accept null

Open

Affected versions: 1.0.0 — 1.1.0 (current). Verified by running on PHP 8.4 with DBAL 3.10; DBAL 4 passes null to the type in the same way.

Symptom. Writing null to a column with an AbstractEnumType-based type, even with nullable: true, fails with InvalidArgumentException: Invalid 'App\MyEnum' value. (on PHP 8.1+ preceded by the deprecation Passing null to parameter #1 ($value)).

Cause. DBAL calls convertToDatabaseValue() for null too, and the method passes the value to $enum::from() without a check; any error is turned into InvalidArgumentException. The string|int return type does not allow fixing this by overriding the method in a subclass.

Workaround. For nullable fields use Doctrine ORM's built-in enum mapping instead of this type — #[ORM\Column(type: 'string', enumType: MyEnum::class, nullable: true)] (the column is then VARCHAR, not ENUM) — or a dedicated enum case for a missing value.


Errors in the package README

Open

Affected versions: 1.0.0 — 1.1.0 (current). Verified against README.md and composer.json of tag 1.1.0.

  • In the entity example changeCase() writes to the non-existent $this->type property instead of $this->case.
  • The MyEnumType example lacks use Ufo\DoctrineHelper\DBAL\AbstractEnumType;.
  • The README describes only AbstractEnumType; the traits, interfaces and Uuid are not mentioned.
  • The homepage link in composer.json and "Documentations" in the README point to docs.ufo-tech.space, not to this site.

Correct examples are on the PHP enum as ENUM and Entity identifiers pages.