Skip to content

Commit e1dafd7

Browse files
committed
Update coding standard
1 parent 818e582 commit e1dafd7

32 files changed

Lines changed: 139 additions & 134 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"require-dev": {
4242
"ext-xdebug": "*",
43-
"aplus/coding-standard": "^1.14",
43+
"aplus/coding-standard": "^2.1",
4444
"ergebnis/composer-normalize": "^2.25",
4545
"jetbrains/phpstorm-attributes": "^1.0",
4646
"phpmd/phpmd": "^2.13",

src/Database.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ class Database
8585
* @throws mysqli_sql_exception if connections fail
8686
*/
8787
public function __construct(
88-
#[SensitiveParameter] array | string $username,
89-
#[SensitiveParameter] string $password = null,
88+
#[SensitiveParameter]
89+
array | string $username,
90+
#[SensitiveParameter]
91+
string $password = null,
9092
string $schema = null,
9193
string $host = 'localhost',
9294
int $port = 3306,
@@ -175,13 +177,15 @@ protected function makeConfig(array $config) : array
175177
* @return static
176178
*/
177179
protected function connect(
178-
#[SensitiveParameter] array | string $username,
179-
#[SensitiveParameter] string $password = null,
180+
#[SensitiveParameter]
181+
array | string $username,
182+
#[SensitiveParameter]
183+
string $password = null,
180184
string $schema = null,
181185
string $host = 'localhost',
182186
int $port = 3306
183187
) : static {
184-
if ( ! \is_array($username)) {
188+
if (!\is_array($username)) {
185189
$username = [
186190
'host' => $host,
187191
'port' => $port,
@@ -285,7 +289,7 @@ public function isOpen() : bool
285289
*/
286290
public function close() : bool
287291
{
288-
if ( ! $this->isOpen()) {
292+
if (!$this->isOpen()) {
289293
return true;
290294
}
291295
$closed = $this->mysqli->close();
@@ -633,7 +637,8 @@ public function exec(#[Language('SQL')] string $statement) : int | string
633637
* @return Result
634638
*/
635639
public function query(
636-
#[Language('SQL')] string $statement,
640+
#[Language('SQL')]
641+
string $statement,
637642
bool $buffered = true
638643
) : Result {
639644
$this->lastQuery = $statement;

src/Debug/DatabaseCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public function getActivities() : array
7272
public function getContents() : string
7373
{
7474
\ob_start();
75-
if ( ! isset($this->database)) {
75+
if (!isset($this->database)) {
7676
echo '<p>This collector has not been added to a Database instance.</p>';
7777
return \ob_get_clean(); // @phpstan-ignore-line
7878
}
7979
echo $this->showHeader();
80-
if ( ! $this->hasData()) {
80+
if (!$this->hasData()) {
8181
echo '<p>Did not run statements.</p>';
8282
return \ob_get_clean(); // @phpstan-ignore-line
8383
}

src/Definition/AlterSchema.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function schema(string $schemaName) : static
3434

3535
protected function renderSchema() : ?string
3636
{
37-
if ( ! isset($this->sql['schema'])) {
37+
if (!isset($this->sql['schema'])) {
3838
return null;
3939
}
4040
$schema = $this->sql['schema'];
@@ -57,7 +57,7 @@ public function charset(string $charset) : static
5757

5858
protected function renderCharset() : ?string
5959
{
60-
if ( ! isset($this->sql['charset'])) {
60+
if (!isset($this->sql['charset'])) {
6161
return null;
6262
}
6363
$charset = $this->database->quote($this->sql['charset']);
@@ -77,7 +77,7 @@ public function collate(string $collation) : static
7777

7878
protected function renderCollate() : ?string
7979
{
80-
if ( ! isset($this->sql['collation'])) {
80+
if (!isset($this->sql['collation'])) {
8181
return null;
8282
}
8383
$collation = $this->database->quote($this->sql['collation']);
@@ -95,7 +95,7 @@ public function upgrade() : static
9595

9696
protected function renderUpgrade() : ?string
9797
{
98-
if ( ! isset($this->sql['upgrade'])) {
98+
if (!isset($this->sql['upgrade'])) {
9999
return null;
100100
}
101101
if (isset($this->sql['charset']) || isset($this->sql['collation'])) {
@@ -108,9 +108,9 @@ protected function renderUpgrade() : ?string
108108

109109
protected function checkSpecifications() : void
110110
{
111-
if ( ! isset($this->sql['charset'])
112-
&& ! isset($this->sql['collation'])
113-
&& ! isset($this->sql['upgrade'])
111+
if (!isset($this->sql['charset'])
112+
&& !isset($this->sql['collation'])
113+
&& !isset($this->sql['upgrade'])
114114
) {
115115
throw new LogicException(
116116
'ALTER SCHEMA must have a specification'

src/Definition/AlterTable.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function online() : static
7171

7272
protected function renderOnline() : ?string
7373
{
74-
if ( ! isset($this->sql['online'])) {
74+
if (!isset($this->sql['online'])) {
7575
return null;
7676
}
7777
return ' ONLINE';
@@ -88,7 +88,7 @@ public function ignore() : static
8888

8989
protected function renderIgnore() : ?string
9090
{
91-
if ( ! isset($this->sql['ignore'])) {
91+
if (!isset($this->sql['ignore'])) {
9292
return null;
9393
}
9494
return ' IGNORE';
@@ -102,7 +102,7 @@ public function ifExists() : static
102102

103103
protected function renderIfExists() : ?string
104104
{
105-
if ( ! isset($this->sql['if_exists'])) {
105+
if (!isset($this->sql['if_exists'])) {
106106
return null;
107107
}
108108
return ' IF EXISTS';
@@ -140,7 +140,7 @@ public function wait(int $seconds) : static
140140

141141
protected function renderWait() : ?string
142142
{
143-
if ( ! isset($this->sql['wait'])) {
143+
if (!isset($this->sql['wait'])) {
144144
return null;
145145
}
146146
if ($this->sql['wait'] < 0) {
@@ -159,7 +159,7 @@ public function noWait() : static
159159

160160
protected function renderNoWait() : ?string
161161
{
162-
if ( ! isset($this->sql['no_wait'])) {
162+
if (!isset($this->sql['no_wait'])) {
163163
return null;
164164
}
165165
if (isset($this->sql['wait'])) {
@@ -199,7 +199,7 @@ public function addIfNotExists(callable $definition) : static
199199

200200
protected function renderAdd() : ?string
201201
{
202-
if ( ! isset($this->sql['add'])) {
202+
if (!isset($this->sql['add'])) {
203203
return null;
204204
}
205205
$parts = [];
@@ -243,7 +243,7 @@ public function changeIfExists(callable $definition) : static
243243

244244
protected function renderChange() : ?string
245245
{
246-
if ( ! isset($this->sql['change'])) {
246+
if (!isset($this->sql['change'])) {
247247
return null;
248248
}
249249
$parts = [];
@@ -287,7 +287,7 @@ public function modifyIfExists(callable $definition) : static
287287

288288
protected function renderModify() : ?string
289289
{
290-
if ( ! isset($this->sql['modify'])) {
290+
if (!isset($this->sql['modify'])) {
291291
return null;
292292
}
293293
$parts = [];
@@ -319,7 +319,7 @@ public function dropColumnIfExists(string $name) : static
319319

320320
protected function renderDropColumns() : ?string
321321
{
322-
if ( ! isset($this->sql['drop_columns'])) {
322+
if (!isset($this->sql['drop_columns'])) {
323323
return null;
324324
}
325325
$drops = [];
@@ -339,7 +339,7 @@ public function dropPrimaryKey() : static
339339

340340
protected function renderDropPrimaryKey() : ?string
341341
{
342-
if ( ! isset($this->sql['drop_primary_key'])) {
342+
if (!isset($this->sql['drop_primary_key'])) {
343343
return null;
344344
}
345345
return ' DROP PRIMARY KEY';
@@ -359,7 +359,7 @@ public function dropKeyIfExists(string $name) : static
359359

360360
protected function renderDropKeys() : ?string
361361
{
362-
if ( ! isset($this->sql['drop_keys'])) {
362+
if (!isset($this->sql['drop_keys'])) {
363363
return null;
364364
}
365365
$drops = [];
@@ -385,7 +385,7 @@ public function dropForeignKeyIfExists(string $name) : static
385385

386386
protected function renderDropForeignKeys() : ?string
387387
{
388-
if ( ! isset($this->sql['drop_foreign_keys'])) {
388+
if (!isset($this->sql['drop_foreign_keys'])) {
389389
return null;
390390
}
391391
$drops = [];
@@ -411,7 +411,7 @@ public function dropConstraintIfExists(string $name) : static
411411

412412
protected function renderDropConstraints() : ?string
413413
{
414-
if ( ! isset($this->sql['drop_constraints'])) {
414+
if (!isset($this->sql['drop_constraints'])) {
415415
return null;
416416
}
417417
$drops = [];
@@ -431,7 +431,7 @@ public function disableKeys() : static
431431

432432
protected function renderDisableKeys() : ?string
433433
{
434-
if ( ! isset($this->sql['disable_keys'])) {
434+
if (!isset($this->sql['disable_keys'])) {
435435
return null;
436436
}
437437
return ' DISABLE KEYS';
@@ -445,7 +445,7 @@ public function enableKeys() : static
445445

446446
protected function renderEnableKeys() : ?string
447447
{
448-
if ( ! isset($this->sql['enable_keys'])) {
448+
if (!isset($this->sql['enable_keys'])) {
449449
return null;
450450
}
451451
return ' ENABLE KEYS';
@@ -459,7 +459,7 @@ public function renameTo(string $newTableName) : static
459459

460460
protected function renderRenameTo() : ?string
461461
{
462-
if ( ! isset($this->sql['rename_to'])) {
462+
if (!isset($this->sql['rename_to'])) {
463463
return null;
464464
}
465465
return ' RENAME TO ' . $this->database->protectIdentifier($this->sql['rename_to']);
@@ -475,7 +475,7 @@ public function orderBy(string $column, string ...$columns) : static
475475

476476
protected function renderOrderBy() : ?string
477477
{
478-
if ( ! isset($this->sql['order_by'])) {
478+
if (!isset($this->sql['order_by'])) {
479479
return null;
480480
}
481481
$columns = [];
@@ -493,7 +493,7 @@ public function renameColumn(string $name, string $newName) : static
493493

494494
protected function renderRenameColumns() : ?string
495495
{
496-
if ( ! isset($this->sql['rename_columns'])) {
496+
if (!isset($this->sql['rename_columns'])) {
497497
return null;
498498
}
499499
$renames = [];
@@ -513,7 +513,7 @@ public function renameKey(string $name, string $newName) : static
513513

514514
protected function renderRenameKeys() : ?string
515515
{
516-
if ( ! isset($this->sql['rename_keys'])) {
516+
if (!isset($this->sql['rename_keys'])) {
517517
return null;
518518
}
519519
$renames = [];
@@ -536,7 +536,7 @@ public function convertToCharset(string $charset, string $collation = null) : st
536536

537537
protected function renderConvertToCharset() : ?string
538538
{
539-
if ( ! isset($this->sql['convert_to_charset'])) {
539+
if (!isset($this->sql['convert_to_charset'])) {
540540
return null;
541541
}
542542
$charset = $this->database->quote($this->sql['convert_to_charset']['charset']);
@@ -555,7 +555,7 @@ public function charset(?string $charset) : static
555555

556556
protected function renderCharset() : ?string
557557
{
558-
if ( ! isset($this->sql['charset'])) {
558+
if (!isset($this->sql['charset'])) {
559559
return null;
560560
}
561561
$charset = \strtolower($this->sql['charset']);
@@ -573,7 +573,7 @@ public function collate(?string $collation) : static
573573

574574
protected function renderCollate() : ?string
575575
{
576-
if ( ! isset($this->sql['collate'])) {
576+
if (!isset($this->sql['collate'])) {
577577
return null;
578578
}
579579
$collate = \strtolower($this->sql['collate']);
@@ -602,11 +602,11 @@ public function lock(string $type) : static
602602

603603
protected function renderLock() : ?string
604604
{
605-
if ( ! isset($this->sql['lock'])) {
605+
if (!isset($this->sql['lock'])) {
606606
return null;
607607
}
608608
$lock = \strtoupper($this->sql['lock']);
609-
if ( ! \in_array($lock, [
609+
if (!\in_array($lock, [
610610
static::LOCK_DEFAULT,
611611
static::LOCK_EXCLUSIVE,
612612
static::LOCK_NONE,
@@ -625,7 +625,7 @@ public function force() : static
625625

626626
protected function renderForce() : ?string
627627
{
628-
if ( ! isset($this->sql['force'])) {
628+
if (!isset($this->sql['force'])) {
629629
return null;
630630
}
631631
return ' FORCE';
@@ -651,11 +651,11 @@ public function algorithm(string $algo) : static
651651

652652
protected function renderAlgorithm() : ?string
653653
{
654-
if ( ! isset($this->sql['algorithm'])) {
654+
if (!isset($this->sql['algorithm'])) {
655655
return null;
656656
}
657657
$algo = \strtoupper($this->sql['algorithm']);
658-
if ( ! \in_array($algo, [
658+
if (!\in_array($algo, [
659659
static::ALGO_COPY,
660660
static::ALGO_DEFAULT,
661661
static::ALGO_INPLACE,

src/Definition/CreateSchema.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function orReplace() : static
3232

3333
protected function renderOrReplace() : ?string
3434
{
35-
if ( ! isset($this->sql['or_replace'])) {
35+
if (!isset($this->sql['or_replace'])) {
3636
return null;
3737
}
3838
return ' OR REPLACE';
@@ -49,7 +49,7 @@ public function ifNotExists() : static
4949

5050
protected function renderIfNotExists() : ?string
5151
{
52-
if ( ! isset($this->sql['if_not_exists'])) {
52+
if (!isset($this->sql['if_not_exists'])) {
5353
return null;
5454
}
5555
if (isset($this->sql['or_replace'])) {
@@ -92,7 +92,7 @@ public function charset(string $charset) : static
9292

9393
protected function renderCharset() : ?string
9494
{
95-
if ( ! isset($this->sql['charset'])) {
95+
if (!isset($this->sql['charset'])) {
9696
return null;
9797
}
9898
$charset = $this->database->quote($this->sql['charset']);
@@ -112,7 +112,7 @@ public function collate(string $collation) : static
112112

113113
protected function renderCollate() : ?string
114114
{
115-
if ( ! isset($this->sql['collation'])) {
115+
if (!isset($this->sql['collation'])) {
116116
return null;
117117
}
118118
$collation = $this->database->quote($this->sql['collation']);

0 commit comments

Comments
 (0)