[php-JsonSchema] PHP < 5.4.0 compatibility patch instead of in-spec logic

Shawn Iwinski siwinski at fedoraproject.org
Sat Aug 30 13:01:08 UTC 2014


commit b2ec54f30b25657222b8942473f74fd34ec04661
Author: Shawn Iwinski <shawn.iwinski at gmail.com>
Date:   Sat Aug 30 08:52:29 2014 -0400

    PHP < 5.4.0 compatibility patch instead of in-spec logic

 php-JsonSchema-php-lt-5-4-0-compat.patch |   23 +++++++++++++++++++++++
 php-JsonSchema.spec                      |   19 +++++++++++--------
 2 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/php-JsonSchema-php-lt-5-4-0-compat.patch b/php-JsonSchema-php-lt-5-4-0-compat.patch
new file mode 100644
index 0000000..a63c44e
--- /dev/null
+++ b/php-JsonSchema-php-lt-5-4-0-compat.patch
@@ -0,0 +1,23 @@
+From 3973764636b93f1b94ea6842bdf2e780b2a59822 Mon Sep 17 00:00:00 2001
+From: Shawn Iwinski <siwinski at redhat.com>
+Date: Fri, 29 Aug 2014 22:41:25 -0400
+Subject: [PATCH] PHP < 5.4.0 compatibility for "--dump-schema"
+
+---
+ bin/validate-json | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/bin/validate-json b/bin/validate-json
+index 2f2fe44..8831a6e 100755
+--- a/bin/validate-json
++++ b/bin/validate-json
+@@ -218,7 +218,8 @@ $refResolver = new JsonSchema\RefResolver($retriever);
+ $refResolver->resolve($schema, $urlSchema);
+ 
+ if (isset($arOptions['--dump-schema'])) {
+-    echo json_encode($schema, JSON_PRETTY_PRINT) . "\n";
++    $options = version_compare(PHP_VERSION, '5.4.0', '>=') ? JSON_PRETTY_PRINT : 0;
++    echo json_encode($schema, $options) . "\n";
+     exit();
+ }
+ 
diff --git a/php-JsonSchema.spec b/php-JsonSchema.spec
index 5ef8341..b3bd284 100644
--- a/php-JsonSchema.spec
+++ b/php-JsonSchema.spec
@@ -24,7 +24,7 @@
 
 Name:          php-%{lib_name}
 Version:       %{github_version}
-Release:       1%{?dist}
+Release:       2%{?dist}
 Summary:       PHP implementation of JSON schema
 
 Group:         Development/Libraries
@@ -32,6 +32,10 @@ License:       BSD
 URL:           https://github.com/%{github_owner}/%{github_name}
 Source0:       %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
 
+# PHP < 5.4.0 compatibility for "--dump-schema"
+# https://github.com/justinrainbow/json-schema/pull/109
+Patch0:        %{name}-php-lt-5-4-0-compat.patch
+
 BuildArch: noarch
 %if %{with_tests}
 # For tests
@@ -67,15 +71,11 @@ See http://json-schema.org for more details.
 %prep
 %setup -qn %{github_name}-%{github_commit}
 
-# Update bin file
-## Shebang
+%patch0 -p1
+
+# Update bin shebang
 sed 's#/usr/bin/env php#%{_bindir}/php#' \
     -i bin/validate-json
-## PHP < 5.4.0 compatibility for "--dump-schema"
-%if "%{php_version}" < "5.4"
-sed 's#,\s*JSON_PRETTY_PRINT##' \
-    -i bin/validate-json
-%endif
 
 
 %build
@@ -127,6 +127,9 @@ sed 's/colors\s*=\s*"true"/colors="false"/' phpunit.xml.dist > phpunit.xml
 
 
 %changelog
+* Sat Aug 30 2014 Shawn Iwinski <shawn.iwinski at gmail.com> - 1.3.7-2
+- PHP < 5.4.0 compatibility patch instead of in-spec logic
+
 * Fri Aug 29 2014 Shawn Iwinski <shawn.iwinski at gmail.com> - 1.3.7-1
 - Updated to 1.3.7 (BZ #1133519)
 - Added option to build without tests ("--without tests")


More information about the scm-commits mailing list