Permalink
Browse files

Use the ::class notation

1 parent bacda07 commit 16e37cb3704d1dc0bb7a55ef1747eb3c742f439f @pespantelis pespantelis committed Jun 8, 2015
Showing with 10 additions and 10 deletions.
  1. +1 −1 artisan
  2. +6 −6 bootstrap/app.php
  3. +1 −1 database/factories/ModelFactory.php
  4. +1 −1 public/index.php
  5. +1 −1 tests/TestCase.php
View
@@ -28,7 +28,7 @@ $app = require_once __DIR__.'/bootstrap/app.php';
|
*/
-$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
+$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
View
@@ -27,18 +27,18 @@
*/
$app->singleton(
- 'Illuminate\Contracts\Http\Kernel',
- 'App\Http\Kernel'
+ Illuminate\Contracts\Http\Kernel::class,
+ App\Http\Kernel::class
);
$app->singleton(
- 'Illuminate\Contracts\Console\Kernel',
- 'App\Console\Kernel'
+ Illuminate\Contracts\Console\Kernel::class,
+ App\Console\Kernel::class
);
$app->singleton(
- 'Illuminate\Contracts\Debug\ExceptionHandler',
- 'App\Exceptions\Handler'
+ Illuminate\Contracts\Debug\ExceptionHandler::class,
+ App\Exceptions\Handler::class
);
/*
@@ -11,7 +11,7 @@
|
*/
-$factory->define('App\User', function ($faker) {
+$factory->define(App\User::class, function ($faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
View
@@ -47,7 +47,7 @@
|
*/
-$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
+$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
View
@@ -18,7 +18,7 @@ public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
- $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
+ $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
}

11 comments on commit 16e37cb

@roud-y
roud-y commented on 16e37cb Jun 15, 2015

When I hit php artisan, I got a parse error in the artisan file at line 31
Parse error: parse error, expecting "identifier (T_STRING)"' or"variable (T_VARIABLE)"' or '{'' or'$''

@pespantelis
Contributor

What version of PHP are you using?

@brayniverse
Contributor

@pespantelis ::class was introduced in PHP 5.5, you can find details here. Laravel 5.1 bumps the minimum PHP version to 5.5 which is why this is being used.

@pespantelis
Contributor

@brayniverse I know that.. @roud-y probably has an older version of php and I tried to help him.

@brayniverse
Contributor

@pespantelis oh I am sorry, I didn't realise your message was for @roud-y, I thought you were asking about the commit.

@pespantelis
Contributor

no problem :)

@roud-y
roud-y commented on 16e37cb Jun 15, 2015

my current version of php is 5.4.24, I guess I will have to update my version. Thanks for your answers guys!
@pespantelis @brayniverse

@imcookie

I had read the doc's, but i don't realise for what this is usefull for in this case?

@barryvdh
Contributor

Having your IDE notice typo's, autocomplete your classes and be able to click+follow to the class ;)
If you don't use an IDE, you probably don't care. The effect is the same anyways.

@imcookie

Thanks for exploration, im using phpstorm .

@briedis
briedis commented on 16e37cb Jul 9, 2015

Thanks for this!!!

Please sign in to comment.