php warning

This commit is contained in:
zotlabs 2019-09-29 23:26:59 -07:00
parent 4c271a38cc
commit 94c1c89396
2 changed files with 8 additions and 6 deletions

View file

@ -36,7 +36,9 @@ class ActivityStreams {
/**
* @brief Constructor for ActivityStreams.
*
* Takes a JSON string as parameter, decodes it and sets up this object.
* Takes a JSON string or previously decode activity array as parameter,
* decodes it and sets up this object/activity, fetching any required attributes
* which were only referenced by @id/URI.
*
* @param string $string
*/
@ -47,6 +49,7 @@ class ActivityStreams {
if (is_array($string)) {
$this->data = $string;
$this->raw = json_encode($string,JSON_UNESCAPED_SLASHES);
}
else {
$this->data = json_decode($string, true);

View file

@ -2281,20 +2281,20 @@ function jindent($json) {
$prevChar = '';
$outOfQuotes = true;
for ($i=0; $i<=$strLen; $i++) {
for ($i = 0; $i <= $strLen; $i++) {
// Grab the next character in the string.
$char = substr($json, $i, 1);
// Are we inside a quoted string?
if ($char == '"' && $prevChar != '\\') {
$outOfQuotes = !$outOfQuotes;
}
// If this character is the end of an element,
// output a new line and indent the next line.
} else if(($char == '}' || $char == ']') && $outOfQuotes) {
elseif(($char == '}' || $char == ']') && $outOfQuotes) {
$result .= $newLine;
$pos --;
for ($j=0; $j<$pos; $j++) {
for ($j = 0; $j < $pos; $j++) {
$result .= $indentStr;
}
}
@ -2314,7 +2314,6 @@ function jindent($json) {
$result .= $indentStr;
}
}
$prevChar = $char;
}