From 09f5012d0cdcd49745060c2240b92d22cff158f7 Mon Sep 17 00:00:00 2001 From: Daniel Carbone Date: Mon, 27 Jul 2020 12:56:09 -0500 Subject: [PATCH] renaming OBJECT_MERGE_UNDEFINED -> OBJECT_MERGE_UNDEFINED_VALUE --- files/constants.php | 2 +- files/functions.php | 6 +++--- src/ObjectMerge.php | 14 +++++++------- src/ObjectMergeResult.php | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/files/constants.php b/files/constants.php index 6e607f3..f6e5473 100644 --- a/files/constants.php +++ b/files/constants.php @@ -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_')); \ No newline at end of file +define('OBJECT_MERGE_UNDEFINED_VALUE', uniqid('__OBJECT_MERGE_UNDEFINED_VALUE_')); \ No newline at end of file diff --git a/files/functions.php b/files/functions.php index cd7a9c8..df4a3c0 100644 --- a/files/functions.php +++ b/files/functions.php @@ -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; } } diff --git a/src/ObjectMerge.php b/src/ObjectMerge.php index 7fe9a69..4caf22e 100644 --- a/src/ObjectMerge.php +++ b/src/ObjectMerge.php @@ -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 { @@ -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 ); } @@ -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(); @@ -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)) { diff --git a/src/ObjectMergeResult.php b/src/ObjectMergeResult.php index 897ea84..d2c3bac 100644 --- a/src/ObjectMergeResult.php +++ b/src/ObjectMergeResult.php @@ -80,7 +80,7 @@ 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; } /** @@ -88,7 +88,7 @@ public function getFinalValue() */ 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; } /** @@ -96,7 +96,7 @@ public function getLeftValue() */ 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; } /**