Skip to content

Commit 8523eec

Browse files
committed
Merge branch 'master' into 9.x
2 parents 46c6e78 + 62716d3 commit 8523eec

File tree

5 files changed

+29
-83
lines changed

5 files changed

+29
-83
lines changed

src/DbProfilerServiceProvider.php

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,23 @@ class DbProfilerServiceProvider extends ServiceProvider
1212
{
1313
/**
1414
* The query counter.
15-
*
16-
* @var int
1715
*/
18-
private $counter = 1;
16+
private int $counter = 1;
1917

2018
/**
2119
* Register the service provider.
22-
*
23-
* @return void
2420
*/
25-
public function register()
21+
public function register(): void
2622
{
2723
$this->mergeConfigFrom(__DIR__.'/../config/db-profiler.php', 'db-profiler');
2824
}
2925

3026
/**
3127
* Boot the service provider.
3228
*
33-
* @return void
34-
*
3529
* @noinspection ForgottenDebugOutputInspection
3630
*/
37-
public function boot()
31+
public function boot(): void
3832
{
3933
if (!$this->isEnabled()) {
4034
return;
@@ -50,10 +44,8 @@ public function boot()
5044

5145
/**
5246
* Check whether database profiling is enabled or not.
53-
*
54-
* @return bool
5547
*/
56-
private function isEnabled()
48+
private function isEnabled(): bool
5749
{
5850
if (!$this->app->isLocal() && !config('db-profiler.force')) {
5951
return false;
@@ -66,22 +58,15 @@ private function isEnabled()
6658

6759
/**
6860
* Apply query bindings to the given SQL query.
69-
*
70-
* @param string $sql
71-
* @param array $bindings
72-
* @return string
7361
*/
74-
private function applyQueryBindings(string $sql, array $bindings)
62+
private function applyQueryBindings(string $sql, array $bindings): string
7563
{
7664
$bindings = collect($bindings)->map(function ($binding) {
77-
switch (gettype($binding)) {
78-
case 'boolean':
79-
return (int) $binding;
80-
case 'string':
81-
return "'{$binding}'";
82-
default:
83-
return $binding;
84-
}
65+
return match (gettype($binding)) {
66+
'boolean' => (int) $binding,
67+
'string' => "'{$binding}'",
68+
default => $binding,
69+
};
8570
})->toArray();
8671

8772
return Str::replaceArray('?', $bindings, $sql);

tests/ConsoleProfilingTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@ class ConsoleProfilingTest extends TestCase
66
{
77
/**
88
* Define whether the app is running in console or not.
9-
*
10-
* @return bool
119
*/
12-
protected function runningInConsole()
10+
protected function runningInConsole(): bool
1311
{
1412
return true;
1513
}
1614

1715
/**
1816
* Emulate the "vvv" flag set.
19-
*
20-
* @return $this
2117
*/
22-
protected function withVvv()
18+
protected function withVvv(): self
2319
{
2420
$_SERVER['argv']['-vvv'] = true;
2521

tests/HttpProfilingTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@ class HttpProfilingTest extends TestCase
88
{
99
/**
1010
* Define whether the app is running in console or not.
11-
*
12-
* @return bool
1311
*/
14-
protected function runningInConsole()
12+
protected function runningInConsole(): bool
1513
{
1614
return false;
1715
}
1816

1917
/**
2018
* Emulate the "vvv" flag set.
21-
*
22-
* @return $this
2319
*/
24-
protected function withVvv()
20+
protected function withVvv(): self
2521
{
2622
Request::merge(['vvv' => true]);
2723

tests/TestCase.php

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
2525

2626
/**
2727
* The emulated environment.
28-
*
29-
* @var string
3028
*/
31-
private $env;
29+
private string $env;
3230

3331
/**
3432
* Setup the test environment.
35-
*
36-
* @return void
3733
*/
3834
protected function setUp(): void
3935
{
@@ -44,10 +40,8 @@ protected function setUp(): void
4440

4541
/**
4642
* Setup the database.
47-
*
48-
* @return void
4943
*/
50-
private function setUpDatabase()
44+
private function setUpDatabase(): void
5145
{
5246
config(['database.default' => 'testing']);
5347
config(['database.connections.testing.foreign_key_constraints' => true]);
@@ -61,10 +55,8 @@ private function setUpDatabase()
6155

6256
/**
6357
* Emulate the local environment.
64-
*
65-
* @return $this
6658
*/
67-
protected function local()
59+
protected function local(): self
6860
{
6961
$this->env = 'local';
7062

@@ -73,10 +65,8 @@ protected function local()
7365

7466
/**
7567
* Emulate the non-local environment.
76-
*
77-
* @return $this
7868
*/
79-
protected function notLocal()
69+
protected function notLocal(): self
8070
{
8171
$this->env = 'production';
8272

@@ -85,24 +75,18 @@ protected function notLocal()
8575

8676
/**
8777
* Define whether the app is running in console or not.
88-
*
89-
* @return bool
9078
*/
91-
abstract protected function runningInConsole();
79+
abstract protected function runningInConsole(): bool;
9280

9381
/**
9482
* Emulate the "vvv" flag set.
95-
*
96-
* @return $this
9783
*/
98-
abstract protected function withVvv();
84+
abstract protected function withVvv(): self;
9985

10086
/**
10187
* Emulate the app boot.
102-
*
103-
* @return void
10488
*/
105-
protected function boot()
89+
protected function boot(): void
10690
{
10791
$app = mock(Application::class);
10892
$app->expects('isLocal')->andReturn($this->env == 'local');
@@ -116,10 +100,8 @@ protected function boot()
116100

117101
/**
118102
* Assert that the database profiler is activated.
119-
*
120-
* @return void
121103
*/
122-
protected function assertDbProfilerActivated()
104+
protected function assertDbProfilerActivated(): void
123105
{
124106
/** @var \Illuminate\Database\Connection $connection */
125107
$connection = DB::connection();
@@ -129,10 +111,8 @@ protected function assertDbProfilerActivated()
129111

130112
/**
131113
* Assert that the database profiler is not activated.
132-
*
133-
* @return void
134114
*/
135-
protected function assertDbProfilerNotActivated()
115+
protected function assertDbProfilerNotActivated(): void
136116
{
137117
/** @var \Illuminate\Database\Connection $connection */
138118
$connection = DB::connection();
@@ -142,10 +122,8 @@ protected function assertDbProfilerNotActivated()
142122

143123
/**
144124
* Assert that the database queries are dumped.
145-
*
146-
* @return void
147125
*/
148-
protected function assertDbQueriesDumped()
126+
protected function assertDbQueriesDumped(): void
149127
{
150128
$queries = collect([
151129
'[1]: select * from "posts"',
@@ -194,11 +172,8 @@ protected function assertDbQueriesDumped()
194172

195173
/**
196174
* Prepare the query pattern for mocking.
197-
*
198-
* @param string $query
199-
* @return string
200175
*/
201-
private function prepareQueryPattern(string $query)
176+
private function prepareQueryPattern(string $query): string
202177
{
203178
$query = preg_quote($query, '/');
204179

@@ -207,8 +182,6 @@ private function prepareQueryPattern(string $query)
207182

208183
/**
209184
* Clean up the testing environment before the next test.
210-
*
211-
* @return void
212185
*/
213186
protected function tearDown(): void
214187
{

tests/fixture/database/migrations/2016_11_01_131415_create_posts_table.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreatePostsTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migration.
11-
*
12-
* @return void
1311
*/
14-
public function up()
12+
public function up(): void
1513
{
1614
Schema::create('posts', function (Blueprint $table) {
1715
$table->increments('id');
@@ -24,11 +22,9 @@ public function up()
2422

2523
/**
2624
* Rollback the migration.
27-
*
28-
* @return void
2925
*/
30-
public function down()
26+
public function down(): void
3127
{
3228
Schema::drop('posts');
3329
}
34-
}
30+
};

0 commit comments

Comments
 (0)