0

I was looking at some code from Laravel, and I saw this:

$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    App\Http\Kernel::class
);

I found it very curious, because it seems to be calling a object method, but what is being passed doesn't look like a variable.

What is this ::class thing?

Enrique Moreno Tent
  • 21,095
  • 29
  • 89
  • 173
  • 1
    [PHP 5.5 Classname Resolution](http://stackoverflow.com/q/24461919) – mario Jun 25 '15 at 17:00
  • Does it have a *raison d'etre*? Wouldn't it be the easier to use `$app->singleton("Illuminate\Contracts\Http\Kernel", "App\Http\Kernel");` ? – Enrique Moreno Tent Jun 25 '15 at 17:09
  • 1
    It can deobfuscate aliased class/namespace imports. (Albeit in practice it's indeed often just used as syntax gimmick.) – mario Jun 25 '15 at 17:34

0 Answers0