“%s” will be interpreted as a class name. Did you mean “%s”? Write “%s”%s to suppress this warning

Description

PHP offers several native type, such as bool or int. These names may also be confused with boolean and integer, which are not PHP native types. They are valid for custom code usage, including creating classes or interfaces. To avoid such confusion, PHP emits this error message to make sure that integer is confused with int.

boolean, for bool, integer, for int, double, for float, and resource, for \resource, are all subjects to this error.

Example

<?php

function foo() : boolean {}

?>

Literal Examples

  • “boolean” will be interpreted as a class name. Did you mean “bool”? Write “boolean” to suppress this warning

  • “resource” will be interpreted as a class name. Did you mean “resource”?

Solutions

  • Use the PHP native type.

  • Create a use statement for the actual type.

  • Add the initial \ with this name.