Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Marcel Thole committed Feb 14, 2024
1 parent b55553a commit 2151863
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 133 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/php-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PHP CI

on:
push:
branches:
- main
pull_request:

jobs:
build:
name: "PHP Tests"
runs-on: ubuntu-latest

strategy:
matrix:
php-version: [ 8.1, 8.2, 8.3 ]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer --prefer-source install

- name: Run tests
run: ./vendor/bin/phpunit -v
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
composer.lock
.phpunit.result.cache
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
],
"license": "MIT",
"require": {
"php": ">=7.1",
"php": ">=8.1",
"ext-SPL": "*",
"doctrine/lexer": ">=1.0"
"doctrine/lexer": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "~5.0",
"codeclimate/php-test-reporter": "dev-master"
"phpunit/phpunit": "^9.6"
},
"autoload": {
"psr-0": {
Expand Down
4 changes: 3 additions & 1 deletion lib/CrEOF/Geo/String/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct($input = null)
*
* @return int
*/
protected function getType(&$value)
protected function getType(string &$value)
{
if (is_numeric($value)) {
$value += 0;
Expand All @@ -71,6 +71,8 @@ protected function getType(&$value)
return self::T_INTEGER;
}

$value = rtrim(sprintf('%.8F', $value), '0');

return self::T_FLOAT;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/CrEOF/Geo/String/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private function degrees()
$glimpse = $this->lexer->glimpse();

// 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
if (Lexer::T_COLON !== $this->nextSymbol && $this->lexer->isNextTokenAny(array(Lexer::T_INTEGER, Lexer::T_FLOAT)) && Lexer::T_DEGREE === $glimpse['type']) {
if ($glimpse !== null && Lexer::T_COLON !== $this->nextSymbol && $this->lexer->isNextTokenAny(array(Lexer::T_INTEGER, Lexer::T_FLOAT)) && Lexer::T_DEGREE === $glimpse->type) {
return $degrees;
}

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

// Match cardinal direction
Expand Down Expand Up @@ -468,7 +468,7 @@ private function match($token)
$this->lexer->moveNext();

// Return the token value
return $this->lexer->token['value'];
return $this->lexer->token->value;
}

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

$message = sprintf(
'[Syntax Error] line 0, col %d: Error: %s %s in value "%s"',
isset($token['position']) ? $token['position'] : '-1',
$token->position ?? -1,
$expected,
$found,
$this->input
Expand Down
12 changes: 1 addition & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php"
Expand All @@ -12,14 +12,4 @@
<directory>./tests/CrEOF/Geo/String/Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">lib</directory>
<exclude>
<directory>tests</directory>
<directory>vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
Loading

0 comments on commit 2151863

Please sign in to comment.