1. Go to this page and download the library: Download nepada/consistence-doctrine library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nepada / consistence-doctrine example snippets
/**
* @phpstan-extends \Nepada\ConsistenceDoctrine\StringEnumType<\FooEnum>
*/
class FooEnumType extends \Nepada\ConsistenceDoctrine\StringEnumType
{
protected function getEnumClassName(): string
{
return \FooEnum::class;
}
}
$result = $repository->createQueryBuilder('bar')
->select('bar.foo') // FooEnum instances are created during hydratation
->where('bar.foo = :fooEnum')
->setParameter('fooEnum', \FooEnum::get(\FooEnum::VALUE), \FooEnum::class) // enum instance gets serialized
->getQuery()
->setMaxResults(1)
->getSingleResult();