Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit c52a017

Browse files
authored
Merge pull request #47 from xparse/add-php-8
Add php8 support
2 parents dedde4f + d52a51c commit c52a017

6 files changed

Lines changed: 22 additions & 23 deletions

File tree

.github/workflows/test.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php-versions: ['7.2', '7.3', '7.4']
10+
php-versions: ['7.3', '7.4', '8.0']
11+
package-stability: ['stable', 'alpha']
1112
name: PHP ${{ matrix.php-versions }}
1213
steps:
1314
- name: Checkout
@@ -28,6 +29,9 @@ jobs:
2829
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
2930
restore-keys: |
3031
${{ runner.os }}-composer-
32+
33+
- name: Configure stability
34+
run: composer config minimum-stability ${{ matrix.package-stability }}
3135
- name: Install dependencies
3236
run: composer install --prefer-dist --dev
3337

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
"name": "xparse/css-expression-translator",
33
"description": "Translate css to xpath",
44
"keywords": [],
5-
"homepage": "https://github.com/",
5+
"homepage": "https://github.com/xparse/CssExpressionTranslator",
66
"license": "MIT",
77
"authors": [
88
{
9-
"name": "funivan",
10-
"email": "dev@funivan.com",
9+
"name": "Ivan Shcherbak @funivan",
10+
"email": "alotofall@gmail.com",
1111
"homepage": "http://funivan.com",
1212
"role": "Developer"
1313
}
1414
],
1515
"require": {
16-
"php": ">=7.1",
17-
"xparse/expression-translator": "0.0.*",
18-
"symfony/css-selector": "^3.0"
16+
"php": "^7.1 || ^8.0",
17+
"symfony/css-selector": "^3.0",
18+
"xparse/expression-translator": "0.0.*"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "^7.0"
21+
"phpunit/phpunit": "^9.3"
2222
},
2323
"autoload": {
2424
"psr-4": {

src/CssExpressionTranslator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function convertToXpath(string $expression): string
1818
foreach (explode(', ', $expression) as $part) {
1919
preg_match('!(.+) (@.+|.+\(\))$!', $part, $matchExpression);
2020
if (!array_key_exists(2, $matchExpression)) {
21-
$xpathExpression[] = parent::toXPath($part);
21+
$xpathExpression[] = $this->toXPath($part);
2222
} else {
23-
$xpathExpression[] = parent::toXPath($matchExpression[1]) . '/' . $matchExpression[2];
23+
$xpathExpression[] = $this->toXPath($matchExpression[1]) . '/' . $matchExpression[2];
2424
}
2525
}
2626
return implode(' | ', $xpathExpression);

src/CssOrXpathExpressionTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CssOrXpathExpressionTranslator implements ExpressionTranslatorInterface
1515
{
1616

1717
/**
18-
* @var ExpressionTranslatorInterface
18+
* @var ?ExpressionTranslatorInterface
1919
*/
2020
private static $translator;
2121

tests/CssExpressionTranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CssExpressionTranslatorTest extends TestCase
1313
{
1414

1515
/**
16-
* @return array
16+
* @return string[][]
1717
*/
1818
final public function getConvertWithAttributesDataProvider(): array
1919
{

tests/CssOrXpathExpressionTranslatorTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace Tests\Atl\Http\Parser;
4+
namespace Xparse\CssExpressionTranslator\Test;
55

6+
use InvalidArgumentException;
67
use PHPUnit\Framework\TestCase;
78
use Xparse\CssExpressionTranslator\CssOrXpathExpressionTranslator;
89

@@ -13,7 +14,7 @@ final class CssOrXpathExpressionTranslatorTest extends TestCase
1314
{
1415

1516
/**
16-
* @return array
17+
* @return string[][]
1718
*/
1819
public function getQueriesDataProvider(): array
1920
{
@@ -97,26 +98,20 @@ public function testQueries(string $input, string $expect): void
9798
{
9899
$output = CssOrXpathExpressionTranslator::getTranslator()
99100
->convertToXpath($input);
100-
static::assertEquals($expect, $output);
101+
self::assertEquals($expect, $output);
101102
}
102103

103104

104-
/**
105-
* @expectedException \InvalidArgumentException
106-
*/
107105
public function testEmptyString(): void
108106
{
109-
/** @noinspection UnusedFunctionResultInspection */
107+
self::expectException(InvalidArgumentException::class);
110108
CssOrXpathExpressionTranslator::getTranslator()->convertToXpath('');
111109
}
112110

113111

114-
/**
115-
* @expectedException \InvalidArgumentException
116-
*/
117112
public function testEmptyStringWithSpaces(): void
118113
{
119-
/** @noinspection UnusedFunctionResultInspection */
114+
self::expectException(InvalidArgumentException::class);
120115
CssOrXpathExpressionTranslator::getTranslator()->convertToXpath(' ');
121116
}
122117

0 commit comments

Comments
 (0)