From 7e14fc371531710d066d00e39948e1f792bd5da7 Mon Sep 17 00:00:00 2001 From: Christopher Burge Date: Tue, 8 Dec 2020 11:22:44 -0600 Subject: [PATCH 1/2] Add PHP 8 support in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 71a7c26..95862e0 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "issues": "https://github.com/neilime/php-css-lint/issues" }, "require": { - "php": "^7.3", + "php": "^7.3 || ^8", "ext-json": "*" }, "require-dev": { From 78f20cd72e7c82973a41d230b74d9bc9ca02bc50 Mon Sep 17 00:00:00 2001 From: Christopher Burge Date: Tue, 8 Dec 2020 12:21:14 -0600 Subject: [PATCH 2/2] Update tests for PHP 8 --- tests/TestSuite/LinterTest.php | 37 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/TestSuite/LinterTest.php b/tests/TestSuite/LinterTest.php index 7ed0ff1..81af2a9 100644 --- a/tests/TestSuite/LinterTest.php +++ b/tests/TestSuite/LinterTest.php @@ -10,9 +10,20 @@ class LinterTest extends \PHPUnit\Framework\TestCase */ protected $linter; + /** + * @var string + */ + protected $phpVersion; + protected function setUp(): void { $this->linter = new \CssLint\Linter(); + $php_version = phpversion(); + if (version_compare($php_version, '8.0.0', '>=')) { + $this->phpVersion = '8'; + } else { + $this->phpVersion = '7'; + } } public function testConstructWithCustomCssLintProperties() @@ -113,20 +124,30 @@ public function testLintStringWithWrongSelectorUnexpectedToken() public function testLintStringWithWrongTypeParam() { $this->expectException(\TypeError::class); - $this->expectExceptionMessage( - 'Argument 1 passed to CssLint\Linter::lintString() must be of the type string, array given' - ); - + if ($this->phpVersion == '8') { + $this->expectExceptionMessage( + 'CssLint\Linter::lintString(): Argument #1 ($sString) must be of type string, array given' + ); + } else { + $this->expectExceptionMessage( + 'Argument 1 passed to CssLint\Linter::lintString() must be of the type string, array given' + ); + } $this->linter->lintString(['wrong']); - $this->assertFalse(false); } public function testLintFileWithWrongTypeParam() { $this->expectException(\TypeError::class); - $this->expectExceptionMessage( - 'Argument 1 passed to CssLint\Linter::lintFile() must be of the type string, array given' - ); + if ($this->phpVersion == '8') { + $this->expectExceptionMessage( + 'CssLint\Linter::lintFile(): Argument #1 ($sFilePath) must be of type string, array given' + ); + } else { + $this->expectExceptionMessage( + 'Argument 1 passed to CssLint\Linter::lintFile() must be of the type string, array given' + ); + } $this->linter->lintFile(['wrong']); }