Skip to content

Commit 42b5558

Browse files
authored
Merge pull request #26 from macburgee1/master
Add PHP 8 support
2 parents a36899c + 78f20cd commit 42b5558

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"issues": "https://github.com/neilime/php-css-lint/issues"
2424
},
2525
"require": {
26-
"php": "^7.3",
26+
"php": "^7.3 || ^8",
2727
"ext-json": "*"
2828
},
2929
"require-dev": {

tests/TestSuite/LinterTest.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@ class LinterTest extends \PHPUnit\Framework\TestCase
1010
*/
1111
protected $linter;
1212

13+
/**
14+
* @var string
15+
*/
16+
protected $phpVersion;
17+
1318
protected function setUp(): void
1419
{
1520
$this->linter = new \CssLint\Linter();
21+
$php_version = phpversion();
22+
if (version_compare($php_version, '8.0.0', '>=')) {
23+
$this->phpVersion = '8';
24+
} else {
25+
$this->phpVersion = '7';
26+
}
1627
}
1728

1829
public function testConstructWithCustomCssLintProperties()
@@ -113,20 +124,30 @@ public function testLintStringWithWrongSelectorUnexpectedToken()
113124
public function testLintStringWithWrongTypeParam()
114125
{
115126
$this->expectException(\TypeError::class);
116-
$this->expectExceptionMessage(
117-
'Argument 1 passed to CssLint\Linter::lintString() must be of the type string, array given'
118-
);
119-
127+
if ($this->phpVersion == '8') {
128+
$this->expectExceptionMessage(
129+
'CssLint\Linter::lintString(): Argument #1 ($sString) must be of type string, array given'
130+
);
131+
} else {
132+
$this->expectExceptionMessage(
133+
'Argument 1 passed to CssLint\Linter::lintString() must be of the type string, array given'
134+
);
135+
}
120136
$this->linter->lintString(['wrong']);
121-
$this->assertFalse(false);
122137
}
123138

124139
public function testLintFileWithWrongTypeParam()
125140
{
126141
$this->expectException(\TypeError::class);
127-
$this->expectExceptionMessage(
128-
'Argument 1 passed to CssLint\Linter::lintFile() must be of the type string, array given'
129-
);
142+
if ($this->phpVersion == '8') {
143+
$this->expectExceptionMessage(
144+
'CssLint\Linter::lintFile(): Argument #1 ($sFilePath) must be of type string, array given'
145+
);
146+
} else {
147+
$this->expectExceptionMessage(
148+
'Argument 1 passed to CssLint\Linter::lintFile() must be of the type string, array given'
149+
);
150+
}
130151
$this->linter->lintFile(['wrong']);
131152
}
132153

0 commit comments

Comments
 (0)