[tarent-useful-scripts SCM] git branch master updated. 31c28fd6fff288c219252b5ecd3079c531d59ece

mirabilos at evolvis.org mirabilos at evolvis.org
Wed Jun 14 14:22:39 CEST 2017 • <20170614122239.7D6A34A030B@evolvis.org>


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main git repository for Evolvis project useful-scripts".

The branch, master has been updated
       via  31c28fd6fff288c219252b5ecd3079c531d59ece (commit)
      from  6ca1f776293eee44305accc1543f6ecd68fb7263 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 31c28fd6fff288c219252b5ecd3079c531d59ece
Author: mirabilos <t.glaser at tarent.de>
Date:   Wed Jun 14 14:22:31 2017 +0200

    update from hello-php-world master copy

-----------------------------------------------------------------------

Summary of changes:
 misc/minijson.php | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/misc/minijson.php b/misc/minijson.php
index 6b96cbc..6124d8d 100644
--- a/misc/minijson.php
+++ b/misc/minijson.php
@@ -69,10 +69,10 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 		return 'false';
 	if (is_int($x)) {
 		$y = (int)$x;
-		$z = (string)$y;
+		$z = strval($y);
 		if ($x == $z)
 			return $z;
-		$x = (string)$x;
+		$x = strval($x);
 	}
 	if (is_float($x)) {
 		$rs = sprintf('%.14e', $x);
@@ -99,7 +99,7 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 		/*
 		 * A bit unbelievable: not only does mb_check_encoding
 		 * not exist from the start, but also does it not check
-		 * reliably – so converting forth and back is the way
+		 * reliably — so converting forth and back is the way
 		 * they recommend… also, JSON is not binary-safe either…
 		 */
 		$isunicode = false;
@@ -157,12 +157,15 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 	}
 	if (is_array($x)) {
 		$k = array_keys($x);
+		if (!$k) {
+			return '[]';
+		}
 
 		$isnum = true;
 		foreach ($k as $v) {
 			if (is_int($v)) {
 				$y = (int)$v;
-				$z = (string)$y;
+				$z = strval($y);
 				if ($v != $z) {
 					$isnum = false;
 					break;
@@ -226,7 +229,7 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 				$rs .= ",\n";
 			if ($si !== false)
 				$rs .= $si;
-			$rs .= minijson_encode_internal((string)$v, false,
+			$rs .= minijson_encode_internal(strval($v), false,
 			    $depth, $truncsz, $dumprsrc);
 			if ($ri === false)
 				$rs .= ':';
@@ -249,6 +252,9 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 			$k[$v] = preg_replace('/^\0([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\*)\0(.)/',
 			    '\\\\$1\\\\$2', $v);
 		}
+		if (!$k) {
+			return '{}';
+		}
 		$si = $ri === false ? false : $ri . '  ';
 		$first = true;
 		$rs = '{';
@@ -281,7 +287,7 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 
 	/* http://de2.php.net/manual/en/function.is-resource.php#103942 */
 	if ($dumprsrc && !is_null($rsrctype = @get_resource_type($x))) {
-		$k = ''.$rsrctype;
+		$k = strval($rsrctype);
 		$rs = '{';
 		if ($ri !== false)
 			$rs .= "\n" . $ri . '  ';
@@ -297,7 +303,7 @@ function minijson_encode_internal($x, $ri, $depth, $truncsz, $dumprsrc) {
 	}
 
 	/* treat everything else as array or string */
-	return minijson_encode_internal(is_scalar($x) ? (string)$x : (array)$x,
+	return minijson_encode_internal(is_scalar($x) ? strval($x) : (array)$x,
 	    $ri, $depth, $truncsz, $dumprsrc);
 }
 
@@ -703,7 +709,7 @@ function minijson_decode_number(&$j, &$p, &$ov) {
 		/* no fractional part, no exponent */
 
 		$v = (int)$s;
-		if ((string)$v == $s) {
+		if (strval($v) == $s) {
 			$ov = $v;
 			return true;
 		}
@@ -747,7 +753,7 @@ if (defined('__main__') && constant('__main__') === __FILE__) {
 				$depth = array_shift($argv);
 				if (!preg_match('/^[1-9][0-9]*$/', $depth))
 					usage();
-				if ((string)(int)$depth !== $depth)
+				if (strval((int)$depth) !== $depth)
 					usage();
 				$depth = (int)$depth;
 				break;
@@ -763,7 +769,7 @@ if (defined('__main__') && constant('__main__') === __FILE__) {
 				$truncsz = array_shift($argv);
 				if (!preg_match('/^[1-9][0-9]*$/', $truncsz))
 					usage();
-				if ((string)(int)$truncsz !== $truncsz)
+				if (strval((int)$truncsz) !== $truncsz)
 					usage();
 				$truncsz = (int)$truncsz;
 				break;


hooks/post-receive
-- 
Main git repository for Evolvis project useful-scripts
(Evolvis project useful-scripts repository useful-scripts)


More information about the useful-scripts-commits mailing list