Skip to content

Commit 72f3117

Browse files
authored
Laravel preset class parentheses (#285)
* Add rule to remove empty class parentheses to laravel preset * Apply new laravel rule on codebase * Apply new laravel rule to test cases
1 parent 1dbc291 commit 72f3117

File tree

12 files changed

+27
-20
lines changed

12 files changed

+27
-20
lines changed

app/Actions/ElaborateSummary.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public function execute($totalFiles, $changes)
6969
protected function displayUsingFormatter($summary, $totalFiles)
7070
{
7171
$reporter = match ($format = $this->input->getOption('format')) {
72-
'checkstyle' => new FixReport\CheckstyleReporter(),
73-
'gitlab' => new FixReport\GitlabReporter(),
74-
'json' => new FixReport\JsonReporter(),
75-
'junit' => new FixReport\JunitReporter(),
76-
'txt' => new FixReport\TextReporter(),
77-
'xml' => new FixReport\XmlReporter(),
72+
'checkstyle' => new FixReport\CheckstyleReporter,
73+
'gitlab' => new FixReport\GitlabReporter,
74+
'json' => new FixReport\JsonReporter,
75+
'junit' => new FixReport\JunitReporter,
76+
'txt' => new FixReport\TextReporter,
77+
'xml' => new FixReport\XmlReporter,
7878
default => abort(1, sprintf('Format [%s] is not supported.', $format)),
7979
};
8080

app/Factories/ConfigurationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ConfigurationFactory
4242
*/
4343
public static function preset($rules)
4444
{
45-
return (new Config())
45+
return (new Config)
4646
->setParallelConfig(ParallelConfigFactory::detect())
4747
->setFinder(self::finder())
4848
->setRules(array_merge($rules, resolve(ConfigurationJsonRepository::class)->rules()))

app/Factories/ConfigurationResolverFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function fromIO($input, $output)
7070
'show-progress' => 'true',
7171
],
7272
Project::path(),
73-
new ToolInfo(),
73+
new ToolInfo,
7474
);
7575

7676
$totalFiles = count(new ArrayIterator(iterator_to_array(

app/Output/ProgressOutput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
protected $input,
3838
protected $output,
3939
) {
40-
$this->symbolsPerLine = (new Terminal())->getWidth() - 4;
40+
$this->symbolsPerLine = (new Terminal)->getWidth() - 4;
4141
}
4242

4343
/**
@@ -70,7 +70,7 @@ public function handle($event)
7070
{
7171
$symbolsOnCurrentLine = $this->processed % $this->symbolsPerLine;
7272

73-
if ($symbolsOnCurrentLine >= (new Terminal())->getWidth() - 4) {
73+
if ($symbolsOnCurrentLine >= (new Terminal)->getWidth() - 4) {
7474
$symbolsOnCurrentLine = 0;
7575
}
7676

app/Providers/AppServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function boot()
2626
public function register()
2727
{
2828
$this->app->singleton(ErrorsManager::class, function () {
29-
return new ErrorsManager();
29+
return new ErrorsManager;
3030
});
3131

3232
$this->app->singleton(EventDispatcher::class, function () {
33-
return new EventDispatcher();
33+
return new EventDispatcher;
3434
});
3535
}
3636
}

app/ValueObjects/Issue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function code()
7474

7575
$exception = $this->payload['source']->getPrevious() ?: $this->payload['source'];
7676

77-
return (new Highlighter())->highlight($content, $exception->getLine());
77+
return (new Highlighter)->highlight($content, $exception->getLine());
7878
}
7979

8080
return $this->diff();
@@ -98,7 +98,7 @@ public function symbol()
9898
protected function diff()
9999
{
100100
if ($this->payload['diff']) {
101-
$highlighter = new Highlighter();
101+
$highlighter = new Highlighter;
102102
$reflector = new ReflectionClass($highlighter);
103103

104104
$diff = $this->payload['diff'];

resources/presets/laravel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
],
8383
'native_function_casing' => true,
8484
'native_type_declaration_casing' => true,
85+
'new_with_parentheses' => [
86+
'named_class' => false,
87+
'anonymous_class' => false,
88+
],
8589
'no_alias_functions' => true,
8690
'no_alias_language_construct_call' => true,
8791
'no_alternative_syntax' => true,

tests/Feature/DirtyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
->shouldReceive('dirty')
1010
->once()
1111
->andReturn([
12-
base_path('tests/Fixtures/without-issues/file.php'),
12+
base_path('tests/Fixtures/without-issues-laravel/file.php'),
1313
]);
1414

1515
$this->swap(PathsRepository::class, $paths);
@@ -28,7 +28,7 @@
2828
->shouldReceive('dirty')
2929
->once()
3030
->andReturn([
31-
base_path('tests/Fixtures/without-issues/file.php'),
31+
base_path('tests/Fixtures/without-issues-laravel/file.php'),
3232
]);
3333

3434
$this->swap(PathsRepository::class, $paths);

tests/Feature/PresetTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
it('uses the laravel preset by default', function () {
44
[$statusCode, $output] = run('default', [
5-
'path' => base_path('tests/Fixtures/without-issues'),
5+
'path' => base_path('tests/Fixtures/without-issues-laravel'),
66
]);
77

88
expect($statusCode)->toBe(0)
@@ -34,7 +34,7 @@
3434

3535
it('may use the Laravel preset', function () {
3636
[$statusCode, $output] = run('default', [
37-
'path' => base_path('tests/Fixtures/without-issues'),
37+
'path' => base_path('tests/Fixtures/without-issues-laravel'),
3838
'--preset' => 'laravel',
3939
]);
4040

tests/Feature/RepairTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
it('exits with status 0 without fixes', function () {
2525
[$statusCode, $output] = run('default', [
26-
'path' => base_path('tests/Fixtures/without-issues'),
26+
'path' => base_path('tests/Fixtures/without-issues-laravel'),
2727
'--repair' => true,
2828
'--test' => false,
2929
]);

0 commit comments

Comments
 (0)