Skip to content

Commit 15dd9ff

Browse files
committed
Fixed dependencies for PHP 7.2
1 parent 22cb2a5 commit 15dd9ff

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed

.scrutinizer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ build:
2525
filter:
2626
excluded_paths:
2727
- RoboFile.php
28+
- phpinsights.php
2829
- tests/*
2930
checks:
3031
php:

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,19 +470,22 @@ Clone the project, run `composer install` then...
470470
$ vendor/bin/robo test --php 7.2 --wait 10 --db mysql --db-version 5
471471
$ vendor/bin/robo test --php 7.3 --wait 10 --db mysql --db-version 8
472472
$ vendor/bin/robo test --php 7.4 --wait 10 --db mysql --db-version 8
473+
$ vendor/bin/robo test --php 8.0 --wait 10 --db mysql --db-version 8
473474
```
474475
#### With PostgreSQL 9, 10 and 11 (12 also works)
475476
```bash
476477
$ vendor/bin/robo test --php 7.2 --wait 10 --db pgsql --db-version 10
477478
$ vendor/bin/robo test --php 7.3 --wait 10 --db pgsql --db-version 11
478479
$ vendor/bin/robo test --php 7.4 --wait 10 --db pgsql --db-version 12
480+
$ vendor/bin/robo test --php 8.0 --wait 10 --db pgsql --db-version 13
479481
```
480482
#### With SQL Server
481483
**Warning** : 2 tests *fail*, because of strange behaviors of SQL Server ... or Doctrine / Dbal. PHPUnit can't compare 2 Datasets because the fields are not in the same order.
482484
```bash
483485
$ vendor/bin/robo test --php 7.2 --wait 15 --db sqlsrv
484486
$ vendor/bin/robo test --php 7.3 --wait 15 --db sqlsrv
485487
$ vendor/bin/robo test --php 7.4 --wait 15 --db sqlsrv
488+
$ vendor/bin/robo test --php 8.0 --wait 15 --db sqlsrv
486489
```
487490

488491
### Build a release (with a phar and a git tag)
@@ -500,3 +503,8 @@ $ php -d phar.readonly=0 vendor/bin/robo phar
500503
```bash
501504
docker run -it --rm -v $(pwd):/app nunomaduro/phpinsights analyse --fix
502505
```
506+
507+
### Update dependencies to make sure it'll work with PHP 7.2
508+
```bash
509+
vendor/bin/robo composer:update
510+
```

RoboFile.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
class RoboFile extends \Robo\Tasks
1616
{
1717
private $phpVersion = 7.2;
18+
private $composer = '/usr/local/bin/composer';
1819
private $dbType = 'mysql';
1920
private $dbVersion = 'latest';
2021
private $dbWait = 10;
@@ -81,6 +82,11 @@ public function test(array $opts = [
8182

8283
$this->setupDocker();
8384

85+
// Install composer and do a composer install to make sure
86+
// dependencies are compatible with that PHP version
87+
$this->installComposer();
88+
$this->doComposerInstall();
89+
8490
$cmd = '/bin/bash -c "cd /var/www/html ; vendor/bin/phpunit ';
8591
$coverageOpt = '--no-coverage ';
8692

@@ -223,6 +229,35 @@ public function release(): void
223229
$this->say('Release ready, you can push');
224230
}
225231

232+
/**
233+
* Do a composer update with the minimum PHP version
234+
*/
235+
public function composerUpdate(): void
236+
{
237+
$this->io()->title('Do a composer update');
238+
239+
$this->stopContainer('robo_php');
240+
241+
$this
242+
->taskDockerRun('edyan/php:' . $this->phpVersion)
243+
->printOutput(false)
244+
->printMetadata(false)
245+
->detached()->name('robo_php')->option('--rm')
246+
->volume(__DIR__, '/var/www/html')
247+
->run();
248+
249+
$this->installComposer();
250+
251+
$cmd = "php {$this->composer} --prefer-dist --no-progress -o update";
252+
$this
253+
->taskDockerExec('robo_php')
254+
->printMetadata(false)
255+
->option('--user', 'www-data')
256+
->exec($this->taskExec("/bin/bash -c 'cd /var/www/html ; $cmd'"))
257+
->run();
258+
259+
}
260+
226261
private function setupDocker(): void
227262
{
228263
$this->destroyDocker();
@@ -335,6 +370,30 @@ private function stopContainer(string $ct): void
335370
$this->taskDockerStop($ct)->silent(true)->run();
336371
}
337372

373+
private function installComposer(): void
374+
{
375+
$this->say('Install composer');
376+
$url = 'https://getcomposer.org/download/latest-stable/composer.phar';
377+
$this
378+
->taskDockerExec('robo_php')
379+
->printMetadata(false)
380+
->exec($this->taskExec("php -r \"copy('$url', '{$this->composer}');\""))
381+
->run();
382+
}
383+
384+
private function doComposerInstall(): void
385+
{
386+
$this->say('Do a composer install');
387+
388+
$cmd = "php {$this->composer} --dry-run --quiet --no-autoloader --no-progress install";
389+
$this
390+
->taskDockerExec('robo_php')
391+
->printMetadata(false)
392+
->option('--user', 'www-data')
393+
->exec($this->taskExec("/bin/bash -c 'cd /var/www/html ; $cmd'"))
394+
->run();
395+
}
396+
338397
private function gitVerifyBranchIsMaster(): void
339398
{
340399
$branch = $this->taskGitStack()

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)