From 966e9d6ac91779ae02c14bf99a00f32d808c2919 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 14 Nov 2016 18:23:45 +0100 Subject: php-jsonlint: fix for php 7.1 --- php-jsonlint-php71.patch | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ php-jsonlint.spec | 13 +++++++--- 2 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 php-jsonlint-php71.patch diff --git a/php-jsonlint-php71.patch b/php-jsonlint-php71.patch new file mode 100644 index 0000000..a1a4dc2 --- /dev/null +++ b/php-jsonlint-php71.patch @@ -0,0 +1,64 @@ +From d73abd9196d739099a26c4daf6dc4eb094824db5 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 14 Nov 2016 18:13:11 +0100 +Subject: [PATCH] fix for 7.1 (_empty_ no more used) + +--- + src/Seld/JsonLint/JsonParser.php | 12 ++++++++++-- + tests/JsonParserTest.php | 6 ++++++ + 2 files changed, 16 insertions(+), 2 deletions(-) + +diff --git a/src/Seld/JsonLint/JsonParser.php b/src/Seld/JsonLint/JsonParser.php +index acc1868..fc306a5 100644 +--- a/src/Seld/JsonLint/JsonParser.php ++++ b/src/Seld/JsonLint/JsonParser.php +@@ -376,7 +376,11 @@ private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yy + $yyval->token = array($tokens[$len-2], $tokens[$len]); + break; + case 16: +- $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0]; ++ if (PHP_VERSION_ID < 70100) { ++ $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0]; ++ } else { ++ $property = $tokens[$len][0]; ++ } + if ($this->flags & self::PARSE_TO_ASSOC) { + $yyval->token = array(); + $yyval->token[$property] = $tokens[$len][1]; +@@ -404,7 +408,11 @@ private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yy + $tokens[$len-2][$key] = $tokens[$len][1]; + } else { + $yyval->token = $tokens[$len-2]; +- $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0]; ++ if (PHP_VERSION_ID < 70100) { ++ $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0]; ++ } else { ++ $key = $tokens[$len][0]; ++ } + if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) { + $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n"; + $errStr .= $this->lexer->showPosition() . "\n"; +diff --git a/tests/JsonParserTest.php b/tests/JsonParserTest.php +index 1c00ff4..a993d17 100644 +--- a/tests/JsonParserTest.php ++++ b/tests/JsonParserTest.php +@@ -154,6 +154,9 @@ public function testDetectsKeyOverridesWithEmpty() + { + $parser = new JsonParser(); + ++ if (PHP_VERSION_ID >= 70100) { ++ $this->markTestSkipped('Only for PHP < 7.1'); ++ } + try { + $parser->parse('{"":"b", "_empty_":"a"}', JsonParser::DETECT_KEY_CONFLICTS); + $this->fail('Duplicate keys should not be allowed'); +@@ -182,6 +185,9 @@ public function testDuplicateKeysWithEmpty() + { + $parser = new JsonParser(); + ++ if (PHP_VERSION_ID >= 70100) { ++ $this->markTestSkipped('Only for PHP < 7.1'); ++ } + $result = $parser->parse('{"":"a", "_empty_":"b"}', JsonParser::ALLOW_DUPLICATE_KEYS); + $this->assertThat($result, + $this->logicalAnd( diff --git a/php-jsonlint.spec b/php-jsonlint.spec index 78096b7..a69d4f9 100644 --- a/php-jsonlint.spec +++ b/php-jsonlint.spec @@ -24,7 +24,7 @@ Name: php-%{github_name} Version: %{github_version} -Release: 2%{?dist} +Release: 3%{?dist} Summary: JSON Lint for PHP Group: Development/Libraries @@ -37,6 +37,8 @@ Source1: %{name}-autoload.php # Bin usage without Composer autoloader Patch0: %{name}-bin-without-composer-autoloader.patch +# https://github.com/Seldaek/jsonlint/pull/37 +Patch1: %{name}-php71.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch @@ -75,6 +77,7 @@ To use this library, you just have to add, in your project: cp %{SOURCE1} src/Seld/JsonLint/autoload.php %patch0 -p1 +%patch1 -p1 %build @@ -101,8 +104,8 @@ if which php56; then php56 %{_bindir}/phpunit --bootstrap %{buildroot}%{_datadir}/php/Seld/JsonLint/autoload.php || ret=1 run=1 fi -if which php70; then # With 7.1 '' => '_empty_' property names - php70 %{_bindir}/phpunit --bootstrap %{buildroot}%{_datadir}/php/Seld/JsonLint/autoload.php || ret=1 +if which php71; then + php71 %{_bindir}/phpunit --bootstrap %{buildroot}%{_datadir}/php/Seld/JsonLint/autoload.php || ret=1 run=1 fi if [ $run -eq 0 ]; then @@ -128,6 +131,10 @@ exit $ret %changelog +* Mon Nov 14 2016 Remi Collet - 1.4.1-3 +- add patch for PHP 7.1 + open https://github.com/Seldaek/jsonlint/pull/37 + * Fri Oct 21 2016 Remi Collet - 1.4.1-2 - switch from symfony/class-loader to fedora/autoloader -- cgit