Skip to content

Commit c243b6e

Browse files
author
Marcel Thole
committed
Update dependencies
This will include an update of the min PHP version to PHP 8.1 to allow an update of the existing dependency on doctrine/lexer This will also lead to an update of PHPUnit and removed an old dependency on codeclimate/php-test-reporter which is not maintained anymore Travis CI is also not available anymore and was moved to Github Actions
1 parent b55553a commit c243b6e

File tree

9 files changed

+140
-133
lines changed

9 files changed

+140
-133
lines changed

.github/workflows/php-ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PHP CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
name: "PHP Tests"
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
php-version: [ 8.1, 8.2, 8.3 ]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Set up PHP ${{ matrix.php-version }}
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-version }}
26+
coverage: none
27+
tools: composer:v2
28+
29+
- name: Install dependencies
30+
run: composer --prefer-source install
31+
32+
- name: Run tests
33+
run: ./vendor/bin/phpunit -v

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
composer.lock
3+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
],
1212
"license": "MIT",
1313
"require": {
14-
"php": ">=7.1",
14+
"php": ">=8.1",
1515
"ext-SPL": "*",
16-
"doctrine/lexer": ">=1.0"
16+
"doctrine/lexer": "^3.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "~5.0",
20-
"codeclimate/php-test-reporter": "dev-master"
19+
"phpunit/phpunit": "^9.6"
2120
},
2221
"autoload": {
2322
"psr-0": {

lib/CrEOF/Geo/String/Lexer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct($input = null)
6262
*
6363
* @return int
6464
*/
65-
protected function getType(&$value)
65+
protected function getType(string &$value)
6666
{
6767
if (is_numeric($value)) {
6868
$value += 0;
@@ -71,6 +71,8 @@ protected function getType(&$value)
7171
return self::T_INTEGER;
7272
}
7373

74+
$value = rtrim(sprintf('%f', $value), '0');
75+
7476
return self::T_FLOAT;
7577
}
7678

lib/CrEOF/Geo/String/Parser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private function degrees()
222222
$glimpse = $this->lexer->glimpse();
223223

224224
// If a colon hasn't been matched, and next token is a number followed by degree symbol, when tuple separator is space instead of comma, this value is complete
225-
if (Lexer::T_COLON !== $this->nextSymbol && $this->lexer->isNextTokenAny(array(Lexer::T_INTEGER, Lexer::T_FLOAT)) && Lexer::T_DEGREE === $glimpse['type']) {
225+
if ($glimpse !== null && Lexer::T_COLON !== $this->nextSymbol && $this->lexer->isNextTokenAny(array(Lexer::T_INTEGER, Lexer::T_FLOAT)) && Lexer::T_DEGREE === $glimpse->type) {
226226
return $degrees;
227227
}
228228

@@ -407,7 +407,7 @@ private function cardinal($value)
407407
{
408408
// If cardinal direction was not on previous coordinate it can be anything
409409
if (null === $this->nextCardinal) {
410-
$this->nextCardinal = Lexer::T_CARDINAL_LON === $this->lexer->lookahead['type'] ? Lexer::T_CARDINAL_LON : Lexer::T_CARDINAL_LAT;
410+
$this->nextCardinal = Lexer::T_CARDINAL_LON === $this->lexer->lookahead->type ? Lexer::T_CARDINAL_LON : Lexer::T_CARDINAL_LAT;
411411
}
412412

413413
// Match cardinal direction
@@ -468,7 +468,7 @@ private function match($token)
468468
$this->lexer->moveNext();
469469

470470
// Return the token value
471-
return $this->lexer->token['value'];
471+
return $this->lexer->token->value;
472472
}
473473

474474
/**
@@ -482,11 +482,11 @@ private function syntaxError($expected)
482482
{
483483
$expected = sprintf('Expected %s, got', $expected);
484484
$token = $this->lexer->lookahead;
485-
$found = null === $this->lexer->lookahead ? 'end of string.' : sprintf('"%s"', $token['value']);
485+
$found = null === $this->lexer->lookahead ? 'end of string.' : sprintf('"%s"', $token->value);
486486

487487
$message = sprintf(
488488
'[Syntax Error] line 0, col %d: Error: %s %s in value "%s"',
489-
isset($token['position']) ? $token['position'] : '-1',
489+
$token->position ?? -1,
490490
$expected,
491491
$found,
492492
$this->input

phpunit.xml.dist

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
55
backupGlobals="false"
66
colors="true"
77
bootstrap="./vendor/autoload.php"
@@ -12,14 +12,4 @@
1212
<directory>./tests/CrEOF/Geo/String/Tests</directory>
1313
</testsuite>
1414
</testsuites>
15-
16-
<filter>
17-
<whitelist>
18-
<directory suffix=".php">lib</directory>
19-
<exclude>
20-
<directory>tests</directory>
21-
<directory>vendor</directory>
22-
</exclude>
23-
</whitelist>
24-
</filter>
2515
</phpunit>

0 commit comments

Comments
 (0)