Skip to content

Commit 67b7ab5

Browse files
clueSimonFrings
authored andcommitted
Support PHP 8
1 parent 1ad397e commit 67b7ab5

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ $ composer require clue/graph:^0.9.1
115115
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
116116

117117
This project aims to run on any platform and thus does not require any PHP
118-
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
118+
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
119119
HHVM.
120120
It's *highly recommended to use PHP 7+* for this project.
121121

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
},
2424
"require": {
25-
"php": "^7.0 || ^5.3"
25+
"php": ">=5.3"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"

src/Exception/NegativeCycleException.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ class NegativeCycleException extends UnexpectedValueException implements Graph\E
1414
*/
1515
private $cycle;
1616

17-
public function __construct($message, $code = NULL, $previous = NULL, Walk $cycle)
17+
public function __construct($message, $code = NULL, $previous = NULL, Walk $cycle = null)
1818
{
19+
// $cycle is required, but required argument may not appear after option arguments as of PHP 8
20+
if ($cycle === null) {
21+
throw new \InvalidArgumentException('Missing required cycle');
22+
}
23+
1924
parent::__construct($message, $code, $previous);
2025
$this->cycle = $cycle;
2126
}

tests/Exception/NegativeCycleExceptionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ public function testConstructor()
1818
$this->assertEquals('test', $exception->getMessage());
1919
$this->assertEquals($cycle, $exception->getCycle());
2020
}
21+
22+
public function testConstructorThrowsWhenNoCycleIsGiven()
23+
{
24+
$this->setExpectedException('InvalidArgumentException');
25+
new NegativeCycleException('test');
26+
}
2127
}

0 commit comments

Comments
 (0)