Skip to content

Commit 5c5d74d

Browse files
committed
remove unused imports, fix Symfony 5 compatibility, update docblocks
1 parent feb66c9 commit 5c5d74d

File tree

21 files changed

+288
-459
lines changed

21 files changed

+288
-459
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
vendor/
22
build/
33
composer.lock
4+
.phpunit.result.cache
45

56

67
.project

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ branches:
1212

1313
before_script:
1414
- composer self-update
15-
- composer install --prefer-source --no-interaction --dev
15+
- composer install --no-interaction --dev
1616

17-
script:
17+
script:
1818
vendor/bin/phpunit

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"symfony/config": "^2.0||^3.0||^4.0||^5.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^9.2",
23+
"phpunit/phpunit": "^7.5||^8.5||^9.2",
2424
"mockery/mockery": "*@dev"
2525
},
2626
"suggest": {

src/Phpmig/Adapter/CodeIgniter/Db.php

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,32 @@
1010

1111
class Db implements AdapterInterface
1212
{
13-
protected $ci = null;
14-
15-
protected $connection = null;
16-
17-
protected $tableName = null;
18-
19-
public function __construct($tableName)
13+
/**
14+
* @var \CI_Controller
15+
*/
16+
protected $ci;
17+
18+
/**
19+
* @var \CI_DB_query_builder
20+
*/
21+
protected $connection;
22+
23+
/**
24+
* @var string
25+
*/
26+
protected $tableName;
27+
28+
public function __construct(string $tableName)
2029
{
2130
$this->ci = &get_instance();
2231
$this->ci->load->dbforge();
2332
$this->tableName = $tableName;
2433
$this->connection = $this->ci->db;
2534
}
2635

36+
/**
37+
* {@inheritdoc}
38+
*/
2739
public function fetchAll()
2840
{
2941
$rows = array();
@@ -37,6 +49,9 @@ public function fetchAll()
3749
return $rows;
3850
}
3951

52+
/**
53+
* {@inheritdoc}
54+
*/
4055
public function up(Migration $migration)
4156
{
4257
$this->connection->insert(
@@ -49,6 +64,9 @@ public function up(Migration $migration)
4964
return $this;
5065
}
5166

67+
/**
68+
* {@inheritdoc}
69+
*/
5270
public function down(Migration $migration)
5371
{
5472
$this->connection->where('version', $migration->getVersion());
@@ -57,11 +75,17 @@ public function down(Migration $migration)
5775
return $this;
5876
}
5977

78+
/**
79+
* {@inheritdoc}
80+
*/
6081
public function hasSchema()
6182
{
6283
return $this->connection->table_exists($this->tableName);
6384
}
6485

86+
/**
87+
* {@inheritdoc}
88+
*/
6589
public function createSchema()
6690
{
6791
$fields = array(

src/Phpmig/Adapter/Doctrine/DBAL.php

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,35 @@ class DBAL implements AdapterInterface
3030
/**
3131
* @var \Doctrine\DBAL\Connection
3232
*/
33-
protected $connection = null;
33+
protected $connection;
3434

3535
/**
3636
* @var string
3737
*/
38-
protected $tableName = null;
38+
protected $tableName;
3939

40-
/**
41-
* Constructor
42-
*
43-
* @param Connection $connection
44-
* @param string $tableName
45-
*/
46-
public function __construct(Connection $connection, $tableName)
40+
public function __construct(Connection $connection, string $tableName)
4741
{
4842
$this->connection = $connection;
4943
$this->tableName = $tableName;
5044
}
5145

5246
/**
53-
* Fetch all
54-
*
55-
* @return array
47+
* {@inheritdoc}
5648
*/
5749
public function fetchAll()
5850
{
5951
$tableName = $this->connection->quoteIdentifier($this->tableName);
6052
$sql = "SELECT version FROM $tableName ORDER BY version ASC";
6153
$all = $this->connection->fetchAll($sql);
54+
6255
return array_map(function($v) {return $v['version'];}, $all);
6356
}
6457

6558
/**
66-
* Up
67-
*
68-
* @param Migration $migration
69-
* @return DBAL
59+
* {@inheritdoc}
7060
*/
71-
public function up(Migration $migration)
61+
public function up(Migration $migration)
7262
{
7363
$this->connection->insert($this->tableName, array(
7464
'version' => $migration->getVersion(),
@@ -78,10 +68,7 @@ public function up(Migration $migration)
7868
}
7969

8070
/**
81-
* Down
82-
*
83-
* @param Migration $migration
84-
* @return DBAL
71+
* {@inheritdoc}
8572
*/
8673
public function down(Migration $migration)
8774
{
@@ -93,9 +80,7 @@ public function down(Migration $migration)
9380
}
9481

9582
/**
96-
* Is the schema ready?
97-
*
98-
* @return bool
83+
* {@inheritdoc}
9984
*/
10085
public function hasSchema()
10186
{
@@ -106,13 +91,12 @@ public function hasSchema()
10691
return true;
10792
}
10893
}
94+
10995
return false;
11096
}
11197

11298
/**
113-
* Create Schema
114-
*
115-
* @return DBAL
99+
* {@inheritdoc}
116100
*/
117101
public function createSchema()
118102
{
@@ -123,8 +107,8 @@ public function createSchema()
123107
foreach($queries as $sql) {
124108
$this->connection->query($sql);
125109
}
110+
126111
return $this;
127112
}
128-
129113
}
130114

src/Phpmig/Adapter/File/Flat.php

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,24 @@
1818
*/
1919

2020
/**
21-
* Flat file adapter
21+
* Flat file adapter
2222
*
2323
* @author Dave Marshall <david.marshall@atstsolutions.co.uk
2424
*/
2525
class Flat implements AdapterInterface
2626
{
2727
/**
28-
* @string
28+
* @var string
2929
*/
30-
protected $filename = null;
30+
protected $filename;
3131

32-
/**
33-
* Construct
34-
*
35-
* @param string $filename
36-
*/
37-
public function __construct($filename)
32+
public function __construct(string $filename)
3833
{
3934
$this->filename = $filename;
4035
}
4136

4237
/**
43-
* Get all migrated version numbers
44-
*
45-
* @return array
38+
* {@inheritdoc}
4639
*/
4740
public function fetchAll()
4841
{
@@ -52,16 +45,13 @@ public function fetchAll()
5245
}
5346

5447
/**
55-
* Up
56-
*
57-
* @param Migration $migration
58-
* @return AdapterInterface
48+
* {@inheritdoc}
5949
*/
6050
public function up(Migration $migration)
6151
{
6252
$versions = $this->fetchAll();
6353
if (in_array($migration->getVersion(), $versions)) {
64-
return;
54+
return $this;
6555
}
6656

6757
$versions[] = $migration->getVersion();
@@ -70,16 +60,13 @@ public function up(Migration $migration)
7060
}
7161

7262
/**
73-
* Down
74-
*
75-
* @param Migration $migration
76-
* @return AdapterInterface
63+
* {@inheritdoc}
7764
*/
7865
public function down(Migration $migration)
7966
{
8067
$versions = $this->fetchAll();
8168
if (!in_array($migration->getVersion(), $versions)) {
82-
return;
69+
return $this;
8370
}
8471

8572
unset($versions[array_search($migration->getVersion(), $versions)]);
@@ -88,23 +75,19 @@ public function down(Migration $migration)
8875
}
8976

9077
/**
91-
* Is the schema ready?
92-
*
93-
* @return bool
78+
* {@inheritdoc}
9479
*/
9580
public function hasSchema()
9681
{
9782
return file_exists($this->filename);
9883
}
9984

10085
/**
101-
* Create Schema
102-
*
103-
* @return AdapterInterface
86+
* {@inheritdoc}
10487
*/
10588
public function createSchema()
10689
{
107-
if (!is_writeable(dirname($this->filename))) {
90+
if (!is_writable(dirname($this->filename))) {
10891
throw new \InvalidArgumentException(sprintf('The file "%s" is not writeable', $this->filename));
10992
}
11093

@@ -117,8 +100,10 @@ public function createSchema()
117100

118101
/**
119102
* Write to file
103+
*
104+
* @param array $versions
120105
*/
121-
protected function write($versions)
106+
protected function write(array $versions)
122107
{
123108
if (false === file_put_contents($this->filename, implode("\n", $versions))) {
124109
throw new \RuntimeException(sprintf('The file "%s" could not be written to', $this->filename));

src/Phpmig/Adapter/Illuminate/Database.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ class Database implements AdapterInterface
2525
*/
2626
protected $adapter;
2727

28-
public function __construct($adapter, $tableName, $connectionName = '')
28+
public function __construct($adapter, string $tableName, string $connectionName = '')
2929
{
3030
$this->adapter = $adapter->connection($connectionName);
3131
$this->tableName = $tableName;
3232
}
3333

3434
/**
35-
* Get all migrated version numbers
36-
*
37-
* @return array
35+
* {@inheritdoc}
3836
*/
3937
public function fetchAll()
4038
{
@@ -67,10 +65,7 @@ public function fetchAll()
6765
}
6866

6967
/**
70-
* Up
71-
*
72-
* @param Migration $migration
73-
* @return AdapterInterface
68+
* {@inheritdoc}
7469
*/
7570
public function up(Migration $migration)
7671
{
@@ -84,10 +79,7 @@ public function up(Migration $migration)
8479
}
8580

8681
/**
87-
* Down
88-
*
89-
* @param Migration $migration
90-
* @return AdapterInterface
82+
* {@inheritdoc}
9183
*/
9284
public function down(Migration $migration)
9385
{
@@ -100,25 +92,23 @@ public function down(Migration $migration)
10092
}
10193

10294
/**
103-
* Is the schema ready?
104-
*
105-
* @return bool
95+
* {@inheritdoc}
10696
*/
10797
public function hasSchema()
10898
{
10999
return $this->adapter->getSchemaBuilder()->hasTable($this->tableName);
110100
}
111101

112102
/**
113-
* Create Schema
114-
*
115-
* @return AdapterInterface
103+
* {@inheritdoc}
116104
*/
117105
public function createSchema()
118106
{
119107
/* @var \Illuminate\Database\Schema\Blueprint $table */
120108
$this->adapter->getSchemaBuilder()->create($this->tableName, function ($table) {
121109
$table->string('version');
122110
});
111+
112+
return $this;
123113
}
124114
}

0 commit comments

Comments
 (0)