Enum case type %s does not match enum backing type %s

Description

Enumeration may be backed with a scalar type, int or string. When doing so, each case must have a value of that type. And no type juggling happens, so '1' is not an integer, while 1 is not a string. The types must match perfectly one with another.

Example

<?php

enum E : string {
    case A = 1;
}

?>

Solutions

  • Change the type on the enumeration to fit the value.

  • Change the type on the value to fit the enumeration.

  • Remove types and values.