The Foo\Bar::class syntax has been introduced in PHP 5.5 to allow fetching a class name as a string, in a way that respects context-dependent name resolution rules and is understood by IDEs. As it is syntactically similar to a class constant access, programmers intuitively expect the syntax $object::class to work as well and provide the same result as get_class($object) . This RFC proposes to allow that syntax.

The original rationale for not allowing the $object::class syntax was that Foo\Bar::class is resolved at compile-time, which is not possible for $object::class . However, this premise is already incorrect for two cases: First, static::class is always resolved at runtime, equivalent to get_called_class() . Second, self::class and parent::class are also sometimes resolved at runtime, for example in closures.