Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies for doctrine/lexer #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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