From feb6fa80bedd7592242bd6ab05dfcf8f0a586e16 Mon Sep 17 00:00:00 2001 From: Konrad Abicht Date: Mon, 14 Dec 2020 13:55:36 +0100 Subject: [PATCH] PHP 8 compatibility (#30) * added PHP nightly to .travis.yml * composer.json: fixed constraints to allow installation using PHP 8 * refined .travis.yml * fixed an "Unreachable statement - code above always terminates." * fixed CS issue --- .travis.yml | 7 ++----- composer.json | 4 ++-- src/N3Lexer.php | 2 +- test/TriGParserTest.php | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33eb93f..1dfecf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,16 +8,13 @@ php: - '7.1' - '7.2' - '7.3' - - nightly jobs: + fast_finish: true include: - php: 7.4 env: LINTER_RUN=run - - fast_finish: true - allow_failures: - - php: nightly + - php: nightly install: - composer update --prefer-dist --no-progress --no-suggest --optimize-autoloader diff --git a/composer.json b/composer.json index 9d8d94e..7182f0b 100644 --- a/composer.json +++ b/composer.json @@ -37,9 +37,9 @@ "php": "^7.1|^8.0" }, "require-dev" : { - "friendsofphp/php-cs-fixer": "^2.16.3", + "friendsofphp/php-cs-fixer": "*", "phpstan/phpstan": "^0.12.36", - "phpunit/phpunit": "^7" + "phpunit/phpunit": "^7 || ^8 || ^9" }, "scripts": { "cs": "vendor/bin/php-cs-fixer fix", diff --git a/src/N3Lexer.php b/src/N3Lexer.php index e2400c6..1bd1960 100644 --- a/src/N3Lexer.php +++ b/src/N3Lexer.php @@ -467,7 +467,7 @@ private function initTokenize() $this->input .= $input; $tokens = []; $error = ''; - $this->input = $this->tokenizeToEnd(function ($e, $t) use (&$tokens,&$error) { + $this->input = $this->tokenizeToEnd(function ($e, $t) use (&$tokens, &$error) { if (isset($e)) { $error = $e; } diff --git a/test/TriGParserTest.php b/test/TriGParserTest.php index f005e2e..925a2b8 100644 --- a/test/TriGParserTest.php +++ b/test/TriGParserTest.php @@ -60,11 +60,11 @@ public function shouldNotParse($createParser, $input, $expectedError = null): vo $parser->parse($input, function ($error, $triple = null) use ($expectedError, &$errorReceived) { //expect($error).not.to.exist; if (isset($error) && !$errorReceived) { - $this->assertEquals($expectedError, $error->getMessage()); $errorReceived = true; + $this->assertEquals($expectedError, $error->getMessage()); } elseif (!isset($triple) && !$errorReceived) { - $this->fail("Expected this error to be thrown (but it wasn't): ".$expectedError); $errorReceived = true; + $this->fail("Expected this error to be thrown (but it wasn't): ".$expectedError); } }); }