Cannot use %s as %s because ‘%s’ is a special class name

Description

This error reports that an alias was created with a special word, such as float, string, etc. Classes with such names are not possible, and the use command cannot use them neither.

Example

<?php

use X as string;

?>

Literal Examples

  • Cannot use X as string because ‘string’ is a special class name

  • Cannot use X as string because ‘float’ is a special class name

Solutions

  • Use another name for the import alias.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See replaceAlias.