Skip to content

Commit

Permalink
Remove unnecessary empty usages
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Apr 1, 2024
1 parent e5e14c8 commit 08a7843
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags
$dumpObjectAsInlineMap = true;

if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) {
$dumpObjectAsInlineMap = empty((array) $input);
$dumpObjectAsInlineMap = !(array) $input;
}

if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || empty($input)) {
if ($inline <= 0 || (!\is_array($input) && !$input instanceof TaggedValue && $dumpObjectAsInlineMap) || !$input) {
$output .= $prefix.Inline::dump($input, $flags);
} elseif ($input instanceof TaggedValue) {
$output .= $this->dumpTaggedValue($input, $inline, $indent, $flags, $prefix);
Expand Down Expand Up @@ -121,10 +121,10 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags
$dumpObjectAsInlineMap = true;

if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) {
$dumpObjectAsInlineMap = empty((array) $value);
$dumpObjectAsInlineMap = !(array) $value;
}

$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || empty($value);
$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || !$value;

$output .= sprintf('%s%s%s%s',
$prefix,
Expand Down
2 changes: 1 addition & 1 deletion Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private function doParse(string $value, int $flags): mixed
$data = $object;
}

return empty($data) ? null : $data;
return $data ?: null;
}

private function parseBlock(int $offset, string $yaml, int $flags): mixed
Expand Down

0 comments on commit 08a7843

Please sign in to comment.