Skip to content

Commit

Permalink
renaming OBJECT_MERGE_UNDEFINED -> OBJECT_MERGE_UNDEFINED_VALUE
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Jul 27, 2020
1 parent 607a12e commit 09f5012
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion files/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
const OBJECT_MERGE_OPT_MERGE_ARRAY_VALUES = 0x4;
const OBJECT_MERGE_OPT_NULL_AS_UNDEFINED = 0x8;

define('OBJECT_MERGE_UNDEFINED', uniqid('__OBJECT_MERGE_UNDEFINED_'));
define('OBJECT_MERGE_UNDEFINED_VALUE', uniqid('__OBJECT_MERGE_UNDEFINED_VALUE_'));
6 changes: 3 additions & 3 deletions files/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@

use DCarbone\ObjectMerge;

if (!function_exists('object_merge_value_undefined')) {
if (!function_exists('is_object_merge_undefined_value')) {
/**
* @param mixed $value
* @param int $opts
* @return bool
*/
function object_merge_value_undefined($value, $opts = 0)
function is_object_merge_undefined_value($value, $opts = 0)
{
if (null === $value && 0 !== ($opts & OBJECT_MERGE_OPT_NULL_AS_UNDEFINED)) {
return true;
}
return $value === OBJECT_MERGE_UNDEFINED;
return $value === OBJECT_MERGE_UNDEFINED_VALUE;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/ObjectMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ private static function _mergeArrayValues(array $leftValue, array $rightValue)
$rightDefined = array_key_exists($i, $rightValue);
$out[$i] = self::_mergeValues(
$i,
$leftDefined ? $leftValue[$i] : OBJECT_MERGE_UNDEFINED,
$rightDefined ? $rightValue[$i] : OBJECT_MERGE_UNDEFINED
$leftDefined ? $leftValue[$i] : OBJECT_MERGE_UNDEFINED_VALUE,
$rightDefined ? $rightValue[$i] : OBJECT_MERGE_UNDEFINED_VALUE
);
}
} else {
Expand Down Expand Up @@ -314,8 +314,8 @@ private static function _mergeObjectValues(stdClass $leftValue, stdClass $rightV
foreach (array_keys(get_object_vars($leftValue) + get_object_vars($rightValue)) as $key) {
$out->{$key} = self::_mergeValues(
$key,
property_exists($leftValue, $key) ? $leftValue->{$key} : OBJECT_MERGE_UNDEFINED,
property_exists($rightValue, $key) ? $rightValue->{$key} : OBJECT_MERGE_UNDEFINED
property_exists($leftValue, $key) ? $leftValue->{$key} : OBJECT_MERGE_UNDEFINED_VALUE,
property_exists($rightValue, $key) ? $rightValue->{$key} : OBJECT_MERGE_UNDEFINED_VALUE
);
}

Expand All @@ -340,7 +340,7 @@ private static function _mergeValues($key, $leftValue, $rightValue)
if (self::OBJECT_T === $resT) {
if ($res instanceof ObjectMergeResult && !$res->shouldContinue()) {
$finalValue = $res->getFinalValue();
if (OBJECT_MERGE_UNDEFINED !== $finalValue) {
if (OBJECT_MERGE_UNDEFINED_VALUE !== $finalValue) {
return $finalValue;
}
$leftValue = $res->getLeftValue();
Expand All @@ -351,8 +351,8 @@ private static function _mergeValues($key, $leftValue, $rightValue)
}
}

$leftUndefined = object_merge_value_undefined($leftValue, self::$_opts);
$rightUndefined = object_merge_value_undefined($rightValue, self::$_opts);
$leftUndefined = is_object_merge_undefined_value($leftValue, self::$_opts);
$rightUndefined = is_object_merge_undefined_value($rightValue, self::$_opts);

if ($leftUndefined && $rightUndefined) {
if (self::_optSet(OBJECT_MERGE_OPT_NULL_AS_UNDEFINED)) {
Expand Down
6 changes: 3 additions & 3 deletions src/ObjectMergeResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@ public function shouldContinue()
*/
public function getFinalValue()
{
return (isset($this->finalValue) || null === $this->finalValue) ? $this->finalValue : OBJECT_MERGE_UNDEFINED;
return (isset($this->finalValue) || null === $this->finalValue) ? $this->finalValue : OBJECT_MERGE_UNDEFINED_VALUE;
}

/**
* @return mixed
*/
public function getLeftValue()
{
return (isset($this->leftValue) || null === $this->leftValue) ? $this->leftValue : OBJECT_MERGE_UNDEFINED;
return (isset($this->leftValue) || null === $this->leftValue) ? $this->leftValue : OBJECT_MERGE_UNDEFINED_VALUE;
}

/**
* @return mixed
*/
public function getRightValue()
{
return (isset($this->rightValue) || null === $this->rightValue) ? $this->rightValue : OBJECT_MERGE_UNDEFINED;
return (isset($this->rightValue) || null === $this->rightValue) ? $this->rightValue : OBJECT_MERGE_UNDEFINED_VALUE;
}

/**
Expand Down

0 comments on commit 09f5012

Please sign in to comment.