Skip to content

Commit

Permalink
Fix CI errors caused by old PHP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgq committed Feb 3, 2021
1 parent d82dedd commit 94bf468
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- hhvm

matrix:
include:
- php: 5.3
dist: precise
- php: 5.4
dist: trusty
- php: 5.5
dist: trusty
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: hhvm-3.30

before_script:
- composer install
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Removed `prestissimo` from the [Dockerfile](Dockerfile).

### Fixed
- Fixed Travis build for PHP 5.4 and 5.5.

## [1.1.2] - 2018-06-03
### Added
- Added a Contributors file.
Expand Down
9 changes: 3 additions & 6 deletions benchmark/BenchmarkRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ class BenchmarkRunner
{
private $progressBar;
private $terrainGenerator;
private $stopwatch;

public function __construct(ProgressBar $progressBar)
{
$this->progressBar = $progressBar;
$this->terrainGenerator = new TerrainGenerator();
$this->stopwatch = new Stopwatch();
}

/**
Expand All @@ -42,18 +40,17 @@ public function run(array $sizes, $iterations, $seed)
$start = new MyNode(0, 0);
$goal = new MyNode($size - 1, $size - 1);

$this->stopwatch->start('benchmark');
$stopwatch = new Stopwatch();
$stopwatch->start('benchmark');

$solution = $aStar->run($start, $goal);

$event = $this->stopwatch->stop('benchmark');
$event = $stopwatch->stop('benchmark');

$solutionFound = !empty($solution);

$results[] = new Result($size, $event->getDuration(), $solutionFound);

$this->stopwatch->reset();

$this->progressBar->advance();
}
}
Expand Down
5 changes: 4 additions & 1 deletion benchmark/Result/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public function display(array $results)
*/
private function orderResults(array $results)
{
usort($results, function ($a, $b) {
// Suppressing the errors thrown by usort due to a PHP5 bug:
// https://bugs.php.net/bug.php?id=50688
// https://stackoverflow.com/q/3235387
@usort($results, function ($a, $b) {
return $a->getSize() > $b->getSize();
});

Expand Down

0 comments on commit 94bf468

Please sign in to comment.