Skip to content

Commit

Permalink
fix null value
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSuperStar committed Aug 10, 2023
1 parent 87b396d commit 56a96d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "alexsuperstar/jsonmaker",
"description": "PHP JSON Maker",
"type": "library",
"version": "1.4.0",
"version": "1.5.0",
"authors": [
{
"name": "Alexey Starikov",
Expand Down
6 changes: 3 additions & 3 deletions src/alexstar/JsonMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public function parse($data)
if (is_object($data) || is_array($data)) {
foreach ($data as $k => $v) {
if (is_object($data)) {
if (is_scalar($v)) {
if (is_scalar($v) || is_null($v)) {
$this->$k = $v;
}
else {
$this->$k->parse($v);
}
}
elseif (is_array($data)) {
if (is_scalar($v)) {
if (is_scalar($v) || is_null($v)) {
$this[$k] = $v;
}
else {
Expand Down Expand Up @@ -84,7 +84,7 @@ public function __invoke()
$vars[$v] = is_scalar($newVal) ? $newVal : new self($newVal);
}
else {
$vars = is_scalar($newVal) ? $newVal : new self($newVal);
$vars = is_scalar($newVal) || is_null($newVal) ? $newVal : new self($newVal);
}
}
return $vars;
Expand Down

0 comments on commit 56a96d4

Please sign in to comment.