json-patch-php
json-patch-php copied to clipboard
count(): Parameter must be an array or an object that implements Countable
src:
{"bankruptcy":null}
$src = {array} [1]
bankruptcy = null
dst:
{"bankruptcy":24}
$dst = {array} [1]
bankruptcy = {int} 24
{
"message": "count(): Parameter must be an array or an object that implements Countable",
"exception": "ErrorException",
"file": "/var/www/app/vendor/mikemccabe/json-patch-php/src/JsonPatch.php",
"line": 264,
"trace": [
{
"file": "/var/www/app/vendor/sentry/sentry/src/ErrorHandler.php",
"line": 361,
"function": "handleError",
"class": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
"type": "->"
},
{
"function": "handleError",
"class": "Sentry\\ErrorHandler",
"type": "->"
},
{
"file": "/var/www/app/vendor/mikemccabe/json-patch-php/src/JsonPatch.php",
"line": 264,
"function": "count"
},
{
"file": "/var/www/app/vendor/mikemccabe/json-patch-php/src/JsonPatch.php",
"line": 311,
"function": "diff_values",
"class": "mikemccabe\\JsonPatch\\JsonPatch",
"type": "::"
},
{
"file": "/var/www/app/vendor/mikemccabe/json-patch-php/src/JsonPatch.php",
"line": 271,
"function": "diff_assoc",
"class": "mikemccabe\\JsonPatch\\JsonPatch",
"type": "::"
},
{
"file": "/var/www/app/vendor/mikemccabe/json-patch-php/src/JsonPatch.php",
"line": 77,
"function": "diff_values",
"class": "mikemccabe\\JsonPatch\\JsonPatch",
"type": "::"
},
Workaround:
Index: vendor/mikemccabe/json-patch-php/src/JsonPatch.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/mikemccabe/json-patch-php/src/JsonPatch.php (date 1569430634786)
+++ vendor/mikemccabe/json-patch-php/src/JsonPatch.php (date 1569430634786)
@@ -261,7 +261,7 @@
private static function diff_values($path, $value, $other)
{
// manually handle the {}-looks-like-[] case, when other is associative
- if ((count($value) == 0 || count($other) == 0)
+ if ((@count($value) == 0 || @count($other) == 0)
&& (self::is_associative($value) || self::is_associative($other)))
{
return self::diff_assoc($path, $value, $other);
or require dev-master version
And another patch:
Idex: vendor/mikemccabe/json-patch-php/src/JsonPatch.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/mikemccabe/json-patch-php/src/JsonPatch.php (date 1570547451959)
+++ vendor/mikemccabe/json-patch-php/src/JsonPatch.php (date 1570547451959)
@@ -291,7 +291,7 @@
private static function diff_assoc($path, $src, $dst)
{
$result = array();
- if (count($src) == 0 && count($dst) != 0)
+ if (@count($src) == 0 && @count($dst) != 0)
{
$result[] = array("op" => "replace", "path" => "$path", "value" => $dst);
}