Skip to content

Commit 406faae

Browse files
committed
Use PHP 7.1 type declarations.
1 parent 44af9c3 commit 406faae

35 files changed

+254
-264
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: php
22
php:
3-
- '7.0'
43
- '7.1'
54
- '7.2'
65
- nightly

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"type": "tool",
1010
"license": "MIT",
1111
"require": {
12-
"php": ">=7.0.0",
12+
"php": ">=7.1.0",
1313
"setbased/exception": "^1.0.0",
14-
"setbased/helper-code-store-mysql": "^1.0.0",
15-
"setbased/php-stratum": "^0.9.0",
16-
"symfony/console": "^3.0.0"
14+
"setbased/helper-code-store-mysql": "^2.0.0",
15+
"setbased/php-stratum": "^0.9.64",
16+
"symfony/console": "^3.0.0 || ^4.0.0"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "^6.0.0",

src/Application/AuditApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct()
2727
/**
2828
* Gets the default commands that should always be available.
2929
*
30-
* @return Command[] An array of default Command instances.
30+
* @return Command[]
3131
*/
3232
protected function getDefaultCommands()
3333
{

src/Audit/AlterAuditTable.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AlterAuditTable
4141
*
4242
* @param array[] $config The content of the configuration file.
4343
*/
44-
public function __construct(&$config)
44+
public function __construct(array &$config)
4545
{
4646
$this->config = &$config;
4747
$this->codeStore = new AlterTableCodeStore();
@@ -57,7 +57,7 @@ public function __construct(&$config)
5757
*
5858
* return string
5959
*/
60-
public function main()
60+
public function main(): string
6161
{
6262
$tables = $this->getTableList();
6363
foreach ($tables as $table)
@@ -74,7 +74,7 @@ public function main()
7474
*
7575
* @param string $tableName The name of the table.
7676
*/
77-
private function compareTable($tableName)
77+
private function compareTable(string $tableName): void
7878
{
7979
$dataTable = $this->getTableMetadata($this->config['database']['data_schema'], $tableName);
8080
$auditTable = $this->getTableMetadata($this->config['database']['audit_schema'], $tableName);
@@ -94,7 +94,7 @@ private function compareTable($tableName)
9494
* @param TableMetadata $dataTable The metadata of the data table.
9595
* @param TableMetadata $auditTable The metadata of the audit table.
9696
*/
97-
private function compareTableColumns($dataTable, $auditTable)
97+
private function compareTableColumns(TableMetadata $dataTable, TableMetadata $auditTable): void
9898
{
9999
$diff = TableColumnsMetadata::differentColumnTypes($dataTable->getColumns(), $auditTable->getColumns());
100100

@@ -136,7 +136,7 @@ private function compareTableColumns($dataTable, $auditTable)
136136
* @param TableMetadata $dataTable The metadata of the data table.
137137
* @param TableMetadata $auditTable The metadata of the audit table.
138138
*/
139-
private function compareTableOptions($dataTable, $auditTable)
139+
private function compareTableOptions(TableMetadata $dataTable, TableMetadata $auditTable): void
140140
{
141141
$options = TableMetadata::compareOptions($dataTable, $auditTable);
142142

@@ -178,7 +178,7 @@ private function compareTableOptions($dataTable, $auditTable)
178178
*
179179
* @return string[]
180180
*/
181-
private function getTableList()
181+
private function getTableList(): array
182182
{
183183
$tables1 = [];
184184
foreach ($this->config['tables'] as $tableName => $config)
@@ -215,7 +215,7 @@ private function getTableList()
215215
*
216216
* @return TableMetadata
217217
*/
218-
private function getTableMetadata($schemaName, $tableName)
218+
private function getTableMetadata(string $schemaName, string $tableName): TableMetadata
219219
{
220220
$table = AuditDataLayer::getTableOptions($schemaName, $tableName);
221221
$columns = AuditDataLayer::getTableColumns($schemaName, $tableName);

src/Audit/Audit.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ class Audit
4949
private $io;
5050

5151
//--------------------------------------------------------------------------------------------------------------------
52+
5253
/**
5354
* Object constructor.
5455
*
5556
* @param array[] $config The content of the configuration file.
5657
* @param StratumStyle $io The Output decorator.
5758
*/
58-
public function __construct(&$config, $io)
59+
public function __construct(array &$config, StratumStyle $io)
5960
{
6061
$this->config = &$config;
6162
$this->io = $io;
@@ -69,7 +70,7 @@ public function __construct(&$config, $io)
6970
/**
7071
* Getting list of all tables from information_schema of database from config file.
7172
*/
72-
public function listOfTables()
73+
public function listOfTables(): void
7374
{
7475
$this->dataSchemaTables = AuditDataLayer::getTablesNames($this->config['database']['data_schema']);
7576
$this->auditSchemaTables = AuditDataLayer::getTablesNames($this->config['database']['audit_schema']);
@@ -79,7 +80,7 @@ public function listOfTables()
7980
/**
8081
* The main method: executes the auditing actions for tables.
8182
*/
82-
public function main()
83+
public function main(): void
8384
{
8485
$this->listOfTables();
8586

@@ -94,7 +95,7 @@ public function main()
9495
/**
9596
* Removes tables listed in the config file that are not longer in the data schema from the config file.
9697
*/
97-
public function obsoleteTables()
98+
public function obsoleteTables(): void
9899
{
99100
foreach ($this->config['tables'] as $tableName => $dummy)
100101
{
@@ -110,7 +111,7 @@ public function obsoleteTables()
110111
/**
111112
* Compares the tables listed in the config file and the tables found in the data schema.
112113
*/
113-
public function unknownTables()
114+
public function unknownTables(): void
114115
{
115116
foreach ($this->dataSchemaTables as $table)
116117
{
@@ -145,7 +146,7 @@ public function unknownTables()
145146
/**
146147
* Processed known tables.
147148
*/
148-
private function knownTables()
149+
private function knownTables(): void
149150
{
150151
foreach ($this->dataSchemaTables as $table)
151152
{

src/Audit/Diff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Diff
6161
* @param InputInterface $input
6262
* @param OutputInterface $output
6363
*/
64-
public function __construct(&$config, $io, $input, $output)
64+
public function __construct(array &$config, StratumStyle $io, InputInterface $input, OutputInterface $output)
6565
{
6666
$this->io = $io;
6767
$this->config = &$config;
@@ -77,7 +77,7 @@ public function __construct(&$config, $io, $input, $output)
7777
/**
7878
* The main method: executes the auditing actions for tables.
7979
*/
80-
public function main()
80+
public function main(): void
8181
{
8282
// Style for column names with miss matched column types.
8383
$style = new OutputFormatterStyle(null, 'red');
@@ -110,7 +110,7 @@ public function main()
110110
*
111111
* @param string $tableName The table name.
112112
*/
113-
private function currentAuditTable($tableName)
113+
private function currentAuditTable(string $tableName): void
114114
{
115115
$columns = AuditDataLayer::getTableColumns($this->config['database']['data_schema'], $tableName);
116116
$dataTableColumns = new TableColumnsMetadata($columns);
@@ -147,7 +147,7 @@ private function currentAuditTable($tableName)
147147
*
148148
* @param string[] $tableNames The names of the current tables.
149149
*/
150-
private function currentAuditTables($tableNames)
150+
private function currentAuditTables(array $tableNames): void
151151
{
152152
foreach ($tableNames as $tableName)
153153
{
@@ -161,7 +161,7 @@ private function currentAuditTables($tableNames)
161161
*
162162
* @return array[]
163163
*/
164-
private function getTableLists()
164+
private function getTableLists(): array
165165
{
166166
$tables1 = [];
167167
foreach ($this->config['tables'] as $tableName => $config)
@@ -197,7 +197,7 @@ private function getTableLists()
197197
*
198198
* @param string[] $tableNames The names of the obsolete tables.
199199
*/
200-
private function missingAuditTables($tableNames)
200+
private function missingAuditTables(array $tableNames): void
201201
{
202202
if (empty($tableNames)) return;
203203

@@ -211,7 +211,7 @@ private function missingAuditTables($tableNames)
211211
*
212212
* @param string[] $tableNames The names of the obsolete tables.
213213
*/
214-
private function obsoleteAuditTables($tableNames)
214+
private function obsoleteAuditTables(array $tableNames): void
215215
{
216216
if (empty($tableNames) || !$this->input->getOption('full')) return;
217217

0 commit comments

Comments
 (0)