diff --git a/src/Linters/QualifiedNamesOnlyForClassName.php b/src/Linters/QualifiedNamesOnlyForClassName.php index c0224f7..4466e6b 100644 --- a/src/Linters/QualifiedNamesOnlyForClassName.php +++ b/src/Linters/QualifiedNamesOnlyForClassName.php @@ -14,7 +14,7 @@ class QualifiedNamesOnlyForClassName extends BaseLinter public function lint(Parser $parser) { - if (preg_match('/\.blade\.php$/i', $this->filename)) { + if ($this->filename && preg_match('/\.blade\.php$/i', $this->filename)) { return []; } diff --git a/tests/Formatting/Formatters/ArrayParametersOverViewWithTest.php b/tests/Formatting/Formatters/ArrayParametersOverViewWithTest.php index 8ece992..7385899 100644 --- a/tests/Formatting/Formatters/ArrayParametersOverViewWithTest.php +++ b/tests/Formatting/Formatters/ArrayParametersOverViewWithTest.php @@ -12,32 +12,32 @@ class ArrayParametersOverViewWithTest extends TestCase public function catches_view_with_method_usage_in_controller_methods() { $file = <<<'file' -with('testing', '1212'); - } -} -file; + class Controller + { + function index() + { + return view('test.view')->with('testing', '1212'); + } + } + file; $expected = <<<'file' - '1212']); - } -} -file; + class Controller + { + function index() + { + return view('test.view', ['testing' => '1212']); + } + } + file; $formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file)); @@ -48,32 +48,32 @@ function index() public function catches_view_with_chained_method_usage_in_controller_methods() { $file = <<<'file' -with('first', 'yes')->with('second', 'no')->with('third', 'maybe'); - } -} -file; + class Controller + { + function index() + { + return view('test.view')->with('first', 'yes')->with('second', 'no')->with('third', 'maybe'); + } + } + file; $expected = <<<'file' - 'yes', 'second' => 'no', 'third' => 'maybe']); - } -} -file; + class Controller + { + function index() + { + return view('test.view', ['first' => 'yes', 'second' => 'no', 'third' => 'maybe']); + } + } + file; $formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file)); @@ -84,35 +84,35 @@ function index() public function catches_view_with_chained_new_lines_method_usage_in_controller_methods() { $file = <<<'file' -with('first', 'gold') - ->with('second', 'silver') - ->with('third', 'bronze'); - } -} -file; + with('first', 'gold') + ->with('second', 'silver') + ->with('third', 'bronze'); + } + } + file; $expected = <<<'file' - 'gold', 'second' => 'silver', 'third' => 'bronze']); - } -} -file; + class Controller + { + function index() + { + return view('test.view', ['first' => 'gold', 'second' => 'silver', 'third' => 'bronze']); + } + } + file; $formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file)); @@ -122,21 +122,21 @@ function index() /** @test */ public function catches_view_with_method_usage_in_routes() { - $file = <<with('test', 'test'); -}); -file; + \Route::get('test', function () { + return view('test')->with('test', 'test'); + }); + file; - $expected = << 'test']); -}); -file; + \Route::get('test', function () { + return view('test', ['test' => 'test']); + }); + file; $formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file)); @@ -147,62 +147,62 @@ public function catches_view_with_method_usage_in_routes() public function catches_multiple_view_with_usage_in_controller_methods() { $file = <<<'file' -with('first', 'yes'); - } - - function show() - { - return view('test.show', ['first' => 'yes']); - } - - function create() - { - return view('test.create'); - } - - function edit() - { - return view('test.edit')->with('first', 'yes')->with('second', 'no'); - } -} -file; + with('first', 'yes'); + } + + function show() + { + return view('test.show', ['first' => 'yes']); + } + + function create() + { + return view('test.create'); + } + + function edit() + { + return view('test.edit')->with('first', 'yes')->with('second', 'no'); + } + } + file; $expected = <<<'file' - 'yes']); - } - - function show() - { - return view('test.show', ['first' => 'yes']); - } - - function create() - { - return view('test.create'); - } - - function edit() - { - return view('test.edit', ['first' => 'yes', 'second' => 'no']); - } -} -file; + 'yes']); + } + + function show() + { + return view('test.show', ['first' => 'yes']); + } + + function create() + { + return view('test.create'); + } + + function edit() + { + return view('test.edit', ['first' => 'yes', 'second' => 'no']); + } + } + file; $formatted = (new TFormat)->format(new ArrayParametersOverViewWith($file)); diff --git a/tests/Formatting/Formatters/FullyQualifiedFacadesTest.php b/tests/Formatting/Formatters/FullyQualifiedFacadesTest.php index 1a67e38..0d78a35 100644 --- a/tests/Formatting/Formatters/FullyQualifiedFacadesTest.php +++ b/tests/Formatting/Formatters/FullyQualifiedFacadesTest.php @@ -12,26 +12,24 @@ class FullyQualifiedFacadesTest extends TestCase public function fixes_facade_aliases() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); $expected = <<<'file' -assertSame($expected, $formatted); } @@ -40,22 +38,20 @@ public function fixes_facade_aliases() public function fixes_facade_aliases_when_file_not_namespaced() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); $expected = <<<'file' -assertSame($expected, $formatted); } @@ -64,32 +60,30 @@ public function fixes_facade_aliases_when_file_not_namespaced() public function fixes_facade_aliases_mixed_with_valid_use_statements() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); $expected = <<<'file' -assertSame($expected, $formatted); } @@ -98,28 +92,26 @@ public function fixes_facade_aliases_mixed_with_valid_use_statements() public function fixes_facade_aliases_after_group_use_when_file_not_namespaced() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); $expected = <<<'file' -assertSame($expected, $formatted); } @@ -128,26 +120,24 @@ public function fixes_facade_aliases_after_group_use_when_file_not_namespaced() public function fixes_str_and_arr_helpers() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); $expected = <<<'file' -assertSame($expected, $formatted); } @@ -156,13 +146,12 @@ public function fixes_str_and_arr_helpers() public function ignores_grouped_imports() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); @@ -173,13 +162,12 @@ public function ignores_grouped_imports() public function ignores_unknown_aliases() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); @@ -190,18 +178,18 @@ public function ignores_unknown_aliases() public function ignores_files_in_same_directory_with_same_name_as_facade_alias() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); @@ -212,29 +200,27 @@ public function doStuff() public function it_does_not_cause_duplicate_import_statements() { $file = <<<'file' -format(new FullyQualifiedFacades($file)); $expected = <<<'file' -assertSame($expected, $formatted); } diff --git a/tests/Formatting/Formatters/MailableMethodsInBuildTest.php b/tests/Formatting/Formatters/MailableMethodsInBuildTest.php index 346856b..e2d2abc 100644 --- a/tests/Formatting/Formatters/MailableMethodsInBuildTest.php +++ b/tests/Formatting/Formatters/MailableMethodsInBuildTest.php @@ -12,64 +12,64 @@ class MailableMethodsInBuildTest extends TestCase public function catches_mailable_methods_in_constructor() { $file = <<<'file' -url = $url; - $this->from('noreply@delivermyride.com', config('name')); - $this->subject(config('name') . ' Garage'); - /* Test PhpParser\Node\Stmt\Nop */ - } + public function __construct($url) + { + $this->url = $url; + $this->from('noreply@delivermyride.com', config('name')); + $this->subject(config('name') . ' Garage'); + /* Test PhpParser\Node\Stmt\Nop */ + } - public function build() - { - return $this->view('auth.emails.email-login'); - } -} -file; + public function build() + { + return $this->view('auth.emails.email-login'); + } + } + file; $expected = <<<'file' -url = $url; - /* Test PhpParser\Node\Stmt\Nop */ - } + public function __construct($url) + { + $this->url = $url; + /* Test PhpParser\Node\Stmt\Nop */ + } - public function build() - { - $this->from('noreply@delivermyride.com', config('name')); - $this->subject(config('name') . ' Garage'); - return $this->view('auth.emails.email-login'); - } -} -file; + public function build() + { + $this->from('noreply@delivermyride.com', config('name')); + $this->subject(config('name') . ' Garage'); + return $this->view('auth.emails.email-login'); + } + } + file; $formatted = (new TFormat)->format(new MailableMethodsInBuild($file)); @@ -80,35 +80,34 @@ public function build() public function does_not_trigger_on_methods_in_build() { $file = <<<'file' -url = $url; - } + public $url; - public function build() - { - $this->from('noreply@delivermyride.com', config('name')); - $this->subject(config('name') . ' Garage'); + public function __construct($url) + { + $this->url = $url; + } - return $this->view('auth.emails.email-login'); - } -} + public function build() + { + $this->from('noreply@delivermyride.com', config('name')); + $this->subject(config('name') . ' Garage'); -file; + return $this->view('auth.emails.email-login'); + } + } + file; $formatted = (new TFormat)->format(new MailableMethodsInBuild($file)); @@ -119,35 +118,34 @@ public function build() public function does_not_trigger_on_non_mailable() { $file = <<<'file' -url = $url; - $this->subject(config('name') . ' Garage'); - } + public function __construct($url) + { + $this->url = $url; + $this->subject(config('name') . ' Garage'); + } - public function build() - { - $this->from('noreply@delivermyride.com', config('name')); - - return $this->view('auth.emails.email-login'); - } -} + public function build() + { + $this->from('noreply@delivermyride.com', config('name')); -file; + return $this->view('auth.emails.email-login'); + } + } + file; $formatted = (new TFormat)->format(new MailableMethodsInBuild($file)); diff --git a/tests/Formatting/Formatters/NoDatesPropertyOnModelsTest.php b/tests/Formatting/Formatters/NoDatesPropertyOnModelsTest.php index a0c8b6b..3f009e6 100644 --- a/tests/Formatting/Formatters/NoDatesPropertyOnModelsTest.php +++ b/tests/Formatting/Formatters/NoDatesPropertyOnModelsTest.php @@ -12,26 +12,26 @@ class NoDatesPropertyOnModelsTest extends TestCase public function converts_dates_property_to_datetime_cast() { $file = <<<'file' - 'datetime', - ]; -} -file; + class Post extends Model + { + protected $casts = [ + 'email_verified_at' => 'datetime', + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } @@ -40,31 +40,31 @@ class Post extends Model public function adds_attributes_to_existing_casts() { $file = <<<'file' - 'boolean', - ]; -} -file; + protected $casts = [ + 'is_active' => 'boolean', + ]; + } + file; $expected = <<<'file' - 'boolean', - 'published_at' => 'datetime', - ]; -} -file; + class Post extends Model + { + protected $casts = [ + 'is_active' => 'boolean', + 'published_at' => 'datetime', + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } @@ -76,29 +76,29 @@ class Post extends Model public function drops_date_attributes_already_in_casts() { $file = <<<'file' - 'date', - ]; -} -file; + 'date', + ]; + } + file; $expected = <<<'file' - 'date', - ]; -} -file; + class Page extends Model + { + protected $casts = [ + 'email_verified_at' => 'date', + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } @@ -107,24 +107,24 @@ class Page extends Model public function creates_casts_property_if_it_doesnt_exist() { $file = <<<'file' - 'datetime', - ]; -} -file; + class User extends Authenticatable + { + protected $casts = [ + 'signed_up_at' => 'datetime', + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } @@ -133,25 +133,25 @@ class User extends Authenticatable public function orders_casts_alphabetically() { $file = <<<'file' - 'datetime', - 'signed_up_at' => 'datetime', - ]; -} -file; + class User extends Authenticatable + { + protected $casts = [ + 'email_verified_at' => 'datetime', + 'signed_up_at' => 'datetime', + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } @@ -160,32 +160,32 @@ class User extends Authenticatable public function doesnt_error_on_custom_cast_classes() { $file = <<<'file' - Password::class, - ]; -} -file; + class User extends Authenticatable + { + protected $dates = ['email_verified_at']; + protected $casts = [ + 'password' => Password::class, + ]; + } + file; $expected = <<<'file' - 'datetime', - 'password' => Password::class, - ]; -} -file; + class User extends Authenticatable + { + protected $casts = [ + 'email_verified_at' => 'datetime', + 'password' => Password::class, + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } @@ -194,27 +194,27 @@ class User extends Authenticatable public function doesnt_error_on_empty_dates() { $file = <<<'file' - 'boolean', - ]; - protected $dates = []; -} -file; + class User extends Authenticatable + { + protected $casts = [ + 'admin' => 'boolean', + ]; + protected $dates = []; + } + file; $expected = <<<'file' - 'boolean', - ]; -} -file; + 'boolean', + ]; + } + file; $this->assertSame($expected, (new TFormat)->format(new NoDatesPropertyOnModels($file))); } diff --git a/tests/Formatting/Formatters/NoDocBlocksForMigrationUpDownTest.php b/tests/Formatting/Formatters/NoDocBlocksForMigrationUpDownTest.php index 3f8a9a5..913ef37 100644 --- a/tests/Formatting/Formatters/NoDocBlocksForMigrationUpDownTest.php +++ b/tests/Formatting/Formatters/NoDocBlocksForMigrationUpDownTest.php @@ -12,62 +12,60 @@ class NoDocBlocksForMigrationUpDownTest extends TestCase public function removes_up_and_down_docblocks() { $file = <<format( new NoDocBlocksForMigrationUpDown($file) ); $correctlyFormatted = <<assertEquals($correctlyFormatted, $formatted); } @@ -76,22 +74,21 @@ public function down() public function doesnt_remove_other_migration_docblocks() { $file = <<<'file' -format( new NoDocBlocksForMigrationUpDown($file) diff --git a/tests/Formatting/Formatters/NoLeadingSlashesOnRoutePathsTest.php b/tests/Formatting/Formatters/NoLeadingSlashesOnRoutePathsTest.php index b7deb9b..9bbb636 100644 --- a/tests/Formatting/Formatters/NoLeadingSlashesOnRoutePathsTest.php +++ b/tests/Formatting/Formatters/NoLeadingSlashesOnRoutePathsTest.php @@ -12,20 +12,20 @@ class NoLeadingSlashesOnRoutePathsTest extends TestCase public function catches_leading_slashes_on_top_level_routes() { $file = <<<'file' -format( new NoLeadingSlashesOnRoutePaths($file, '.php') @@ -38,24 +38,24 @@ public function catches_leading_slashes_on_top_level_routes() public function catches_leading_slashes_in_route_groups() { $file = <<<'file' - 'auth'], function () { - Route::get('/home', function () { - // Uses Auth Middleware - }); -}); -file; + Route::group(['middleware' => 'auth'], function () { + Route::get('/home', function () { + // Uses Auth Middleware + }); + }); + file; $correctlyFormatted = <<<'file' - 'auth'], function () { - Route::get('home', function () { - // Uses Auth Middleware - }); -}); -file; + Route::group(['middleware' => 'auth'], function () { + Route::get('home', function () { + // Uses Auth Middleware + }); + }); + file; $formatted = (new TFormat)->format( new NoLeadingSlashesOnRoutePaths($file, '.php') @@ -68,12 +68,12 @@ public function catches_leading_slashes_in_route_groups() public function does_not_trigger_on_otherwise_empty_paths() { $file = <<<'file' -format( new NoLeadingSlashesOnRoutePaths($file, '.php') @@ -86,12 +86,12 @@ public function does_not_trigger_on_otherwise_empty_paths() public function does_not_throw_on_dynamic_calls() { $file = <<<'file' -format( new NoLeadingSlashesOnRoutePaths($file, '.php') diff --git a/tests/Formatting/Formatters/NoSpaceAfterBladeDirectivesTest.php b/tests/Formatting/Formatters/NoSpaceAfterBladeDirectivesTest.php index d13d576..b8da346 100644 --- a/tests/Formatting/Formatters/NoSpaceAfterBladeDirectivesTest.php +++ b/tests/Formatting/Formatters/NoSpaceAfterBladeDirectivesTest.php @@ -12,64 +12,64 @@ class NoSpaceAfterBladeDirectivesTest extends TestCase public function it_removes_spaces_from_directives() { $file = <<<'file' -@section ('sidebar') - This is the master sidebar. -@show + @section ('sidebar') + This is the master sidebar. + @show -
- @yield ('content') -
+
+ @yield ('content') +
-Padding + Padding -active)) /> + active)) /> - + -@auth The user is authenticated @endauth + @auth The user is authenticated @endauth -@auth ('admin') - // The user is authenticated... -@endauth -file; + @auth ('admin') + // The user is authenticated... + @endauth + file; $formatted = (new TFormat)->format( new NoSpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@section('sidebar') - This is the master sidebar. -@show + @section('sidebar') + This is the master sidebar. + @show -
- @yield('content') -
+
+ @yield('content') +
-Padding + Padding -active)) /> + active)) /> - + -@auth The user is authenticated @endauth + @auth The user is authenticated @endauth -@auth('admin') - // The user is authenticated... -@endauth -file; + @auth('admin') + // The user is authenticated... + @endauth + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -78,38 +78,38 @@ public function it_removes_spaces_from_directives() public function it_ignores_directives_where_space_required() { $file = <<<'file' -@if (true) - This is true. -@elseif (false) - This is false. -@endif - -@if (true) @if ($inline) Inline @endif @endif - -@unless (true) - This isn't true. -@endunless - -@for ($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor - -@foreach ($users as $user) - @foreach ($user->emails as $email) -
  • {{ $email }}
  • - @endforeach -@endforeach - -@forelse ($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse - -@while (true) -

    I'm looping forever.

    -@endwhile -file; + @if (true) + This is true. + @elseif (false) + This is false. + @endif + + @if (true) @if ($inline) Inline @endif @endif + + @unless (true) + This isn't true. + @endunless + + @for ($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + + @foreach ($users as $user) + @foreach ($user->emails as $email) +
  • {{ $email }}
  • + @endforeach + @endforeach + + @forelse ($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + + @while (true) +

    I'm looping forever.

    + @endwhile + file; $formatted = (new TFormat)->format( new NoSpaceAfterBladeDirectives($file) diff --git a/tests/Formatting/Formatters/OneLineBetweenClassVisibilityChangesTest.php b/tests/Formatting/Formatters/OneLineBetweenClassVisibilityChangesTest.php index 465da8d..5956191 100644 --- a/tests/Formatting/Formatters/OneLineBetweenClassVisibilityChangesTest.php +++ b/tests/Formatting/Formatters/OneLineBetweenClassVisibilityChangesTest.php @@ -12,29 +12,29 @@ class OneLineBetweenClassVisibilityChangesTest extends TestCase public function catches_missing_line_between_visibility_changes() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -45,35 +45,35 @@ class Thing public function catches_missing_line_between_visibility_changes_with_doc_block() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -84,20 +84,20 @@ class Thing public function ignores_doc_block_between_visibility_changes() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -108,31 +108,31 @@ class Thing public function catches_missing_line_between_visibility_changes_with_comment() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -143,33 +143,33 @@ class Thing public function catches_missing_line_between_visibility_changes_with_two_comments() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -180,37 +180,37 @@ class Thing public function catches_missing_line_between_visibility_changes_with_many_comments() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -221,18 +221,18 @@ class Thing public function ignores_comment_below_space_between_visibility_changes() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -243,18 +243,18 @@ class Thing public function ignores_comment_above_space_between_visibility_changes() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -265,24 +265,24 @@ class Thing public function ignores_many_comments_between_visibility_changes() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); @@ -293,45 +293,45 @@ class Thing public function catches_missing_line_between_visibility_changes_in_anon_class() { $file = <<<'file' -format(new OneLineBetweenClassVisibilityChanges($file)); diff --git a/tests/Formatting/Formatters/RemoveLeadingSlashNamespacesTest.php b/tests/Formatting/Formatters/RemoveLeadingSlashNamespacesTest.php index 742ecae..7e3b708 100644 --- a/tests/Formatting/Formatters/RemoveLeadingSlashNamespacesTest.php +++ b/tests/Formatting/Formatters/RemoveLeadingSlashNamespacesTest.php @@ -11,39 +11,39 @@ class RemoveLeadingSlashNamespacesTest extends TestCase /** @test */ public function catches_leading_slashes_in_use_statements() { - $file = <<format( new RemoveLeadingSlashNamespaces($file, '.php') @@ -56,29 +56,29 @@ public function test() public function does_not_catch_leading_slash_in_code() { $file = <<<'file' -name; + class AppServiceProvider extends ServiceProvider + { + public function boot() + { + $name = \Illuminate\Support\Facades\Auth::user()->name; - $zip = new \ZipArchive; + $zip = new \ZipArchive; - $class = new \stdClass; + $class = new \stdClass; - $model = \App\User::class; + $model = \App\User::class; - Validator::extend('recaptcha', 'App\Validators\ReCaptchaValidator@validate'); - } -} -file; + Validator::extend('recaptcha', 'App\Validators\ReCaptchaValidator@validate'); + } + } + file; $formatted = (new TFormat)->format( new RemoveLeadingSlashNamespaces($file, '.php') diff --git a/tests/Formatting/Formatters/RequestHelperFunctionWherePossibleTest.php b/tests/Formatting/Formatters/RequestHelperFunctionWherePossibleTest.php index 2a554c4..9e1eebc 100644 --- a/tests/Formatting/Formatters/RequestHelperFunctionWherePossibleTest.php +++ b/tests/Formatting/Formatters/RequestHelperFunctionWherePossibleTest.php @@ -12,32 +12,32 @@ class RequestHelperFunctionWherePossibleTest extends TestCase public function catches_get_method_usage() { $file = <<<'file' -get('savedVehicleId')); - } -} -file; + class Controller + { + public function index() + { + return SavedVehicle::findOrFail(request()->get('savedVehicleId')); + } + } + file; $expected = <<<'file' -format(new RequestHelperFunctionWherePossible($file)); @@ -48,22 +48,22 @@ public function index() public function ignores_other_request_methods() { $file = <<<'file' -validate(['test' => 'required']); - - if (request()->has('version') || request()->hasHeader('version')) { - return request()->input('version') ?? request()->header('version'); - } - } -} -file; + validate(['test' => 'required']); + + if (request()->has('version') || request()->hasHeader('version')) { + return request()->input('version') ?? request()->header('version'); + } + } + } + file; $formatted = (new TFormat)->format(new RequestHelperFunctionWherePossible($file)); diff --git a/tests/Formatting/Formatters/RequestValidationTest.php b/tests/Formatting/Formatters/RequestValidationTest.php index 62fdd68..4d67304 100644 --- a/tests/Formatting/Formatters/RequestValidationTest.php +++ b/tests/Formatting/Formatters/RequestValidationTest.php @@ -12,36 +12,36 @@ class RequestValidationTest extends TestCase public function catches_this_validate_method_usage() { $file = <<<'file' -validate(['name' => 'required'], ['name.required' => 'Name is required']); - } -} -file; + class ControllerA extends Controller + { + public function store() + { + $this->validate(['name' => 'required'], ['name.required' => 'Name is required']); + } + } + file; $expected = <<<'file' -validate(['name' => 'required'], ['name.required' => 'Name is required']); - } -} -file; + class ControllerA extends Controller + { + public function store() + { + request()->validate(['name' => 'required'], ['name.required' => 'Name is required']); + } + } + file; $formatted = (new TFormat)->format(new RequestValidation($file)); @@ -52,18 +52,18 @@ public function store() public function does_not_trigger_on_helper_function_usage() { $file = <<<'file' -validate([ - 'response' => 'required_without:file', - ]); - } -} -file; + validate([ + 'response' => 'required_without:file', + ]); + } + } + file; $formatted = (new TFormat)->format(new RequestValidation($file)); @@ -74,18 +74,18 @@ public function update() public function does_not_trigger_when_using_request_variable_method() { $file = <<<'file' -validate([]); - } -} -file; + class ControllerA extends Controller + { + public function store(ARequest $request) + { + $request->validate([]); + } + } + file; $formatted = (new TFormat)->format(new RequestValidation($file)); @@ -96,19 +96,19 @@ public function store(ARequest $request) public function does_not_cause_php_notice_when_value_is_not_an_expression_with_a_name() { $file = <<<'file' -with('errors', (new ViewErrorBag)->add('field', 'message')); - } -} -file; + class ControllerA extends Controller + { + public function store() + { + return back() + ->with('errors', (new ViewErrorBag)->add('field', 'message')); + } + } + file; $formatted = (new TFormat)->format(new RequestValidation($file)); @@ -119,18 +119,18 @@ public function store() public function it_ignores_classes_that_do_not_extend_controller() { $file = <<<'file' -validate(['name' => 'required'], ['name.required' => 'Name is required']); - } -} -file; + validate(['name' => 'required'], ['name.required' => 'Name is required']); + } + } + file; $formatted = (new TFormat)->format(new RequestValidation($file)); diff --git a/tests/Formatting/Formatters/SpaceAfterBladeDirectivesTest.php b/tests/Formatting/Formatters/SpaceAfterBladeDirectivesTest.php index 633f85a..a442e7f 100644 --- a/tests/Formatting/Formatters/SpaceAfterBladeDirectivesTest.php +++ b/tests/Formatting/Formatters/SpaceAfterBladeDirectivesTest.php @@ -12,24 +12,24 @@ class SpaceAfterBladeDirectivesTest extends TestCase public function it_adds_space_to_if_statement() { $file = <<<'file' -@if(true) - This is true. -@elseif(false) - This is false. -@endif -file; + @if(true) + This is true. + @elseif(false) + This is false. + @endif + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@if (true) - This is true. -@elseif (false) - This is false. -@endif -file; + @if (true) + This is true. + @elseif (false) + This is false. + @endif + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -38,20 +38,20 @@ public function it_adds_space_to_if_statement() public function it_adds_space_to_unless_statement() { $file = <<<'file' -@unless(true) - This isn't true. -@endunless -file; + @unless(true) + This isn't true. + @endunless + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@unless (true) - This isn't true. -@endunless -file; + @unless (true) + This isn't true. + @endunless + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -60,20 +60,20 @@ public function it_adds_space_to_unless_statement() public function it_adds_space_to_for_statement() { $file = <<<'file' -@for($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor -file; + @for($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@for ($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor -file; + @for ($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -82,20 +82,20 @@ public function it_adds_space_to_for_statement() public function it_adds_space_to_foreach_statement() { $file = <<<'file' -@foreach($users as $user) -
  • {{ $user->name }}
  • -@endforeach -file; + @foreach($users as $user) +
  • {{ $user->name }}
  • + @endforeach + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@foreach ($users as $user) -
  • {{ $user->name }}
  • -@endforeach -file; + @foreach ($users as $user) +
  • {{ $user->name }}
  • + @endforeach + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -104,24 +104,24 @@ public function it_adds_space_to_foreach_statement() public function it_adds_space_to_forelse_statement() { $file = <<<'file' -@forelse($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse -file; + @forelse($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@forelse ($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse -file; + @forelse ($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -130,20 +130,20 @@ public function it_adds_space_to_forelse_statement() public function it_adds_space_to_while_statement() { $file = <<<'file' -@while(true) -

    I'm looping forever.

    -@endwhile -file; + @while(true) +

    I'm looping forever.

    + @endwhile + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@while (true) -

    I'm looping forever.

    -@endwhile -file; + @while (true) +

    I'm looping forever.

    + @endwhile + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -152,14 +152,14 @@ public function it_adds_space_to_while_statement() public function it_ignores_correctly_spaced_directives() { $file = <<<'file' -@foreach ($users as $user) -
  • {{ $user->name }}
  • -@endforeach + @foreach ($users as $user) +
  • {{ $user->name }}
  • + @endforeach -@auth -

    Authenticated

    -@endauth -file; + @auth +

    Authenticated

    + @endauth + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) @@ -172,76 +172,76 @@ public function it_ignores_correctly_spaced_directives() public function it_adds_space_to_kitchen_sink() { $file = <<<'file' -@if(true) - This is true. -@elseif(false) - This is false. -@endif - -@if(true) @if($inline) Inline @endif @endif - -@unless(true) - This isn't true. -@endunless - -@for($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor - -@foreach($users as $user) - @foreach($user->emails as $email) -
  • {{ $email }}
  • - @endforeach -@endforeach - -@forelse($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse - -@while(true) -

    I'm looping forever.

    -@endwhile -file; + @if(true) + This is true. + @elseif(false) + This is false. + @endif + + @if(true) @if($inline) Inline @endif @endif + + @unless(true) + This isn't true. + @endunless + + @for($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + + @foreach($users as $user) + @foreach($user->emails as $email) +
  • {{ $email }}
  • + @endforeach + @endforeach + + @forelse($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + + @while(true) +

    I'm looping forever.

    + @endwhile + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@if (true) - This is true. -@elseif (false) - This is false. -@endif - -@if (true) @if ($inline) Inline @endif @endif - -@unless (true) - This isn't true. -@endunless - -@for ($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor - -@foreach ($users as $user) - @foreach ($user->emails as $email) -
  • {{ $email }}
  • - @endforeach -@endforeach - -@forelse ($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse - -@while (true) -

    I'm looping forever.

    -@endwhile -file; + @if (true) + This is true. + @elseif (false) + This is false. + @endif + + @if (true) @if ($inline) Inline @endif @endif + + @unless (true) + This isn't true. + @endunless + + @for ($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + + @foreach ($users as $user) + @foreach ($user->emails as $email) +
  • {{ $email }}
  • + @endforeach + @endforeach + + @forelse ($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + + @while (true) +

    I'm looping forever.

    + @endwhile + file; $this->assertEquals($correctlyFormatted, $formatted); } @@ -250,28 +250,28 @@ public function it_adds_space_to_kitchen_sink() public function it_fixes_directives_spanning_multiple_lines() { $file = <<<'file' -@foreach([ - Laravel\Memberships\Membership::MEMBER_ROLE, - Laravel\Memberships\Membership::SUPERVISION_ROLE, - Laravel\Memberships\Membership::ADMIN_ROLE, - ] as $role) - -@endforeach -file; + @foreach([ + Laravel\Memberships\Membership::MEMBER_ROLE, + Laravel\Memberships\Membership::SUPERVISION_ROLE, + Laravel\Memberships\Membership::ADMIN_ROLE, + ] as $role) + + @endforeach + file; $formatted = (new TFormat)->format( new SpaceAfterBladeDirectives($file) ); $correctlyFormatted = <<<'file' -@foreach ([ - Laravel\Memberships\Membership::MEMBER_ROLE, - Laravel\Memberships\Membership::SUPERVISION_ROLE, - Laravel\Memberships\Membership::ADMIN_ROLE, - ] as $role) - -@endforeach -file; + @foreach ([ + Laravel\Memberships\Membership::MEMBER_ROLE, + Laravel\Memberships\Membership::SUPERVISION_ROLE, + Laravel\Memberships\Membership::ADMIN_ROLE, + ] as $role) + + @endforeach + file; $this->assertEquals($correctlyFormatted, $formatted); } diff --git a/tests/Formatting/Formatters/SpacesAroundBladeRenderContentTest.php b/tests/Formatting/Formatters/SpacesAroundBladeRenderContentTest.php index d79c357..0ddf569 100644 --- a/tests/Formatting/Formatters/SpacesAroundBladeRenderContentTest.php +++ b/tests/Formatting/Formatters/SpacesAroundBladeRenderContentTest.php @@ -12,12 +12,12 @@ class SpacesAroundBladeRenderContentTest extends TestCase public function catches_missing_spaces_around_blade_render_content() { $file = <<<'file' -{{1 + 1}} -file; + {{1 + 1}} + file; $correctlyFormatted = <<<'file' -{{ 1 + 1 }} -file; + {{ 1 + 1 }} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -30,12 +30,12 @@ public function catches_missing_spaces_around_blade_render_content() public function catches_missing_spaces_around_blade_render_content_after_correctly_spaced() { $file = <<<'file' -{{ 1 + 1 }} {{1 + 1}} -file; + {{ 1 + 1 }} {{1 + 1}} + file; $correctlyFormatted = <<<'file' -{{ 1 + 1 }} {{ 1 + 1 }} -file; + {{ 1 + 1 }} {{ 1 + 1 }} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -48,12 +48,12 @@ public function catches_missing_spaces_around_blade_render_content_after_correct public function catches_extra_spaces_around_blade_render_content() { $file = <<<'file' -{{1 + 1 }} -file; + {{1 + 1 }} + file; $correctlyFormatted = <<<'file' -{{ 1 + 1 }} -file; + {{ 1 + 1 }} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -66,12 +66,12 @@ public function catches_extra_spaces_around_blade_render_content() public function catches_missing_spaces_around_raw_blade_render_content() { $file = <<<'file' -{!!$a!!} -file; + {!!$a!!} + file; $correctlyFormatted = <<<'file' -{!! $a !!} -file; + {!! $a !!} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -84,8 +84,8 @@ public function catches_missing_spaces_around_raw_blade_render_content() public function does_not_trigger_when_spaces_are_placed_correctly_raw_blade_render_content() { $file = <<<'file' -{!! $a !!} -file; + {!! $a !!} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -98,8 +98,8 @@ public function does_not_trigger_when_spaces_are_placed_correctly_raw_blade_rend public function does_not_trigger_when_spaces_are_placed_correctly() { $file = <<<'file' -{{ 1 + 1 }} -file; + {{ 1 + 1 }} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -128,8 +128,8 @@ public function does_not_trigger_on_multiline_renders() public function does_not_trigger_on_blade_comment() { $file = <<<'file' -{{-- This comment will not be present in the rendered HTML --}} -file; + {{-- This comment will not be present in the rendered HTML --}} + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) @@ -142,50 +142,50 @@ public function does_not_trigger_on_blade_comment() public function catches_space_to_render_content_complex() { $file = <<<'file' -
    - @foreach ($chirps as $chirp) -
    - - - -
    -
    -
    - {{$chirp->user->name}} {{$chirp->user->created_at }} - {{ $chirp->created_at->format('j M Y, g:i a') }} +
    + @foreach ($chirps as $chirp) +
    + + + +
    +
    +
    + {{$chirp->user->name}} {{$chirp->user->created_at }} + {{ $chirp->created_at->format('j M Y, g:i a') }} +
    +
    +

    {!!$chirp->message!!}

    +
    -
    -

    {!!$chirp->message!!}

    + @endforeach
    -
    - @endforeach -
    -file; + file; $formatted = (new TFormat)->format( new SpacesAroundBladeRenderContent($file) ); $correctlyFormatted = <<<'file' -
    - @foreach ($chirps as $chirp) -
    - - - -
    -
    -
    - {{ $chirp->user->name }} {{ $chirp->user->created_at }} - {{ $chirp->created_at->format('j M Y, g:i a') }} +
    + @foreach ($chirps as $chirp) +
    + + + +
    +
    +
    + {{ $chirp->user->name }} {{ $chirp->user->created_at }} + {{ $chirp->created_at->format('j M Y, g:i a') }} +
    +
    +

    {!! $chirp->message !!}

    +
    -
    -

    {!! $chirp->message !!}

    + @endforeach
    -
    - @endforeach -
    -file; + file; $this->assertEquals($correctlyFormatted, $formatted); } diff --git a/tests/Formatting/Formatters/UseAnonymousMigrationsTest.php b/tests/Formatting/Formatters/UseAnonymousMigrationsTest.php index 6a0ea69..3e3d563 100644 --- a/tests/Formatting/Formatters/UseAnonymousMigrationsTest.php +++ b/tests/Formatting/Formatters/UseAnonymousMigrationsTest.php @@ -11,49 +11,47 @@ class UseAnonymousMigrationsTest extends TestCase /** @test */ public function it_converts_named_migration_to_anonymous_migration() { - $file = <<format( new UseAnonymousMigrations($file) ); - $correctlyFormatted = <<assertEquals($correctlyFormatted, $formatted); } @@ -61,25 +59,24 @@ public function down() /** @test */ public function it_ignores_anonymous_migrations() { - $file = <<format( new UseAnonymousMigrations($file) diff --git a/tests/Formatting/NoOpFormatterSaysLGTMTest.php b/tests/Formatting/NoOpFormatterSaysLGTMTest.php index 0915f7e..5bc4bdf 100644 --- a/tests/Formatting/NoOpFormatterSaysLGTMTest.php +++ b/tests/Formatting/NoOpFormatterSaysLGTMTest.php @@ -19,16 +19,15 @@ public function no_op_says_lgtm() $commandTester = new CommandTester($command); $file = <<<'file' -middleware('auth'); - } -} - -file; + class BuyRequestController extends Controller + { + public function __construct() + { + $this->middleware('auth'); + } + } + file; $lints = (new TLint)->lint( new ApplyMiddlewareInRoutes($file) @@ -36,20 +35,19 @@ public function __construct() /** @test */ public function does_not_throw_on_methods_calls_on_instantiations() { - $file = <<column(); - } -} - -file; + $file = <<<'file' + column(); + } + } + file; $lints = (new TLint)->lint( new ApplyMiddlewareInRoutes($file) diff --git a/tests/Linting/Linters/ArrayParametersOverViewWithTest.php b/tests/Linting/Linters/ArrayParametersOverViewWithTest.php index b4e310f..65a111e 100644 --- a/tests/Linting/Linters/ArrayParametersOverViewWithTest.php +++ b/tests/Linting/Linters/ArrayParametersOverViewWithTest.php @@ -12,18 +12,18 @@ class ArrayParametersOverViewWithTest extends TestCase public function catches_view_with_method_usage_in_controller_methods() { $file = <<<'file' -with('ok', 'test'); - } -} -file; + class Controller + { + function index() + { + return view('test.view')->with('ok', 'test'); + } + } + file; $lints = (new TLint)->lint( new ArrayParametersOverViewWith($file) @@ -35,13 +35,13 @@ function index() /** @test */ public function catches_view_with_method_usage_in_routes() { - $file = <<with('test', 'test'); -}); -file; + \Route::get('test', function () { + return view('test')->with('test', 'test'); + }); + file; $lints = (new TLint)->lint( new ArrayParametersOverViewWith($file) diff --git a/tests/Linting/Linters/FullyQualifiedFacadesTest.php b/tests/Linting/Linters/FullyQualifiedFacadesTest.php index faed9c8..e750902 100644 --- a/tests/Linting/Linters/FullyQualifiedFacadesTest.php +++ b/tests/Linting/Linters/FullyQualifiedFacadesTest.php @@ -12,13 +12,12 @@ class FullyQualifiedFacadesTest extends TestCase public function it_triggers_on_namespaced_file() { $file = <<<'file' -lint( new FullyQualifiedFacades($file) @@ -31,11 +30,10 @@ public function it_triggers_on_namespaced_file() public function it_triggers_on_non_namespaced_file() { $file = <<<'file' -lint( new FullyQualifiedFacades($file) @@ -48,11 +46,10 @@ public function it_triggers_on_non_namespaced_file() public function it_triggers_on_aliased_facade() { $file = <<<'file' -lint( new FullyQualifiedFacades($file) @@ -64,14 +61,13 @@ public function it_triggers_on_aliased_facade() /** @test */ public function does_not_trigger_on_a_fully_qualified_facade() { - $file = <<lint( new FullyQualifiedFacades($file) @@ -83,14 +79,13 @@ public function does_not_trigger_on_a_fully_qualified_facade() /** @test */ public function does_not_trigger_on_custom_class_aliased_to_facade_name() { - $file = <<lint( new FullyQualifiedFacades($file) @@ -102,14 +97,13 @@ public function does_not_trigger_on_custom_class_aliased_to_facade_name() /** @test */ public function does_not_trigger_on_facade_usage_with_grouped_import() { - $file = <<lint( new FullyQualifiedFacades($file) @@ -121,16 +115,15 @@ public function does_not_trigger_on_facade_usage_with_grouped_import() /** @test */ public function does_not_trigger_on_facade_usage_with_grouped_import_and_renamed_imports() { - $file = <<lint( new FullyQualifiedFacades($file) @@ -143,13 +136,12 @@ public function does_not_trigger_on_facade_usage_with_grouped_import_and_renamed public function ignores_unknown_aliases_in_namespaced_file() { $file = <<<'file' -lint( new FullyQualifiedFacades($file) @@ -162,11 +154,10 @@ public function ignores_unknown_aliases_in_namespaced_file() public function ignores_unknown_aliases_in_non_namespaced_file() { $file = <<<'file' -lint( new FullyQualifiedFacades($file) @@ -179,18 +170,18 @@ public function ignores_unknown_aliases_in_non_namespaced_file() public function does_not_trigger_on_alias_usage_without_import() { $file = <<<'file' -lint( new FullyQualifiedFacades($file) diff --git a/tests/Linting/Linters/MailableMethodsInBuildTest.php b/tests/Linting/Linters/MailableMethodsInBuildTest.php index 1d6c9b8..b8b4012 100644 --- a/tests/Linting/Linters/MailableMethodsInBuildTest.php +++ b/tests/Linting/Linters/MailableMethodsInBuildTest.php @@ -12,35 +12,34 @@ class MailableMethodsInBuildTest extends TestCase public function catches_mailable_methods_in_constructor() { $file = <<<'file' -url = $url; - $this->from('noreply@delivermyride.com', config('name')); - $this->subject(config('name') . ' Garage'); - /* Test PhpParser\Node\Stmt\Nop */ - } + public $url; - public function build() - { - return $this->view('auth.emails.email-login'); - } -} + public function __construct($url) + { + $this->url = $url; + $this->from('noreply@delivermyride.com', config('name')); + $this->subject(config('name') . ' Garage'); + /* Test PhpParser\Node\Stmt\Nop */ + } -file; + public function build() + { + return $this->view('auth.emails.email-login'); + } + } + file; $lints = (new TLint)->lint( new MailableMethodsInBuild($file) @@ -53,36 +52,35 @@ public function build() public function does_not_trigger_on_methods_in_build() { $file = <<<'file' -url = $url; - /* Test PhpParser\Node\Stmt\Nop */ - } + public $url; - public function build() - { - $this->from('noreply@delivermyride.com', config('name')); - $this->subject(config('name') . ' Garage'); + public function __construct($url) + { + $this->url = $url; + /* Test PhpParser\Node\Stmt\Nop */ + } - return $this->view('auth.emails.email-login'); - } -} + public function build() + { + $this->from('noreply@delivermyride.com', config('name')); + $this->subject(config('name') . ' Garage'); -file; + return $this->view('auth.emails.email-login'); + } + } + file; $lints = (new TLint)->lint( new MailableMethodsInBuild($file) @@ -95,35 +93,34 @@ public function build() public function does_not_trigger_on_non_mailable() { $file = <<<'file' -url = $url; - $this->subject(config('name') . ' Garage'); - } + public $url; - public function build() - { - $this->from('noreply@delivermyride.com', config('name')); + public function __construct($url) + { + $this->url = $url; + $this->subject(config('name') . ' Garage'); + } - return $this->view('auth.emails.email-login'); - } -} + public function build() + { + $this->from('noreply@delivermyride.com', config('name')); -file; + return $this->view('auth.emails.email-login'); + } + } + file; $lints = (new TLint)->lint( new MailableMethodsInBuild($file) diff --git a/tests/Linting/Linters/NoDatesPropertyOnModelsTest.php b/tests/Linting/Linters/NoDatesPropertyOnModelsTest.php index e063bbe..33525a6 100644 --- a/tests/Linting/Linters/NoDatesPropertyOnModelsTest.php +++ b/tests/Linting/Linters/NoDatesPropertyOnModelsTest.php @@ -12,22 +12,22 @@ class NoDatesPropertyOnModelsTest extends TestCase public function lints_dates_property_on_model() { $file = <<<'file' -belongsTo(User::class); - } -} -file; + public function user() + { + return $this->belongsTo(User::class); + } + } + file; $lints = (new TLint)->lint(new NoDatesPropertyOnModels($file)); @@ -38,19 +38,19 @@ public function user() public function lints_dates_property_on_pivot_model() { $file = <<<'file' -lint(new NoDatesPropertyOnModels($file)); @@ -61,21 +61,21 @@ class AuthorPost extends Pivot public function lints_dates_property_on_authenticatable() { $file = <<<'file' -lint(new NoDatesPropertyOnModels($file)); @@ -86,15 +86,15 @@ class User extends Authenticatable public function ignores_dates_property_on_non_model() { $file = <<<'file' -assertEmpty((new TLint)->lint(new NoDatesPropertyOnModels($file))); } diff --git a/tests/Linting/Linters/NoDocBlocksForMigrationUpDownTest.php b/tests/Linting/Linters/NoDocBlocksForMigrationUpDownTest.php index 864a321..10846df 100644 --- a/tests/Linting/Linters/NoDocBlocksForMigrationUpDownTest.php +++ b/tests/Linting/Linters/NoDocBlocksForMigrationUpDownTest.php @@ -11,37 +11,36 @@ class NoDocBlocksForMigrationUpDownTest extends TestCase /** @test */ public function catches_doc_blocks_on_up_and_down() { - $file = <<lint( new NoDocBlocksForMigrationUpDown($file) diff --git a/tests/Linting/Linters/NoJsonDirectiveTest.php b/tests/Linting/Linters/NoJsonDirectiveTest.php index d24eca3..eb4f6a5 100644 --- a/tests/Linting/Linters/NoJsonDirectiveTest.php +++ b/tests/Linting/Linters/NoJsonDirectiveTest.php @@ -12,15 +12,14 @@ class NoJsonDirectiveTest extends TestCase public function catches_json_directive_usage() { $file = <<<'file' - @extends('layouts.app') + @extends('layouts.app') - @section('content') -
    - "Logan's thing"], ["name" => "ok"]])"> -
    - @endsection - -file; + @section('content') +
    + "Logan's thing"], ["name" => "ok"]])"> +
    + @endsection + file; $lints = (new TLint)->lint( new NoJsonDirective($file) diff --git a/tests/Linting/Linters/NoLeadingSlashesOnRoutePathsTest.php b/tests/Linting/Linters/NoLeadingSlashesOnRoutePathsTest.php index ea6c215..4c2abbe 100644 --- a/tests/Linting/Linters/NoLeadingSlashesOnRoutePathsTest.php +++ b/tests/Linting/Linters/NoLeadingSlashesOnRoutePathsTest.php @@ -12,12 +12,12 @@ class NoLeadingSlashesOnRoutePathsTest extends TestCase public function catches_leading_slashes_on_top_level_routes() { $file = <<<'file' -lint( new NoLeadingSlashesOnRoutePaths($file) @@ -30,14 +30,14 @@ public function catches_leading_slashes_on_top_level_routes() public function catches_leading_slashes_in_route_groups() { $file = <<<'file' - 'auth'], function () { - Route::get('/home', function () { - // Uses Auth Middleware - }); -}); -file; + Route::group(['middleware' => 'auth'], function () { + Route::get('/home', function () { + // Uses Auth Middleware + }); + }); + file; $lints = (new TLint)->lint( new NoLeadingSlashesOnRoutePaths($file) @@ -50,12 +50,12 @@ public function catches_leading_slashes_in_route_groups() public function does_not_trigger_on_otherwise_empty_paths() { $file = <<<'file' -lint( new NoLeadingSlashesOnRoutePaths($file) @@ -68,12 +68,12 @@ public function does_not_trigger_on_otherwise_empty_paths() public function does_not_throw_on_dynamic_calls() { $file = <<<'file' -lint( new NoLeadingSlashesOnRoutePaths($file) diff --git a/tests/Linting/Linters/NoRequestAllTest.php b/tests/Linting/Linters/NoRequestAllTest.php index 90b1bd3..2278621 100644 --- a/tests/Linting/Linters/NoRequestAllTest.php +++ b/tests/Linting/Linters/NoRequestAllTest.php @@ -12,22 +12,22 @@ class NoRequestAllTest extends TestCase public function catches_request_all_with_variable() { $file = <<<'file' -all()); + class UserController + { + public function store(Request $request) + { + $user = User::create($request->all()); - return response()->json($user); - } -} -file; + return response()->json($user); + } + } + file; $lints = (new TLint)->lint(new NoRequestAll($file)); @@ -38,20 +38,20 @@ public function store(Request $request) public function catches_request_all_with_helper() { $file = <<<'file' -all()); + class UserController + { + public function store() + { + $user = User::create(request()->all()); - return response()->json($user); - } -} -file; + return response()->json($user); + } + } + file; $lints = (new TLint)->lint(new NoRequestAll($file)); @@ -62,22 +62,22 @@ public function store() public function catches_request_all_with_facade() { $file = <<<'file' -json($user); - } -} -file; + return response()->json($user); + } + } + file; $lints = (new TLint)->lint(new NoRequestAll($file)); @@ -88,16 +88,16 @@ public function store() public function allows_other_request_methods() { $file = <<<'file' -user(); - $method = $request->method(); - $keys = $request->keys(); + Route::get('/user', function (Request $request) { + $user = $request->user(); + $method = $request->method(); + $keys = $request->keys(); - return [$user, $method, $keys]; -}); -file; + return [$user, $method, $keys]; + }); + file; $lints = (new TLint)->lint(new NoRequestAll($file)); diff --git a/tests/Linting/Linters/NoSpaceAfterBladeDirectivesTest.php b/tests/Linting/Linters/NoSpaceAfterBladeDirectivesTest.php index caf45cd..bcaaa39 100644 --- a/tests/Linting/Linters/NoSpaceAfterBladeDirectivesTest.php +++ b/tests/Linting/Linters/NoSpaceAfterBladeDirectivesTest.php @@ -12,14 +12,14 @@ class NoSpaceAfterBladeDirectivesTest extends TestCase public function catches_space_after_directives() { $file = <<<'file' - @section ('sidebar') - This is the master sidebar. - @show + @section ('sidebar') + This is the master sidebar. + @show -
    - @yield ('content') -
    -file; +
    + @yield ('content') +
    + file; $lints = (new TLint)->lint( new NoSpaceAfterBladeDirectives($file) diff --git a/tests/Linting/Linters/OneLineBetweenClassVisibilityChangesTest.php b/tests/Linting/Linters/OneLineBetweenClassVisibilityChangesTest.php index 5ec6515..04d4d97 100644 --- a/tests/Linting/Linters/OneLineBetweenClassVisibilityChangesTest.php +++ b/tests/Linting/Linters/OneLineBetweenClassVisibilityChangesTest.php @@ -12,16 +12,16 @@ class OneLineBetweenClassVisibilityChangesTest extends TestCase public function catches_missing_line_between_visibility_changes() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -34,19 +34,19 @@ class Thing public function catches_missing_line_between_visibility_changes_with_doc_block() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -59,20 +59,20 @@ class Thing public function ignores_doc_block_between_visibility_changes() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -85,17 +85,17 @@ class Thing public function catches_missing_line_between_visibility_changes_with_comment() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -108,18 +108,18 @@ class Thing public function catches_missing_line_between_visibility_changes_with_two_comments() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -132,20 +132,20 @@ class Thing public function catches_missing_line_between_visibility_changes_with_many_comments() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -158,18 +158,18 @@ class Thing public function ignores_comment_below_space_between_visibility_changes() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -182,18 +182,18 @@ class Thing public function ignores_comment_above_space_between_visibility_changes() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) @@ -206,24 +206,24 @@ class Thing public function ignores_many_comments_between_visibility_changes() { $file = <<<'file' -lint( new OneLineBetweenClassVisibilityChanges($file) diff --git a/tests/Linting/Linters/PureRestControllersTest.php b/tests/Linting/Linters/PureRestControllersTest.php index 367bab9..7cce1f4 100644 --- a/tests/Linting/Linters/PureRestControllersTest.php +++ b/tests/Linting/Linters/PureRestControllersTest.php @@ -12,23 +12,23 @@ class PureRestControllersTest extends TestCase public function catches_non_rest_public_methods_in_an_otherwise_restful_controller() { $file = <<<'file' - 'test']); - } + class Controller + { + public function index() + { + return view('test.view', ['ok' => 'test']); + } - public function nonRest() - { - return 'nope'; - } -} -file; + public function nonRest() + { + return 'nope'; + } + } + file; $lints = (new TLint)->lint( new PureRestControllers($file) @@ -41,23 +41,23 @@ public function nonRest() public function does_not_trigger_on_non_restful_private_method() { $file = <<<'file' - 'test']); - } + class Controller + { + public function index() + { + return view('test.view', ['ok' => 'test']); + } - private function nonRest() - { - return 'nope'; - } -} -file; + private function nonRest() + { + return 'nope'; + } + } + file; $lints = (new TLint)->lint( new PureRestControllers($file) diff --git a/tests/Linting/Linters/QualifiedNamesOnlyForClassNameTest.php b/tests/Linting/Linters/QualifiedNamesOnlyForClassNameTest.php index c6395d1..58097c6 100644 --- a/tests/Linting/Linters/QualifiedNamesOnlyForClassNameTest.php +++ b/tests/Linting/Linters/QualifiedNamesOnlyForClassNameTest.php @@ -11,11 +11,11 @@ class QualifiedNamesOnlyForClassNameTest extends TestCase /** @test */ public function catches_qualified_class_constant_calls() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -27,11 +27,11 @@ public function catches_qualified_class_constant_calls() /** @test */ public function catches_qualified_static_property_access() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -43,11 +43,11 @@ public function catches_qualified_static_property_access() /** @test */ public function catches_qualified_static_method_calls() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -59,11 +59,11 @@ public function catches_qualified_static_method_calls() /** @test */ public function allows_qualified_class_name_access() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -75,11 +75,11 @@ public function allows_qualified_class_name_access() /** @test */ public function catches_fully_qualified_instantiations() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -92,11 +92,11 @@ public function catches_fully_qualified_instantiations() public function does_not_triggen_on_variable_class_instantiation() { $file = <<<'file' -lint( new QualifiedNamesOnlyForClassName($file) @@ -109,10 +109,10 @@ public function does_not_triggen_on_variable_class_instantiation() public function does_not_trigger_on_anonymous_class() { $file = <<<'file' -lint( new QualifiedNamesOnlyForClassName($file) @@ -124,14 +124,14 @@ public function does_not_trigger_on_anonymous_class() /** @test */ public function catches_extends_fqcn() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -143,14 +143,14 @@ class ImportFacades extends \Tighten\TLint\BaseLinter /** @test */ public function catches_extends_fqcn_no_leading_slash() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -162,14 +162,14 @@ class ImportFacades extends Tighten\TLint\BaseLinter /** @test */ public function catches_trait_qualified() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -181,14 +181,14 @@ class ImportFacades /** @test */ public function catches_trait_fully_qualified() { - $file = <<lint( new QualifiedNamesOnlyForClassName($file) @@ -200,19 +200,19 @@ class ImportFacades /** @test */ public function does_not_throw_on_dynamic_class_instantiation() { - $file = <<dispatchers[\$eventType])->dispatch(\$request); - } -} -file; + $file = <<<'file' + dispatchers[$eventType])->dispatch($request); + } + } + file; $lints = (new TLint)->lint( new QualifiedNamesOnlyForClassName($file) diff --git a/tests/Linting/Linters/RemoveLeadingSlashNamespacesTest.php b/tests/Linting/Linters/RemoveLeadingSlashNamespacesTest.php index b5187ac..4cca159 100644 --- a/tests/Linting/Linters/RemoveLeadingSlashNamespacesTest.php +++ b/tests/Linting/Linters/RemoveLeadingSlashNamespacesTest.php @@ -11,14 +11,14 @@ class RemoveLeadingSlashNamespacesTest extends TestCase /** @test */ public function catches_leading_slashes_in_use_statements() { - $file = <<lint( new RemoveLeadingSlashNamespaces($file) @@ -31,11 +31,11 @@ public function catches_leading_slashes_in_use_statements() /** @test */ public function catches_leading_slashes_in_static_calls() { - $file = <<name; -file; + echo \Auth::user()->name; + file; $lints = (new TLint)->lint( new RemoveLeadingSlashNamespaces($file) @@ -47,11 +47,11 @@ public function catches_leading_slashes_in_static_calls() /** @test */ public function catches_leading_slashes_in_instantiations() { - $file = <<lint( new RemoveLeadingSlashNamespaces($file) @@ -63,23 +63,23 @@ public function catches_leading_slashes_in_instantiations() /** @test */ public function does_not_throw_on_variable_class_static_calls() { - $file = <<count() > 0) { - return \$className::all()->random(); - } + class Relationships + { + static function randomOrCreate($className) + { + if ($className::all()->count() > 0) { + return $className::all()->random(); + } - return factory(\$className)->create(); - } -} -file; + return factory($className)->create(); + } + } + file; $lints = (new TLint)->lint( new RemoveLeadingSlashNamespaces($file) @@ -91,16 +91,16 @@ static function randomOrCreate(\$className) /** @test */ public function does_not_throw_when_calling_class_in_a_namespaced_file() { - $file = <<lint( new RemoveLeadingSlashNamespaces($file) @@ -112,16 +112,16 @@ class User extends BaseResource /** @test */ public function catches_leading_slash_in_factories() { - $file = <<define(App\S::class, function (Faker\Generator \$faker) { - return [ - 'user_id' => factory(App\User::class), - 'version_id' => factory(\App\J\V::class), - ]; -}); -file; + $file = <<<'file' + define(App\S::class, function (Faker\Generator $faker) { + return [ + 'user_id' => factory(App\User::class), + 'version_id' => factory(\App\J\V::class), + ]; + }); + file; $lints = (new TLint)->lint( new RemoveLeadingSlashNamespaces($file) diff --git a/tests/Linting/Linters/RequestHelperFunctionWherePossibleTest.php b/tests/Linting/Linters/RequestHelperFunctionWherePossibleTest.php index c6b0228..82c0e33 100644 --- a/tests/Linting/Linters/RequestHelperFunctionWherePossibleTest.php +++ b/tests/Linting/Linters/RequestHelperFunctionWherePossibleTest.php @@ -12,18 +12,18 @@ class RequestHelperFunctionWherePossibleTest extends TestCase public function catches_get_method_usage() { $file = <<<'file' -get('savedVehicleId')); - } -} -file; + class Controller + { + public function index() + { + return SavedVehicle::findOrFail(request()->get('savedVehicleId')); + } + } + file; $lints = (new TLint)->lint( new RequestHelperFunctionWherePossible($file) @@ -36,11 +36,11 @@ public function index() public function does_not_trigger_on_new_instance_method_calls() { $file = <<<'file' -column(); -file; + (new TableBuilder(new TablePresenter())) + ->column(); + file; $lints = (new TLint)->lint( new RequestHelperFunctionWherePossible($file) diff --git a/tests/Linting/Linters/RequestValidationTest.php b/tests/Linting/Linters/RequestValidationTest.php index 6c272c6..651b895 100644 --- a/tests/Linting/Linters/RequestValidationTest.php +++ b/tests/Linting/Linters/RequestValidationTest.php @@ -11,21 +11,21 @@ class RequestValidationTest extends TestCase /** @test */ public function catches_this_validate_method_usage() { - $file = <<validate(['name' => 'required']); - } -} -file; + class ControllerA extends Controller + { + public function store() + { + $this->validate(['name' => 'required']); + } + } + file; $lints = (new TLint)->lint( new RequestValidation($file) @@ -38,18 +38,18 @@ public function store() public function does_not_trigger_on_helper_function_usage() { $file = <<<'file' -validate([ - 'response' => 'required_without:file', - ]); - } -} -file; + validate([ + 'response' => 'required_without:file', + ]); + } + } + file; $lints = (new TLint)->lint( new RequestValidation($file) @@ -62,18 +62,18 @@ public function update() public function does_not_trigger_when_using_request_variable_method() { $file = <<<'file' -validate([]); - } -} -file; + class ControllerA extends Controller + { + public function store(ARequest $request) + { + $request->validate([]); + } + } + file; $lints = (new TLint)->lint( new RequestValidation($file) @@ -86,19 +86,19 @@ public function store(ARequest $request) public function does_not_cause_php_notice_when_value_is_not_an_expression_with_a_name() { $file = <<<'file' -with('errors', (new ViewErrorBag)->add('field', 'message')); - } -} -file; + with('errors', (new ViewErrorBag)->add('field', 'message')); + } + } + file; $lints = (new TLint)->lint( new RequestValidation($file) diff --git a/tests/Linting/Linters/SpaceAfterBladeDirectivesTest.php b/tests/Linting/Linters/SpaceAfterBladeDirectivesTest.php index dd92ff7..216cb4d 100644 --- a/tests/Linting/Linters/SpaceAfterBladeDirectivesTest.php +++ b/tests/Linting/Linters/SpaceAfterBladeDirectivesTest.php @@ -12,12 +12,12 @@ class SpaceAfterBladeDirectivesTest extends TestCase public function it_catches_missing_space_if_statement() { $file = <<<'file' -@if(true) - This is true. -@elseif(false) - This is false. -@endif -file; + @if(true) + This is true. + @elseif(false) + This is false. + @endif + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -31,10 +31,10 @@ public function it_catches_missing_space_if_statement() public function it_catches_missing_space_unless_statement() { $file = <<<'file' -@unless(true) - This isn't true. -@endunless -file; + @unless(true) + This isn't true. + @endunless + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -47,10 +47,10 @@ public function it_catches_missing_space_unless_statement() public function it_catches_missing_space_for_statement() { $file = <<<'file' -@for($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor -file; + @for($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -63,10 +63,10 @@ public function it_catches_missing_space_for_statement() public function it_catches_missing_space_foreach_statement() { $file = <<<'file' -@foreach($users as $user) -
  • {{ $user->name }}
  • -@endforeach -file; + @foreach($users as $user) +
  • {{ $user->name }}
  • + @endforeach + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -79,12 +79,12 @@ public function it_catches_missing_space_foreach_statement() public function it_catches_missing_space_forelse_statement() { $file = <<<'file' -@forelse($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse -file; + @forelse($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -97,10 +97,10 @@ public function it_catches_missing_space_forelse_statement() public function it_catches_missing_space_while_statement() { $file = <<<'file' -@while(true) -

    I'm looping forever.

    -@endwhile -file; + @while(true) +

    I'm looping forever.

    + @endwhile + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -113,10 +113,10 @@ public function it_catches_missing_space_while_statement() public function it_ignores_correctly_spaced_directives() { $file = <<<'file' -@foreach ($users as $user) -
  • {{ $user->name }}
  • -@endforeach -file; + @foreach ($users as $user) +
  • {{ $user->name }}
  • + @endforeach + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -129,38 +129,38 @@ public function it_ignores_correctly_spaced_directives() public function it_catches_missing_space_kitchen_sink() { $file = <<<'file' -@if(true) - This is true. -@elseif(false) - This is false. -@endif - -@if(true) @if($inline) Inline @endif @endif - -@unless(true) - This isn't true. -@endunless - -@for($i = 0; $i < 10; $i++) - The current value is {{ $i }} -@endfor - -@foreach($users as $user) - @foreach($user->emails as $email) -
  • {{ $email }}
  • - @endforeach -@endforeach - -@forelse($users as $user) -
  • {{ $user->name }}
  • -@empty -

    No users

    -@endforelse - -@while(true) -

    I'm looping forever.

    -@endwhile -file; + @if(true) + This is true. + @elseif(false) + This is false. + @endif + + @if(true) @if($inline) Inline @endif @endif + + @unless(true) + This isn't true. + @endunless + + @for($i = 0; $i < 10; $i++) + The current value is {{ $i }} + @endfor + + @foreach($users as $user) + @foreach($user->emails as $email) +
  • {{ $email }}
  • + @endforeach + @endforeach + + @forelse($users as $user) +
  • {{ $user->name }}
  • + @empty +

    No users

    + @endforelse + + @while(true) +

    I'm looping forever.

    + @endwhile + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) @@ -182,14 +182,14 @@ public function it_catches_missing_space_kitchen_sink() public function it_catches_directives_spanning_multiple_lines() { $file = <<<'file' -@foreach([ - Laravel\Memberships\Membership::MEMBER_ROLE, - Laravel\Memberships\Membership::SUPERVISION_ROLE, - Laravel\Memberships\Membership::ADMIN_ROLE, - ] as $role) - -@endforeach -file; + @foreach([ + Laravel\Memberships\Membership::MEMBER_ROLE, + Laravel\Memberships\Membership::SUPERVISION_ROLE, + Laravel\Memberships\Membership::ADMIN_ROLE, + ] as $role) + + @endforeach + file; $lints = (new TLint)->lint( new SpaceAfterBladeDirectives($file) diff --git a/tests/Linting/Linters/SpacesAroundBladeRenderContentTest.php b/tests/Linting/Linters/SpacesAroundBladeRenderContentTest.php index fa0305b..a6757da 100644 --- a/tests/Linting/Linters/SpacesAroundBladeRenderContentTest.php +++ b/tests/Linting/Linters/SpacesAroundBladeRenderContentTest.php @@ -12,8 +12,8 @@ class SpacesAroundBladeRenderContentTest extends TestCase public function catches_missing_spaces_around_blade_render_content() { $file = <<<'file' - {{1 + 1}} -file; + {{1 + 1}} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -26,8 +26,8 @@ public function catches_missing_spaces_around_blade_render_content() public function catches_missing_spaces_around_blade_render_content_after_correctly_spaced() { $file = <<<'file' -{{ 1 + 1 }} {{1 + 1}} -file; + {{ 1 + 1 }} {{1 + 1}} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -40,8 +40,8 @@ public function catches_missing_spaces_around_blade_render_content_after_correct public function catches_extra_spaces_around_blade_render_content() { $file = <<<'file' - {{1 + 1 }} -file; + {{1 + 1 }} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -54,8 +54,8 @@ public function catches_extra_spaces_around_blade_render_content() public function catches_missing_spaces_around_raw_blade_render_content() { $file = <<<'file' - {!!$a!!} -file; + {!!$a!!} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -68,8 +68,8 @@ public function catches_missing_spaces_around_raw_blade_render_content() public function does_not_trigger_when_spaces_are_placed_correctly_raw_blade_render_content() { $file = <<<'file' - {!! $a !!} -file; + {!! $a !!} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -82,8 +82,8 @@ public function does_not_trigger_when_spaces_are_placed_correctly_raw_blade_rend public function does_not_trigger_when_spaces_are_placed_correctly() { $file = <<<'file' - {{ 1 + 1 }} -file; + {{ 1 + 1 }} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -96,10 +96,10 @@ public function does_not_trigger_when_spaces_are_placed_correctly() public function does_not_trigger_on_multiline_renders() { $file = <<<'file' - {{ - 1 + 1 - }} -file; + {{ + 1 + 1 + }} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) @@ -112,8 +112,8 @@ public function does_not_trigger_on_multiline_renders() public function does_not_trigger_on_blade_comment() { $file = <<<'file' -{{-- This comment will not be present in the rendered HTML --}} -file; + {{-- This comment will not be present in the rendered HTML --}} + file; $lints = (new TLint)->lint( new SpacesAroundBladeRenderContent($file) diff --git a/tests/Linting/Linters/UseAnonymousMigrationsTest.php b/tests/Linting/Linters/UseAnonymousMigrationsTest.php index 21dd4cd..62fb763 100644 --- a/tests/Linting/Linters/UseAnonymousMigrationsTest.php +++ b/tests/Linting/Linters/UseAnonymousMigrationsTest.php @@ -11,25 +11,24 @@ class UseAnonymousMigrationsTest extends TestCase /** @test */ public function it_catches_named_class_migrations() { - $file = <<lint( new UseAnonymousMigrations($file) @@ -41,25 +40,24 @@ public function down() /** @test */ public function it_allows_anonymous_migrations() { - $file = <<lint( new UseAnonymousMigrations($file) diff --git a/tests/Linting/ParseErrorConvertsToLintTest.php b/tests/Linting/ParseErrorConvertsToLintTest.php index aadae38..7b3f9f8 100644 --- a/tests/Linting/ParseErrorConvertsToLintTest.php +++ b/tests/Linting/ParseErrorConvertsToLintTest.php @@ -18,17 +18,17 @@ public function gracefully_handles_parse_error() $commandTester = new CommandTester($command); $file = <<<'file' -