Skip to content

Commit a164bda

Browse files
committed
Applied Pint v1.10 PHP code style fixes
1 parent b54be8c commit a164bda

File tree

10 files changed

+70
-75
lines changed

10 files changed

+70
-75
lines changed

pint.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{
22
"preset": "laravel",
33
"rules": {
4-
"braces": false,
54
"blank_line_before_statement": false,
6-
"class_definition": false,
75
"binary_operator_spaces": false,
8-
"concat_space": false,
9-
"no_unused_imports": false,
106
"phpdoc_separation": false,
11-
"Laravel/laravel_phpdoc_alignment": false,
127
"modernize_strpos": true
138
},
149
"exclude": [

src/Concerns/ReplacesBindings.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function replaceBindings(string $sql, array $bindings): string
2424
/**
2525
* Get final value that will be displayed in query.
2626
*
27-
* @param mixed $value
27+
* @param mixed $value
2828
*
2929
* @return int|string
3030
*/
@@ -38,27 +38,27 @@ protected function value($value)
3838
return (int) $value;
3939
}
4040

41-
return is_numeric($value) ? $value : "'" . $value . "'";
41+
return is_numeric($value) ? $value : "'".$value."'";
4242
}
4343

4444
/**
4545
* Get regex to be used for named parameter with given name.
4646
*
47-
* @param string $name
47+
* @param string $name
4848
*/
4949
protected function getNamedParameterRegex($name): string
5050
{
5151
if (mb_substr($name, 0, 1) == ':') {
5252
$name = mb_substr($name, 1);
5353
}
5454

55-
return $this->wrapRegex($this->notInsideQuotes('\:' . preg_quote($name), false));
55+
return $this->wrapRegex($this->notInsideQuotes('\:'.preg_quote($name), false));
5656
}
5757

5858
/**
5959
* Format bindings values.
6060
*
61-
* @param array $bindings
61+
* @param array $bindings
6262
*
6363
* @return array
6464
*/
@@ -84,28 +84,28 @@ protected function getRegex()
8484
{
8585
return $this->wrapRegex(
8686
$this->notInsideQuotes('?')
87-
. '|' .
87+
.'|'.
8888
$this->notInsideQuotes('\:\w+', false)
8989
);
9090
}
9191

9292
/**
9393
* Wrap regex.
9494
*
95-
* @param string $regex
95+
* @param string $regex
9696
*
9797
* @return string
9898
*/
9999
protected function wrapRegex($regex)
100100
{
101-
return '#' . $regex . '#ms';
101+
return '#'.$regex.'#ms';
102102
}
103103

104104
/**
105105
* Create partial regex to find given text not inside quotes.
106106
*
107-
* @param string $string
108-
* @param bool $quote
107+
* @param string $string
108+
* @param bool $quote
109109
*
110110
* @return string
111111
*/
@@ -117,9 +117,9 @@ protected function notInsideQuotes($string, $quote = true)
117117

118118
return
119119
// double quotes - ignore "" and everything inside quotes for example " abc \"err "
120-
'(?:""|"(?:[^"]|\\")*?[^\\\]")(*SKIP)(*F)|' . $string .
121-
'|' .
120+
'(?:""|"(?:[^"]|\\")*?[^\\\]")(*SKIP)(*F)|'.$string.
121+
'|'.
122122
// single quotes - ignore '' and everything inside quotes for example ' abc \'err '
123-
'(?:\\\'\\\'|\'(?:[^\']|\\\')*?[^\\\]\')(*SKIP)(*F)|' . $string;
123+
'(?:\\\'\\\'|\'(?:[^\']|\\\')*?[^\\\]\')(*SKIP)(*F)|'.$string;
124124
}
125125
}

src/FileName.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function __construct(
2222
public function getLogfile(): string
2323
{
2424
return
25-
$this->parseFileName($this->config->queriesFileName()) .
26-
$this->suffix() .
25+
$this->parseFileName($this->config->queriesFileName()).
26+
$this->suffix().
2727
$this->config->fileExtension();
2828
}
2929

src/Formatter.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getHeader(): string
8080
$formatted[] = $this->separatorLine();
8181
$maxKeyLength = max(array_map('strlen', array_keys($headers)));
8282
foreach ($headers as $key => $value) {
83-
$formatted[] = '-- ' . Str::padRight(Str::ucfirst($key) . ':', $maxKeyLength + 2) . $value;
83+
$formatted[] = '-- '.Str::padRight(Str::ucfirst($key).':', $maxKeyLength + 2).$value;
8484
}
8585
$formatted[] = $this->separatorLine();
8686

@@ -92,7 +92,7 @@ public function getHeader(): string
9292
*/
9393
protected function time(float $time): string
9494
{
95-
return $this->config->useSeconds() ? ($time / 1000.0) . 's' : $time . 'ms';
95+
return $this->config->useSeconds() ? ($time / 1000.0).'s' : $time.'ms';
9696
}
9797

9898
/**
@@ -101,16 +101,16 @@ protected function time(float $time): string
101101
protected function originLine(): string
102102
{
103103
return $this->app->runningInConsole()
104-
? '(console) ' . $this->getArtisanLine()
105-
: '(request) ' . $this->getRequestLine();
104+
? '(console) '.$this->getArtisanLine()
105+
: '(request) '.$this->getRequestLine();
106106
}
107107

108108
/**
109109
* Get query line.
110110
*/
111111
protected function getQueryLine(SqlQuery $query): string
112112
{
113-
return $query->get() . ';';
113+
return $query->get().';';
114114
}
115115

116116
/**
@@ -132,14 +132,14 @@ protected function getArtisanLine(): string
132132
*/
133133
protected function getRequestLine(): string
134134
{
135-
return $this->app['request']->method() . ' ' . $this->app['request']->fullUrl();
135+
return $this->app['request']->method().' '.$this->app['request']->fullUrl();
136136
}
137137

138138
/**
139139
* Get separator line.
140140
*/
141141
protected function separatorLine(): string
142142
{
143-
return '-- ' . str_repeat('-', 50);
143+
return '-- '.str_repeat('-', 50);
144144
}
145145
}

