Skip to content
docsv0.24.0

EntityVerifier

Verifies a class follows one of the two entity conventions {@see Flavor} names, chosen at construction time (default {@see Flavor::Legacy}, matching this class's behavior before F3 — every existing caller that builds `new EntityVerifier()` with no argument is unaffected), mirroring exactly how {@see ControllerVerifier} picks its convention: - {@see Flavor::Legacy}: the Milpa host-app Doctrine entity convention — `#[ORM\Entity]` (+ `#[ORM\Table]`), an `#[ORM\Id]`/`#[ORM\GeneratedValue]` identity, private-only properties, typed `#[ORM\Column]`s with nullable coherence between the column and the PHP type, initialized to-many collections, an `#[ORM\PreUpdate]` + `#[ORM\HasLifecycleCallbacks]` pair when `updatedAt` is present, and that Doctrine's no-constructor hydration path actually works (nullable properties readable right after `newInstanceWithoutConstructor()`). `doctrine/orm` is an OPTIONAL dependency of `milpa/devtools` (see `composer.json`'s `suggest`) — this is the only path that needs it. {@see verify()} returns a failed {@see VerificationResult} carrying {@see DoctrineAvailability::MESSAGE} when it is not installed, the same non-throwing shape as every other verification failure this class reports (e.g. "class not found" below), rather than crashing deep inside attribute reflection. Ported 1:1 from `scripts/verify-entity.php` (reflection checks only; CLI arg parsing/formatting lives in the thin shim). - {@see Flavor::Runtime}: `milpa/data`'s plain-entity convention — implements `Milpa\Data\EntityInterface` (`id()`/`toArray()`/`fromArray()`), no Doctrine attributes. Unlike the legacy path there is no column/nullability/hydration bookkeeping to check — persistence lives entirely behind `Milpa\Data\RepositoryInterface`, outside this class. `milpa/data` is a hard `require` of `milpa/devtools` (unlike the optional `doctrine/orm`), so no availability guard is needed for this path.

EntityVerifier::__construct()

public function __construct(Milpa\DevTools\Make\Flavor $flavor = Milpa\DevTools\Make\Flavor::Legacy, ?bool $doctrineAvailable = null):

Parameters

Parameters of __construct()
NameTypeDescription
$flavorMilpa\DevTools\Make\Flavor
$doctrineAvailable(bool | null)override for testing; `null` (the default) auto-detects via {@see DoctrineAvailability::isAvailable()}

EntityVerifier::verify()

public function verify(string $fqcn): Milpa\DevTools\Verify\VerificationResult

Reflects `$fqcn` and checks it against the constructor-selected {@see Flavor}'s convention.

Parameters

Parameters of verify()
NameTypeDescription
$fqcnstring