Skip to content

Commit 055e297

Browse files
plozmundbu
authored andcommitted
Allow PHP 8 and fix some deprecations
1 parent c7d4ef5 commit 055e297

12 files changed

+37
-29
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.1
64
- 7.2
75
- 7.3
86

@@ -13,17 +11,19 @@ sudo: false
1311

1412
matrix:
1513
include:
16-
- php: 5.6
17-
env: PACKAGE_VERSION=low
1814
- php: 7.4
1915
env:
2016
- MINIMUM_STABILITY=dev
2117
- PACKAGE_VERSION=high
18+
- php: nightly
19+
env:
20+
- MINIMUM_STABILITY=dev
21+
- PACKAGE_VERSION=high
2222

2323
before_script:
2424
- composer selfupdate
2525
- if [[ "$MINIMUM_STABILITY" ]]; then composer config minimum-stability $MINIMUM_STABILITY ; fi
2626
- if [[ "$PACKAGE_VERSION" == "high" ]]; then composer update --prefer-dist; fi
2727
- if [[ "$PACKAGE_VERSION" == "low" ]]; then composer update --prefer-lowest --prefer-dist; fi
2828

29-
script: vendor/bin/simple-phpunit
29+
script: vendor/bin/phpunit

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
}
1010
],
1111
"require": {
12+
"php": "^7.2|^8.0",
1213
"phpcr/phpcr": "^2.1",
13-
"symfony/finder": "^2.8 || ^3.4 || ^4.0 || ^5.0",
14-
"symfony/console": "^2.8 || ^3.4 || ^4.0 || ^5.0"
14+
"symfony/finder": "^4.4 || ^5.0",
15+
"symfony/console": "^4.4 || ^5.0"
1516
},
1617
"require-dev": {
17-
"symfony/phpunit-bridge": "^5.0.4",
1818
"jackalope/jackalope-fs": "0.0.*",
19-
"handcraftedinthealps/zendsearch": "^2.0"
19+
"handcraftedinthealps/zendsearch": "^2.0",
20+
"phpunit/phpunit": "^8.5 || ^9.4"
2021
},
2122
"autoload": {
2223
"psr-4": {
@@ -25,7 +26,7 @@
2526
},
2627
"autoload-dev": {
2728
"psr-4": {
28-
"PHPCR\\Migrations\\": "tests"
29+
"PHPCR\\Migrations\\Tests\\": "tests"
2930
}
3031
},
3132
"extra": {

lib/Migrator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function initialize()
5757
* If $to is 0 then all migrations will be reverted.
5858
* If $to is null then all migrations will be executed.
5959
*
60-
* @param string $to Version to run until
60+
* @param string|null $to Version to run until
6161
* @param OutputInterface $output
6262
*
6363
* @return VersionInterface[] Executed migrations
6464
*/
65-
public function migrate($to = null, OutputInterface $output)
65+
public function migrate($to, OutputInterface $output)
6666
{
6767
if (false === $to) {
6868
return array();
@@ -79,7 +79,6 @@ public function migrate($to = null, OutputInterface $output)
7979
return array();
8080
}
8181

82-
$start = microtime(true);
8382
$position = 0;
8483
$output->writeln(sprintf('<comment>%s</comment> %d version(s):', ($direction == 'up' ? 'Upgrading' : 'Reverting'), count($versionsToExecute)));
8584
foreach ($versionsToExecute as $timestamp => $version) {

lib/MigratorUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function getClassNameFromFile($file)
4747
for (;$i < count($tokens);$i++) {
4848
if ($tokens[$i][0] === T_NAMESPACE) {
4949
for ($j = $i + 1;$j < count($tokens); $j++) {
50-
if ($tokens[$j][0] === T_STRING) {
50+
if (\defined('T_NAME_QUALIFIED') && $tokens[$j][0] === T_NAME_QUALIFIED || $tokens[$j][0] === T_STRING) {
5151
$namespace .= '\\' . $tokens[$j][1];
5252
} elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
5353
break;

lib/VersionFinder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace PHPCR\Migrations;
1313

14+
use PHPCR\Migrations\Exception\MigratorException;
1415
use Symfony\Component\Finder\Finder;
1516

1617
class VersionFinder

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</testsuites>
1919

2020
<filter>
21+
2122
<whitelist addUncoveredFilesFromWhitelist="true">
2223
<directory>.</directory>
2324
<exclude>

tests/BaseTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations;
12+
namespace PHPCR\Migrations\Tests;
1313

1414
use Jackalope\RepositoryFactoryFilesystem;
1515
use PHPCR\SimpleCredentials;

tests/Functional/MigrationTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Functional;
12+
namespace PHPCR\Migrations\Tests\Functional;
1313

14-
use PHPCR\Migrations\BaseTestCase;
1514
use PHPCR\Migrations\Exception\MigratorException;
1615
use PHPCR\Migrations\Migrator;
16+
use PHPCR\Migrations\Tests\BaseTestCase;
1717
use PHPCR\Migrations\VersionFinder;
1818
use PHPCR\Migrations\VersionStorage;
1919
use Symfony\Component\Console\Output\BufferedOutput;
@@ -27,10 +27,11 @@ class MigrationTest extends BaseTestCase
2727

2828
private $output;
2929
private $filesystem;
30+
private $migrationDistDir;
3031
private $migrationDir;
3132
private $storage;
3233

33-
public function setUp()
34+
public function setUp(): void
3435
{
3536
$this->initPhpcr();
3637
$this->migrationDir = __DIR__ . '/../migrations';
@@ -63,9 +64,9 @@ public function testMigration()
6364
$nodes = $this->session->getNode('/phpcrmig:versions')->getNodes();
6465
$names = array_keys((array) $nodes);
6566

66-
$this->assertContains('201501011200', $names);
67-
$this->assertContains('201501011212', $names);
68-
$this->assertContains('201501011215', $names);
67+
$this->assertContains(201501011200, $names);
68+
$this->assertContains(201501011212, $names);
69+
$this->assertContains(201501011215, $names);
6970
}
7071

7172
/**
@@ -201,6 +202,7 @@ public function testMigratePrevious()
201202
$this->addVersion(self::VERSION2);
202203
$this->addVersion(self::VERSION3);
203204
$migratedVersions = $this->getMigrator()->migrate(null, $this->output);
205+
$this->assertCount(3, $migratedVersions);
204206
$this->assertEquals(self::VERSION3, $this->storage->getCurrentVersion());
205207

206208
$migratedVersions = $this->getMigrator()->migrate('down', $this->output);
@@ -256,8 +258,7 @@ private function getMigrator()
256258
$this->storage = new VersionStorage($this->session);
257259
$finder = new VersionFinder(array($this->migrationDir));
258260
$versions = $finder->getCollection();
259-
$migrator = new Migrator($this->session, $versions, $this->storage);
260261

261-
return $migrator;
262+
return new Migrator($this->session, $versions, $this->storage);
262263
}
263264
}

tests/Unit/MigratorFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\Migrator;
1515
use PHPCR\Migrations\MigratorFactory;

tests/Unit/MigratorUtilTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\MigratorUtil;
1515
use PHPUnit\Framework\TestCase;

tests/Unit/VersionCollectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\VersionCollection;
1515
use PHPCR\Migrations\VersionInterface;
@@ -21,7 +21,7 @@ class VersionCollectionTest extends TestCase
2121
const VERSION2 = '201501020000';
2222
const VERSION3 = '201501030000';
2323

24-
public function setUp()
24+
public function setUp(): void
2525
{
2626
$this->version1 = $this->prophesize('PHPCR\Migrations\VersionInterface');
2727
$this->version2 = $this->prophesize('PHPCR\Migrations\VersionInterface');

tests/Unit/VersionFinderTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\VersionCollection;
1515
use PHPCR\Migrations\VersionFinder;
1616
use PHPUnit\Framework\TestCase;
1717

1818
class VersionFinderTest extends TestCase
1919
{
20-
public function setUp()
20+
/**
21+
* @var VersionFinder
22+
*/
23+
private $finder;
24+
25+
public function setUp(): void
2126
{
2227
$this->finder = new VersionFinder(array(
2328
__DIR__ . '/../migrations',

0 commit comments

Comments
 (0)