src/Providers/EventServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function boot()
5454
*/
5555
protected function configFileLocation(): string
5656
{
57-
return realpath(__DIR__ . '/../../config/sql-reporter.php');
57+
return realpath(__DIR__.'/../../config/sql-reporter.php');
5858
}
5959
}

src/Writer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ protected function shouldLogQuery(SqlQuery $query): bool
8383
protected function writeLine(string $line, bool $override = false): int|false
8484
{
8585
return file_put_contents(
86-
$this->directory() . DIRECTORY_SEPARATOR . $this->fileName->getLogfile(),
87-
$line . PHP_EOL,
86+
$this->directory().DIRECTORY_SEPARATOR.$this->fileName->getLogfile(),
87+
$line.PHP_EOL,
8888
$override ? 0 : FILE_APPEND
8989
);
9090
}

tests/Unit/EventServiceProviderTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public function it_merges_config_and_publishes_when_nothing_should_be_logged()
2525

2626
$baseDir = '/some/sample/directory';
2727

28-
// $app->shouldReceive('configFileLocation')->atLeast()->once()
29-
// ->withNoArgs()->andReturn($baseDir . '/sql-reporter.php');
28+
// $app->shouldReceive('configFileLocation')->atLeast()->once()
29+
// ->withNoArgs()->andReturn($baseDir . '/sql-reporter.php');
3030

31-
$configFile = realpath(__DIR__ . '/../../config/sql-reporter.php');
31+
$configFile = realpath(__DIR__.'/../../config/sql-reporter.php');
3232
$provider->shouldReceive('mergeConfigFrom')->once()->with(
3333
$configFile,
3434
'sql-reporter'
@@ -41,9 +41,9 @@ public function it_merges_config_and_publishes_when_nothing_should_be_logged()
4141
$provider->register();
4242
$this->assertTrue(true);
4343

44-
// $provider->boot();
45-
// $provider->shouldReceive('publishes')->once()->with(
46-
// [$configFile => config_path('sql-reporter.php')], 'config'
47-
// );
44+
// $provider->boot();
45+
// $provider->shouldReceive('publishes')->once()->with(
46+
// [$configFile => config_path('sql-reporter.php')], 'config'
47+
// );
4848
}
4949
}

tests/Unit/SqlLoggerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function it_runs_writer_with_valid_query()
3434
]);
3535

3636
$sqlQuery = new SqlQuery(1, 'anything', [], 1.23);
37-
// $this->writer->shouldReceive('writeQuery')->once()->with($sqlQuery)
37+
// $this->writer->shouldReceive('writeQuery')->once()->with($sqlQuery)
3838
$this->writer->shouldReceive('writeQuery')->once()->with(Mockery::on(function ($arg) use ($sqlQuery) {
3939
return $sqlQuery == $arg;
4040
}));
@@ -52,13 +52,13 @@ public function it_uses_valid_query_number_for_multiple_queries()
5252
]);
5353

5454
$sqlQuery = new SqlQuery(1, 'anything', ['one', 1], 1.23);
55-
// $this->writer->shouldReceive('writeQuery')->once()->with($sqlQuery);
55+
// $this->writer->shouldReceive('writeQuery')->once()->with($sqlQuery);
5656
$this->writer->shouldReceive('writeQuery')->once()->with(Mockery::on(function ($arg) use ($sqlQuery) {
5757
return $sqlQuery == $arg;
5858
}));
5959

6060
$sqlQuery2 = new SqlQuery(2, 'anything2', ['two', 2], 4.56);
61-
// $this->writer->shouldReceive('writeQuery')->once()->with($sqlQuery2);
61+
// $this->writer->shouldReceive('writeQuery')->once()->with($sqlQuery2);
6262
$this->writer->shouldReceive('writeQuery')->once()->with(Mockery::on(function ($arg) use ($sqlQuery2) {
6363
return $sqlQuery2 == $arg;
6464
}));

tests/Unit/SqlQueryLogSubscriberTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ protected function setUp(): void
1717
$this->logger = Mockery::mock(SqlLogger::class);
1818
}
1919

20-
/** @test */
21-
public function foo_bar()
22-
{
23-
// TODO
24-
$this->assertTrue(true);
25-
}
20+
/** @test */
21+
public function foo_bar()
22+
{
23+
// TODO
24+
$this->assertTrue(true);
25+
}
2626
}

0 commit comments

Comments
 (0)