Skip to content

MIR0713

BackedEnumCaseTypeMismatch

A backed enum case has a value that doesn’t match the enum’s backing type.

<?php
enum Status: int {
case Draft = 'draft'; // Error: string value for int-backed enum
case Published = 1;
}

Use values that match the enum’s backing type:

<?php
enum Status: int {
case Draft = 0;
case Published = 1;
}
// Or use string-backed enum
enum Status: string {
case Draft = 'draft';
case Published = 'published';
}