Skip to content

Commit f6895e2

Browse files
committed
Fix typos, align with coding standards, and improve comments.
1 parent 9c02dce commit f6895e2

File tree

10 files changed

+56
-57
lines changed

10 files changed

+56
-57
lines changed

src/Audit/AlterAuditTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(TypedConfig $config)
5555

5656
//--------------------------------------------------------------------------------------------------------------------
5757
/**
58-
* The main method: executes the create alter table statement actions for tables.
58+
* The main method: executes the creates alter table statement actions for tables.
5959
*
6060
* return string
6161
*/

src/Audit/Audit.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,14 @@ public function listOfTables(): void
8585
public function main(): void
8686
{
8787
$this->listOfTables();
88-
8988
$this->unknownTables();
90-
9189
$this->obsoleteTables();
92-
9390
$this->knownTables();
9491
}
9592

9693
//--------------------------------------------------------------------------------------------------------------------
9794
/**
98-
* Removes tables listed in the config file that are not longer in the data schema from the config file.
95+
* Removes tables listed in the config file that are no longer in the data schema from the config file.
9996
*/
10097
public function obsoleteTables(): void
10198
{

src/Audit/Diff.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,13 @@ public function main(): void
100100
$lists = $this->getTableLists();
101101

102102
$this->currentAuditTables($lists['current']);
103-
104103
$this->missingAuditTables($lists['missing']);
105-
106104
$this->obsoleteAuditTables($lists['obsolete']);
107105
}
108106

109107
//--------------------------------------------------------------------------------------------------------------------
110108
/**
111-
* Prints the difference between a data and and its audit table.
109+
* Prints the difference between a data and its related audit table.
112110
*
113111
* @param string $tableName The table name.
114112
*/

src/AuditTable.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AuditTable
4040
*
4141
* @var string
4242
*/
43-
protected $dataSchemaName;
43+
private string $dataSchemaName;
4444

