Category : enums

hi i just started to use enums in php 8.1 but when i used it i get the error below Parse error: syntax error, unexpected identifier "SanitizeFilters" in C:Apache24htdocsminaremon.comclassesenumsSanitizeFilters.php on line 3 attached my created enum code : namespace classesenums; enum SanitizeFilters { case FILTER_FLAG_STRIP_LOW; case FILTER_FLAG_STRIP_HIGH; case FILTER_FLAG_STRIP_BACKTICK; case FILTER_FLAG_ENCODE_LOW; case FILTER_FLAG_ENCODE_HIGH; case FILTER_FLAG_ALLOW_FRACTION; ..

Read more

In my Symfony project I to define enum types for string field: class Log { const TYPE = [ 0 => ‘invite’, 1 => ‘revoke’ ]; /** * @ORMColumn(type="string", nullable=false) * @AssertNotBlank */ private $type; } And then in my setter: $newLog->setType(Log::TYPE[0]); Is this the right approach for setting enum types within Symfony or there ..

Read more