Imports

JS Import Statements

JS

When you add import or add references for new classes in a file they must always be at the top of the page.

Bad:

JS
...

5 import moment from '../../node_modules/moment/dist/moment';

Good:

JS
1 import moment from '../../node_modules/moment/dist/moment';

...

PHP Use Statements

When you add import or add references for new classes in a file they must always be at the top of the page, immediately after the strict_types declaration.

Bad:

PHP
<?php

use App\Http\Controllers\Controller;

declare(strict_types=1);

namespace App\Http\Controllers\Users;

...

Good:

PHP
<?php

declare(strict_types=1);

namespace App\Http\Controllers\Users;

use App\Http\Controllers\Controller;
...

Traits & Helpers

When you add traits or helper functions to classes, they need to be at the top of the class immediately after the opening bracket. Each use statement must be on its own line.

Bad:

PHP
class User extends Authenticatable implements MustVerifyEmail
{
    use HasFactory, Notifiable, HasApiTokens;

    ...
}

Good:

PHP
class User extends Authenticatable implements MustVerifyEmail
{
    use HasFactory;
    use Notifiable;
    use HasApiTokens;

    ...
}