'PHP Classname not seen as callable

<?php
class StorageMapper
{
    public function __invoke(string $entity, array $storageServices): StorageServiceInterface
    {
        $globalEntities = [
            'Customer::class',
            'CustomerSetting::class',
            'UserSetting::class',
        ];

        return \in_array($entity, $globalEntities, true) ?
            $storageServices['db1'] :
            $storageServices['db2'];
    }

    public function __call($name, $args) {
        // Hello
    }
    
    public static function __callStatic($name, $arguments)
    {
        // Note: value of $name is case sensitive.
        echo "Calling static method '$name' "
             . implode(', ', $arguments). "\n";
    }
}

echo(is_callable(StorageMapper::class) ? 'true' : 'false');

It should see this class as callable, since it has __invoke, and even has __callStatic methods. Why doesn't it? How should this be fixed?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source