Class constant %s::%s cannot have type %s

Description

Some native PHP types are not allowed with a class constant. This is the case of void, never and callable. Any mention of them, alone or in a compsed type generates this error.

Example

<?php

class X {
     const callable|int A = 1;
}

?>

Literal Examples

  • Class constant X::A cannot have type callable|int

Solutions

  • Remove any illegal type from the definition of the constant.

  • Remove all types from the definition of the constant.