Skip to content

Commit 107df92

Browse files
committed
Fix coding style violations in 4.2
1 parent d8c35c1 commit 107df92

32 files changed

+2120
-2206
lines changed

app/Config/Publisher.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
*/
1313
class Publisher extends BasePublisher
1414
{
15-
/**
16-
* A list of allowed destinations with a (pseudo-)regex
17-
* of allowed files for each destination.
18-
* Attempts to publish to directories not in this list will
19-
* result in a PublisherException. Files that do no fit the
20-
* pattern will cause copy/merge to fail.
21-
*
22-
* @var array<string,string>
23-
*/
24-
public $restrictions = [
25-
ROOTPATH => '*',
26-
FCPATH => '#\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
27-
];
15+
/**
16+
* A list of allowed destinations with a (pseudo-)regex
17+
* of allowed files for each destination.
18+
* Attempts to publish to directories not in this list will
19+
* result in a PublisherException. Files that do no fit the
20+
* pattern will cause copy/merge to fail.
21+
*
22+
* @var array<string,string>
23+
*/
24+
public $restrictions = [
25+
ROOTPATH => '*',
26+
FCPATH => '#\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
27+
];
2828
}

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ protected function bootstrapEnvironment()
496496
*/
497497
protected function startBenchmark()
498498
{
499-
if($this->startTime === null) {
499+
if ($this->startTime === null) {
500500
$this->startTime = microtime(true);
501501
}
502502

Lines changed: 72 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

33
/**
4-
* This file is part of the CodeIgniter 4 framework.
4+
* This file is part of CodeIgniter 4 framework.
55
*
66
* (c) CodeIgniter Foundation <admin@codeigniter.com>
77
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
1010
*/
1111

1212
namespace CodeIgniter\Commands\Utilities;
@@ -22,92 +22,83 @@
2222
*/
2323
class Publish extends BaseCommand
2424
{
25-
/**
26-
* The group the command is lumped under
27-
* when listing commands.
28-
*
29-
* @var string
30-
*/
31-
protected $group = 'CodeIgniter';
25+
/**
26+
* The group the command is lumped under
27+
* when listing commands.
28+
*
29+
* @var string
30+
*/
31+
protected $group = 'CodeIgniter';
3232

33-
/**
34-
* The Command's name
35-
*
36-
* @var string
37-
*/
38-
protected $name = 'publish';
33+
/**
34+
* The Command's name
35+
*
36+
* @var string
37+
*/
38+
protected $name = 'publish';
3939

40-
/**
41-
* The Command's short description
42-
*
43-
* @var string
44-
*/
45-
protected $description = 'Discovers and executes all predefined Publisher classes.';
40+
/**
41+
* The Command's short description
42+
*
43+
* @var string
44+
*/
45+
protected $description = 'Discovers and executes all predefined Publisher classes.';
4646

47-
/**
48-
* The Command's usage
49-
*
50-
* @var string
51-
*/
52-
protected $usage = 'publish [<directory>]';
47+
/**
48+
* The Command's usage
49+
*
50+
* @var string
51+
*/
52+
protected $usage = 'publish [<directory>]';
5353

54-
/**
55-
* The Command's arguments
56-
*
57-
* @var array<string, string>
58-
*/
59-
protected $arguments = [
60-
'directory' => '[Optional] The directory to scan within each namespace. Default: "Publishers".',
61-
];
54+
/**
55+
* The Command's arguments
56+
*
57+
* @var array<string, string>
58+
*/
59+
protected $arguments = [
60+
'directory' => '[Optional] The directory to scan within each namespace. Default: "Publishers".',
61+
];
6262

63-
/**
64-
* the Command's Options
65-
*
66-
* @var array
67-
*/
68-
protected $options = [];
63+
/**
64+
* the Command's Options
65+
*
66+
* @var array
67+
*/
68+
protected $options = [];
6969

70-
//--------------------------------------------------------------------
70+
/**
71+
* Displays the help for the spark cli script itself.
72+
*/
73+
public function run(array $params)
74+
{
75+
$directory = array_shift($params) ?? 'Publishers';
7176

72-
/**
73-
* Displays the help for the spark cli script itself.
74-
*
75-
* @param array $params
76-
*/
77-
public function run(array $params)
78-
{
79-
$directory = array_shift($params) ?? 'Publishers';
77+
if ([] === $publishers = Publisher::discover($directory)) {
78+
CLI::write(lang('Publisher.publishMissing', [$directory]));
8079

81-
if ([] === $publishers = Publisher::discover($directory))
82-
{
83-
CLI::write(lang('Publisher.publishMissing', [$directory]));
84-
return;
85-
}
80+
return;
81+
}
8682

87-
foreach ($publishers as $publisher)
88-
{
89-
if ($publisher->publish())
90-
{
91-
CLI::write(lang('Publisher.publishSuccess', [
92-
get_class($publisher),
93-
count($publisher->getPublished()),
94-
$publisher->getDestination(),
95-
]), 'green');
96-
}
97-
else
98-
{
99-
CLI::error(lang('Publisher.publishFailure', [
100-
get_class($publisher),
101-
$publisher->getDestination(),
102-
]), 'light_gray', 'red');
83+
foreach ($publishers as $publisher) {
84+
if ($publisher->publish()) {
85+
CLI::write(lang('Publisher.publishSuccess', [
86+
get_class($publisher),
87+
count($publisher->getPublished()),
88+
$publisher->getDestination(),
89+
]), 'green');
90+
} else {
91+
CLI::error(lang('Publisher.publishFailure', [
92+
get_class($publisher),
93+
$publisher->getDestination(),
94+
]), 'light_gray', 'red');
10395

104-
foreach ($publisher->getErrors() as $file => $exception)
105-
{
106-
CLI::write($file);
107-
CLI::error($exception->getMessage());
108-
CLI::newLine();
109-
}
110-
}
111-
}
112-
}
96+
foreach ($publisher->getErrors() as $file => $exception) {
97+
CLI::write($file);
98+
CLI::error($exception->getMessage());
99+
CLI::newLine();
100+
}
101+
}
102+
}
103+
}
113104
}

system/Common.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -719,19 +719,17 @@ function lang(string $line, array $args = [], ?string $locale = null)
719719
{
720720
$language = Services::language();
721721

722-
//Get active locale
722+
// Get active locale
723723
$activeLocale = $language->getLocale();
724724

725-
if ($locale && $locale != $activeLocale)
726-
{
725+
if ($locale && $locale !== $activeLocale) {
727726
$language->setLocale($locale);
728727
}
729728

730729
$line = $language->getLine($line, $args);
731730

732-
if ($locale && $locale != $activeLocale)
733-
{
734-
//Reset to active locale
731+
if ($locale && $locale !== $activeLocale) {
732+
// Reset to active locale
735733
$language->setLocale($activeLocale);
736734
}
737735

system/Config/Publisher.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

33
/**
4-
* This file is part of the CodeIgniter 4 framework.
4+
* This file is part of CodeIgniter 4 framework.
55
*
66
* (c) CodeIgniter Foundation <admin@codeigniter.com>
77
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
1010
*/
1111

1212
namespace CodeIgniter\Config;
@@ -19,24 +19,24 @@
1919
*/
2020
class Publisher extends BaseConfig
2121
{
22-
/**
23-
* A list of allowed destinations with a (pseudo-)regex
24-
* of allowed files for each destination.
25-
* Attempts to publish to directories not in this list will
26-
* result in a PublisherException. Files that do no fit the
27-
* pattern will cause copy/merge to fail.
28-
*
29-
* @var array<string,string>
30-
*/
31-
public $restrictions = [
32-
ROOTPATH => '*',
33-
FCPATH => '#\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
34-
];
22+
/**
23+
* A list of allowed destinations with a (pseudo-)regex
24+
* of allowed files for each destination.
25+
* Attempts to publish to directories not in this list will
26+
* result in a PublisherException. Files that do no fit the
27+
* pattern will cause copy/merge to fail.
28+
*
29+
* @var array<string,string>
30+
*/
31+
public $restrictions = [
32+
ROOTPATH => '*',
33+
FCPATH => '#\.(?css|js|map|htm?|xml|json|webmanifest|tff|eot|woff?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
34+
];
3535

36-
/**
37-
* Disables Registrars to prevent modules from altering the restrictions.
38-
*/
39-
final protected function registerProperties()
40-
{
41-
}
36+
/**
37+
* Disables Registrars to prevent modules from altering the restrictions.
38+
*/
39+
final protected function registerProperties()
40+
{
41+
}
4242
}

system/Database/Forge.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public function addForeignKey($fieldName = '', string $tableName = '', $tableFie
398398
}
399399

400400
if ($errorNames !== []) {
401-
$errorNames[0] = implode(', ',$errorNames);
401+
$errorNames[0] = implode(', ', $errorNames);
402402

403403
throw new DatabaseException(lang('Database.fieldNotExists', $errorNames));
404404
}
@@ -1025,24 +1025,22 @@ protected function _processForeignKeys(string $table): string
10251025
'SET DEFAULT',
10261026
];
10271027

1028-
if ($this->foreignKeys !== []) {
1029-
foreach ($this->foreignKeys as $fkey) {
1030-
$nameIndex = $table . '_' . implode('_', $fkey['field']) . '_foreign';
1031-
$nameIndexFilled = $this->db->escapeIdentifiers($nameIndex);
1032-
$foreignKeyFilled = implode(', ', $this->db->escapeIdentifiers($fkey['field']));
1033-
$referenceTableFilled = $this->db->escapeIdentifiers($this->db->DBPrefix . $fkey['referenceTable']);
1034-
$referenceFieldFilled = implode(', ', $this->db->escapeIdentifiers($fkey['referenceField']));
1028+
foreach ($this->foreignKeys as $fkey) {
1029+
$nameIndex = $table . '_' . implode('_', $fkey['field']) . '_foreign';
1030+
$nameIndexFilled = $this->db->escapeIdentifiers($nameIndex);
1031+
$foreignKeyFilled = implode(', ', $this->db->escapeIdentifiers($fkey['field']));
1032+
$referenceTableFilled = $this->db->escapeIdentifiers($this->db->DBPrefix . $fkey['referenceTable']);
1033+
$referenceFieldFilled = implode(', ', $this->db->escapeIdentifiers($fkey['referenceField']));
10351034

1036-
$formatSql = ",\n\tCONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)";
1037-
$sql .= sprintf($formatSql, $nameIndexFilled, $foreignKeyFilled, $referenceTableFilled, $referenceFieldFilled);
1035+
$formatSql = ",\n\tCONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)";
1036+
$sql .= sprintf($formatSql, $nameIndexFilled, $foreignKeyFilled, $referenceTableFilled, $referenceFieldFilled);
10381037

1039-
if ($fkey['onDelete'] !== false && in_array($fkey['onDelete'], $allowActions, true)) {
1040-
$sql .= ' ON DELETE ' . $fkey['onDelete'];
1041-
}
1038+
if ($fkey['onDelete'] !== false && in_array($fkey['onDelete'], $allowActions, true)) {
1039+
$sql .= ' ON DELETE ' . $fkey['onDelete'];
1040+
}
10421041

1043-
if ($fkey['onUpdate'] !== false && in_array($fkey['onUpdate'], $allowActions, true)) {
1044-
$sql .= ' ON UPDATE ' . $fkey['onUpdate'];
1045-
}
1042+
if ($fkey['onUpdate'] !== false && in_array($fkey['onUpdate'], $allowActions, true)) {
1043+
$sql .= ' ON UPDATE ' . $fkey['onUpdate'];
10461044
}
10471045
}
10481046

system/Database/MySQLi/Connection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class Connection extends BaseConnection
6969
*/
7070
public $resultMode = MYSQLI_STORE_RESULT;
7171

72-
//--------------------------------------------------------------------
73-
7472
/**
7573
* Connect to the database.
7674
*

system/Database/SQLSRV/Forge.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -282,24 +282,22 @@ protected function _processForeignKeys(string $table): string
282282

283283
$allowActions = ['CASCADE', 'SET NULL', 'NO ACTION', 'RESTRICT', 'SET DEFAULT'];
284284

285-
if ($this->foreignKeys !== []) {
286-
foreach ($this->foreignKeys as $fkey) {
287-
$nameIndex = $table . '_' . implode('_', $fkey['field']) . '_foreign';
288-
$nameIndexFilled = $this->db->escapeIdentifiers($nameIndex);
289-
$foreignKeyFilled = implode(', ', $this->db->escapeIdentifiers($fkey['field']));
290-
$referenceTableFilled = $this->db->escapeIdentifiers($this->db->DBPrefix . $fkey['referenceTable']);
291-
$referenceFieldFilled = implode(', ', $this->db->escapeIdentifiers($fkey['referenceField']));
292-
293-
$formatSql = ",\n\tCONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)";
294-
$sql .= sprintf($formatSql, $nameIndexFilled, $foreignKeyFilled, $referenceTableFilled, $referenceFieldFilled);
295-
296-
if ($fkey['onDelete'] !== false && in_array($fkey['onDelete'], $allowActions, true)) {
297-
$sql .= ' ON DELETE ' . $fkey['onDelete'];
298-
}
285+
foreach ($this->foreignKeys as $fkey) {
286+
$nameIndex = $table . '_' . implode('_', $fkey['field']) . '_foreign';
287+
$nameIndexFilled = $this->db->escapeIdentifiers($nameIndex);
288+
$foreignKeyFilled = implode(', ', $this->db->escapeIdentifiers($fkey['field']));
289+
$referenceTableFilled = $this->db->escapeIdentifiers($this->db->DBPrefix . $fkey['referenceTable']);
290+
$referenceFieldFilled = implode(', ', $this->db->escapeIdentifiers($fkey['referenceField']));
291+
292+
$formatSql = ",\n\tCONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)";
293+
$sql .= sprintf($formatSql, $nameIndexFilled, $foreignKeyFilled, $referenceTableFilled, $referenceFieldFilled);
294+
295+
if ($fkey['onDelete'] !== false && in_array($fkey['onDelete'], $allowActions, true)) {
296+
$sql .= ' ON DELETE ' . $fkey['onDelete'];
297+
}
299298

300-
if ($fkey['onUpdate'] !== false && in_array($fkey['onUpdate'], $allowActions, true)) {
301-
$sql .= ' ON UPDATE ' . $fkey['onUpdate'];
302-
}
299+
if ($fkey['onUpdate'] !== false && in_array($fkey['onUpdate'], $allowActions, true)) {
300+
$sql .= ' ON UPDATE ' . $fkey['onUpdate'];
303301
}
304302
}
305303

0 commit comments

Comments
 (0)