4545
/**
4646
* The metadata of the columns of the data table retrieved from information_schema.
@@ -57,7 +57,8 @@ class AuditTable
5757
private AuditStyle $io;
5858

5959
/**
60-
* The skip variable for triggers.
60+
* The name of the MySQL user defined variable for skipping triggers. When the value of this variable is not null the
61+
* audit trigger will (effectively) be sipped.
6162
*
6263
* @var string|null
6364
*/
@@ -79,16 +80,17 @@ class AuditTable
7980
* @param string $auditSchemaName The name of the schema with audit tables.
8081
* @param string $tableName The name of the data and audit table.
8182
* @param TableColumnsMetadata $additionalAuditColumns The metadata of the additional audit columns.
82-
* @param string|null $alias An unique alias for this table.
83-
* @param string|null $skipVariable The skip variable
83+
* @param string|null $alias A unique alias for this table.
84+
* @param string|null $skipVariable The name of the MySQL user defined variable for skipping
85+
* triggers.
8486
*/
85-
public function __construct(AuditStyle $io,
86-
string $dataSchemaName,
87-
string $auditSchemaName,
88-
string $tableName,
87+
public function __construct(AuditStyle $io,
88+
string $dataSchemaName,
89+
string $auditSchemaName,
90+
string $tableName,
8991
TableColumnsMetadata $additionalAuditColumns,
90-
?string $alias,
91-
?string $skipVariable)
92+
?string $alias,
93+
?string $skipVariable)
9294
{
9395
$this->io = $io;
9496
$this->dataSchemaName = $dataSchemaName;
@@ -158,7 +160,7 @@ public function createAuditTable(): void
158160
/**
159161
* Creates audit triggers on this table.
160162
*
161-
* @param string[] $additionalSql Additional SQL statements to be include in triggers.
163+
* @param string[] $additionalSql Additional SQL statements to be included in triggers.
162164
*/
163165
public function createTriggers(array $additionalSql): void
164166
{
@@ -192,7 +194,7 @@ public function getTableName(): string
192194
/**
193195
* Main function for work with table.
194196
*
195-
* @param string[] $additionalSql Additional SQL statements to be include in triggers.
197+
* @param string[] $additionalSql Additional SQL statements to be included in triggers.
196198
*/
197199
public function main(array $additionalSql): void
198200
{
@@ -221,7 +223,7 @@ private function addNewColumns(TableColumnsMetadata $columns): void
221223

222224
//--------------------------------------------------------------------------------------------------------------------
223225
/**
224-
* Returns metadata of new table columns that can be used in a 'alter table .. add column' statement.
226+
* Returns metadata of new table columns that can be used in a 'alter table ... add column' statement.
225227
*
226228
* @param TableColumnsMetadata $newColumns The metadata new table columns.
227229
*
@@ -243,9 +245,9 @@ private function alterNewColumns(TableColumnsMetadata $newColumns): TableColumns
243245
/**
244246
* Creates a triggers for this table.
245247
*
246-
* @param string $action The trigger action (INSERT, DELETE, or UPDATE).
247-
* @param string|null $skipVariable
248-
* @param string[] $additionSql The additional SQL statements to be included in triggers.
248+
* @param string $action The trigger action (INSERT, DELETE, or UPDATE).
249+
* @param string|null $skipVariable The name of the MySQL user defined variable for skipping triggers.
250+
* @param string[] $additionSql The additional SQL statements to be included in triggers.
249251
*/
250252
private function createTableTrigger(string $action, ?string $skipVariable, array $additionSql): void
251253
{
@@ -306,7 +308,7 @@ private function getTableColumnInfo(): array
306308
/**
307309
* Returns the trigger name for a trigger action.
308310
*
309-
* @param string $action Trigger on action (Insert, Update, Delete)
311+
* @param string $action Trigger on action (Insert, Update, Delete).
310312
*
311313
* @return string
312314
*/

src/Metadata/ColumnMetadata.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ abstract class ColumnMetadata
2121
'collation_name'];
2222

2323
/**
24-
* The the properties of this table column.
24+
* The properties of this table column.
2525
*
2626
* @var array
2727
*/
2828
private array $properties = [];
2929

3030
//--------------------------------------------------------------------------------------------------------------------
31-
3231
/**
3332
* Object constructor.
3433
*

src/Metadata/TableColumnsMetadata.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public static function differentColumnTypes(TableColumnsMetadata $columns1,
7171
array $ignore = []): TableColumnsMetadata
7272
{
7373
$diff = new TableColumnsMetadata();
74-
foreach ($columns1->columns as $column_name => $column1)
74+
foreach ($columns1->columns as $columnName => $column1)
7575
{
76-
if (isset($columns2->columns[$column_name]))
76+
if (isset($columns2->columns[$columnName]))
7777
{
78-
if (!ColumnMetadata::compare($column1, $columns2->columns[$column_name], $ignore))
78+
if (!ColumnMetadata::compare($column1, $columns2->columns[$columnName], $ignore))
7979
{
8080
$diff->appendTableColumn($column1);
8181
}
@@ -99,9 +99,9 @@ public static function notInOtherSet(TableColumnsMetadata $columns1,
9999
TableColumnsMetadata $columns2): TableColumnsMetadata
100100
{
101101
$diff = new TableColumnsMetadata();
102-
foreach ($columns1->columns as $column_name => $column1)
102+
foreach ($columns1->columns as $columnName => $column1)
103103
{
104-
if (!isset($columns2->columns[$column_name]))
104+
if (!isset($columns2->columns[$columnName]))
105105
{
106106
$diff->appendTableColumn($column1);
107107
}

src/Metadata/TableMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TableMetadata
2424
private TableColumnsMetadata $columns;
2525

2626
/**
27-
* The the properties of this table column.
27+
* The properties of this table column.
2828
*
2929
* @var array
3030
*/

src/MySql/AuditDataLayer.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public function addNewColumns(string $auditSchemaName, string $tableName, TableC
7575
* @param TableColumnsMetadata $columns The metadata of the columns of the audit table (i.e. the audit
7676
* columns and columns of the data table).
7777
*/
78-
public function createAuditTable(string $dataSchemaName,
79-
string $auditSchemaName,
80-
string $tableName,
78+
public function createAuditTable(string $dataSchemaName,
79+
string $auditSchemaName,
80+
string $tableName,
8181
TableColumnsMetadata $columns): void
8282
{
8383
$helper = new CreateAuditTable($dataSchemaName, $auditSchemaName, $tableName, $columns);
@@ -97,18 +97,19 @@ public function createAuditTable(string $dataSchemaName,
9797
* @param string $triggerName The name of the trigger.
9898
* @param TableColumnsMetadata $additionalAuditColumns The metadata of the additional audit columns.
9999
* @param TableColumnsMetadata $tableColumns The metadata of the data table columns.
100-
* @param string|null $skipVariable The skip variable.
100+
* @param string|null $skipVariable The name of the MySQL user defined variable for skipping
101+
* triggers.
101102
* @param string[] $additionSql Additional SQL statements.
102103
*/
103-
public function createAuditTrigger(string $dataSchemaName,
104-
string $auditSchemaName,
105-
string $tableName,
106-
string $triggerName,
107-
string $triggerAction,
104+
public function createAuditTrigger(string $dataSchemaName,
105+
string $auditSchemaName,
106+
string $tableName,
107+
string $triggerName,
108+
string $triggerAction,
108109
TableColumnsMetadata $additionalAuditColumns,
109110
TableColumnsMetadata $tableColumns,
110-
?string $skipVariable,
111-
array $additionSql): void
111+
?string $skipVariable,
112+
array $additionSql): void
112113
{
113114
$helper = new CreateAuditTrigger($dataSchemaName,
114115
$auditSchemaName,
@@ -422,7 +423,7 @@ public function lockTable(string $schemaName, string $tableName): void
422423
* @return TableColumnsMetadata
423424
*/
424425
public function resolveCanonicalAdditionalAuditColumns(string $auditSchema,
425-
array $additionalAuditColumns): TableColumnsMetadata
426+
array $additionalAuditColumns): TableColumnsMetadata
426427
{
427428
if (empty($additionalAuditColumns))
428429
{

src/MySql/Sql/CreateAuditTrigger.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class CreateAuditTrigger
5151
private string $dataSchemaName;
5252

5353
/**
54-
* The skip variable.
54+
* The name of the MySQL user defined variable for skipping triggers. When the value of this variable is not null the
55+
* audit trigger will (effectively) be sipped.
5556
*
5657
* @var string|null
5758
*/
@@ -96,18 +97,19 @@ class CreateAuditTrigger
9697
* @param string $triggerName The name of the trigger.
9798
* @param TableColumnsMetadata $additionalAuditColumns The metadata of the additional audit columns.
9899
* @param TableColumnsMetadata $tableColumns The metadata of the data table columns.
99-
* @param string|null $skipVariable The skip variable.
100+
* @param string|null $skipVariable The name of the MySQL user defined variable for skipping
101+
* triggers.
100102
* @param string[]|null $additionalSql Additional SQL statements.
101103
*/
102-
public function __construct(string $dataSchemaName,
103-
string $auditSchemaName,
104-
string $tableName,
105-
string $triggerName,
106-
string $triggerAction,
104+
public function __construct(string $dataSchemaName,
105+
string $auditSchemaName,
106+
string $tableName,
107+
string $triggerName,
108+
string $triggerAction,
107109
TableColumnsMetadata $additionalAuditColumns,
108110
TableColumnsMetadata $tableColumns,
109-
?string $skipVariable,
110-
?array $additionalSql)
111+
?string $skipVariable,
112+
?array $additionalSql)
111113
{
112114
$this->dataSchemaName = $dataSchemaName;
113115
$this->auditSchemaName = $auditSchemaName;

src/Style/AuditStyle.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(InputInterface $input, OutputInterface $output)
4444
*
4545
* This method takes arguments like sprintf.
4646
*/
47-
public function logInfo()
47+
public function logInfo(): void
4848
{
4949
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_NORMAL)
5050
{
@@ -61,7 +61,7 @@ public function logInfo()
6161
*
6262
* This method takes arguments like sprintf.
6363
*/
64-
public function logVerbose()
64+
public function logVerbose(): void
6565
{
6666
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERBOSE)
6767
{
@@ -78,7 +78,7 @@ public function logVerbose()
7878
*
7979
* This method takes arguments like sprintf.
8080
*/
81-
public function logVeryVerbose()
81+
public function logVeryVerbose(): void
8282
{
8383
if ($this->getVerbosity()>=OutputInterface::VERBOSITY_VERY_VERBOSE)
8484
{

0 commit comments

Comments
 (0)