Validates if the input is equal some value.

@param string $value
@param        $comparedValue
@param bool   $identical

@return bool
496090
public static function equals($value, $comparedValue, $identical = false)
    {
        if (false === $identical) {
            return $value == $comparedValue;
        }

        return $value === $comparedValue;
    }
995165
public static boolean equal(SoyValue operand0, SoyValue operand1) {
    // Treat the case where either is a string specially.
    // TODO(gboyer): This should probably handle SanitizedContent == SanitizedContent, even though
    // Javascript doesn't handle that case properly. http://b/21461181
    if (operand0 instanceof StringData || operand0 instanceof UnsanitizedString) {
      return compareString(operand0.stringValue(), operand1);
    }
    if (operand1 instanceof StringData || operand1 instanceof UnsanitizedString) {
      return compareString(operand1.stringValue(), operand0);
    }
    return Objects.equals(operand0, operand1);
  }
300845
public function matches($value): bool
    {
        $left = $this->value;
        $right = $value;

        if ($this->useSubstitution) {
            if ($left instanceof IterableSpy) {
                $left = $left->iterable();
            } elseif (
                $left instanceof Generator &&
                isset($left->_phonySubject)
            ) {
                $left = $left->_phonySubject;
            } elseif ($left instanceof InstanceHandle) {
                $left = $left->get();
            }

            if ($right instanceof IterableSpy) {
                $right = $right->iterable();
            } elseif (
                $right instanceof Generator &&
                isset($right->_phonySubject)
            ) {
                $right = $right->_phonySubject;
            } elseif ($right instanceof InstanceHandle) {
                $right = $right->get();
            }
        }

        /*
         * @var array<string,bool> The set of object comparisons that have been made.
         *
         * Keys are of the format "<left spl hash>:<right spl hash>"; values are
         * always TRUE. This set is used to detect comparisons that have already
         * been made in order to avoid infinite recursion when comparing cyclic
         * data structures.
         */
        $visitedObjects = [];

        /*
         * @var array<string,bool> The set of array comparisons that have been made.
         *
         * Keys are of the format "<left id>:<right id>"; values are always
         * TRUE. This set is used to detect comparisons that have already been
         * made in order to avoid infinite recursion when comparing cyclic data
         * structures.
         */
        $visitedArrays = [];

        /*
         * @var array<&array> Arrays that have been marked with an internal ID.
         *
         * In order to detect cyclic arrays we need to mark them with an ID.
         * This ID must be removed upon completion of the comparison.
         */
        $markedArrays = [];

        /*
         * @var array<&array> Stacks of values that are currently being compared.
         *
         * We maintain our own stack in order to:
         *
         *  - make fewer function calls (much faster in PHP 5.*)
         *  - avoid stack-depth limits
         *  - allow for 'continuations'
         *  - avoid unwinding when comparison fails
         *
         * Separate stacks are used for left/right to avoid construction of
         * temporary arrays.
         */
        $leftStack = [];
        $rightStack = [];

        /*
         * @var int The number of elements on the stacks.
         */
        $stackSize = 0;

        // ---------------------------------------------------------
        // This is the main entry point of the comparison algorithm.
        // ---------------------------------------------------------
        compare:

        if (is_array($left) && is_array($right)) {

            // Fetch or generate a unique ID for the left-hand-side.
            if (isset($left[self::ARRAY_ID_KEY])) {
                $leftId = $left[self::ARRAY_ID_KEY];
            } else {
                reset($left);
                $leftId = count($markedArrays) + 1;
                $left[self::ARRAY_ID_KEY] = $leftId;
                $markedArrays[] = &$left;
            }

            // Fetch or generate a unique ID for the right-hand-side.
            if (isset($right[self::ARRAY_ID_KEY])) {
                $rightId = $right[self::ARRAY_ID_KEY];
            } else {
                reset($right);
                $rightId = count($markedArrays) + 1;
                $right[self::ARRAY_ID_KEY] = $rightId;
                $markedArrays[] = &$right;
            }

            // Left and right are references to the same array.
            if ($leftId === $rightId) {
                goto pass;
            }

            $comparisonId = $leftId . ':' . $rightId;

            // These two arrays have already been compared.
            if (isset($visitedArrays[$comparisonId])) {
                goto pass;
            }

            // Record the comparison.
            $visitedArrays[$comparisonId] = true;

            // ---------------------------------
            // Compare the next array key/value.
            // ---------------------------------
            compareNextArrayElement:

            // Get the current key for each array, skipping our internal ID
            // value.
            $leftKey = key($left);
            next($left);

            if ($leftKey === self::ARRAY_ID_KEY) {
                $leftKey = key($left);
                next($left);
            }

            $rightKey = key($right);
            next($right);

            if ($rightKey === self::ARRAY_ID_KEY) {
                $rightKey = key($right);
                next($right);
            }

            // Keys can only be string|int (or null, if end of array).
            // Compare them using regular PHP comparison.
            if ($leftKey !== $rightKey) {
                return false;

            // Both keys are null, which means that both array are the same
            // length.
            } elseif (null === $leftKey) {
                goto pass;
            }

            // Push the arrays we're comparing on to the stack and start
            // comparing the values of this element.
            $leftStack[$stackSize] = &$left;
            $rightStack[$stackSize] = &$right;
            ++$stackSize;

            $left = &$left[$leftKey];
            $right = &$right[$rightKey];

            goto compare;
        }

        // Objects and other non-arrays can be compared with ===, as it will
        // not recurse in either case.
        if ($left === $right) {
            goto pass;
        }

        // Non-objects are not identical.
        if (!is_object($left) || !is_object($right)) {
            return false;
        }

        $leftClass = get_class($left);
        $rightClass = get_class($right);

        // The class names do not match.
        if ($leftClass !== $rightClass) {
            return false;
        }

        $comparisonId = spl_object_hash($left) . ':' . spl_object_hash($right);

        // These two objects have already been compared.
        if (isset($visitedObjects[$comparisonId])) {
            goto pass;
        }

        // Record the comparison.
        $visitedObjects[$comparisonId] = true;

        /*
         * Cast the objects as arrays and start comparing them.
         *
         * Importantly, the array cast operator maintains private and protected
         * properties, as well as arbitrary properties added to the object after
         * construction.
         *
         * Some special properties are removed for the purposes of comparison.
         *
         * @see https://github.com/php/php-src/commit/5721132
         */

        $leftIsMock = $left instanceof Mock;
        $leftIsException = $left instanceof Throwable;

        $left = (array) $left;
        unset($left["\0gcdata"]);

        if ($leftIsMock) {
            $handleProperty = "\0" . $leftClass . "\0_handle";

            if ($left[$handleProperty]) {
                $left['phony.label'] = $left[$handleProperty]->label();
            }

            unset($left[$handleProperty]);
        }

        if ($leftIsException) {
            unset(
                $left["\0*\0file"],
                $left["\0*\0line"],
                $left["\0Exception\0trace"],
                $left["\0Exception\0string"],
                $left['xdebug_message']
            );
        }

        $rightIsMock = $right instanceof Mock;
        $rightIsException = $right instanceof Throwable;

        $right = (array) $right;
        unset($right["\0gcdata"]);

        if ($rightIsMock) {
            $handleProperty = "\0" . $rightClass . "\0_handle";

            if ($right[$handleProperty]) {
                $right['phony.label'] = $right[$handleProperty]->label();
            }

            unset($right[$handleProperty]);
        }

        if ($rightIsException) {
            unset(
                $right["\0*\0file"],
                $right["\0*\0line"],
                $right["\0Exception\0trace"],
                $right["\0Exception\0string"],
                $right['xdebug_message']
            );
        }

        goto compareNextArrayElement;

        // -----------------------------
        // The current values are equal!
        // -----------------------------
        pass:

        // The stack is not empty, pop some values and compare again.
        if ($stackSize--) {
            $left = &$leftStack[$stackSize];
            $right = &$rightStack[$stackSize];

            goto compareNextArrayElement;
        }

        // Stack is empty, there's nothing left to compare. Clean up the
        // injected array IDs and return
        foreach ($markedArrays as &$array) {
            unset($array[self::ARRAY_ID_KEY]);
        }

        return true;
    }
1275178
public static function areEqual($value1, $value2) : bool
    {
        return $value1 === $value2 || self::hash($value1) === self::hash($value2);
    }
219400
def validate_equal(value):
    
    def equal_validator(field, data):
        if field.value is None:
            return
        if not (field.value == value):
            raise ValidationError('equal', other=value)
    return equal_validator
887063
public static function determineComparison($value)
    {
        switch (true) {
            case is_scalar($value): {
                return static::EQ;
            }
            case is_array($value): {
                return static::IN;
            }
            case null === $value: {
                return static::IS_NULL;
            }
            default: {
                return static::RAW;
            }
        }
    }
1299612
public function validate(string $value)
    {
        if (!$value || $this->value === $value) {
            return;
        }

        $this->error['match'] = [$this->value];
    }
1087851
public static function in($value, $haystack, $identical = false)
    {
        $haystack = (string) $haystack;
        $enc      = \mb_detect_encoding($value);

        if (false === $identical) {
            return (false !== \mb_stripos($haystack, $value, 0, $enc));
        }

        return (false !== \mb_strpos($haystack, $value, 0, $enc));
    }
1255022
public static function compare($compare1, $operator, $compare2, $strict = false)
    {
        $operator = trim(strtolower($operator));

        switch ($operator) {
            case '=':
            case '==':
            case 'eq':
                return $strict ? $compare1 === $compare2 : $compare1 == $compare2;
                break;

            case '===':
                return $compare1 === $compare2;
                break;

            case '!=':
            case 'neq':
                return $strict ? $compare1 !== $compare2 : $compare1 != $compare2;
                break;

            case '!==':
                return $compare1 !== $compare2;
                break;

            case '>':
            case 'gt':
                return $compare1 > $compare2;
                break;

            case '>=':
            case 'gte':
                return $compare1 >= $compare2;
                break;

            case '<':
            case 'lt':
                return $compare1 < $compare2;
                break;

            case '<=':
            case 'lte':
                return $compare1 <= $compare2;
                break;

            case 'in':
                return in_array($compare1, static::toArray($compare2), $strict);
                break;

            case 'not in':
            case 'not-in':
            case 'notin':
            case 'nin':
                return !in_array($compare1, static::toArray($compare2), $strict);
                break;

            default:
                throw new \InvalidArgumentException('Invalid compare operator: ' . $operator);
        }
    }
1173000
function it_can_be_compared_to_other_template_fragments($sameValue, $differentValue, $differentType)
    {
        $sameValue->getValueMask()->willReturn(['1', '2']);
        $sameValue->getTypeMask()->willReturn('[..]');

        $this->equals($sameValue)->shouldReturn(true);

        $differentValue->getValueMask()->willReturn(['3', '4']);
        $differentValue->getTypeMask()->willReturn('[..]');

        $this->equals($differentValue)->shouldReturn(false);

        $differentType->getValueMask()->willReturn(['1', '2']);
        $differentType->getTypeMask()->willReturn('[##]');

        $this->equals($differentType)->shouldReturn(false);
    }
453187
public static Object validateEqual(Object t1, Object t2, String errorMsg) throws ValidateException {
		if (false == equal(t1, t2)) {
			throw new ValidateException(errorMsg);
		}
		return t1;
	}
861765
public static function equals($value, $required, $strict = false)
    {
        return Validator::equals($value, $strict)->validate($required);
    }
1012287
public function neqFieldValidator($val, string $compareField): bool
    {
        return $compareField && ($val !== $this->getByPath($compareField));
    }
842250
public function equals($compare): bool
    {
        if ($compare instanceof self) {
            return ($this->timestamp() === $compare->timestamp());
        }

        return false;
    }
987942
public function gtFieldValidator($val, string $compareField): bool
    {
        $minVal = $this->getByPath($compareField);

        if ($minVal === null) {
            return false;
        }

        return Validators::gt($val, $minVal);
    }
59693
public function equalsIgnoreCase($value) {
        if ($value instanceof StringClass) {
            $value = $value->getValue();
        }
        if (!is_string($value)) return false;
            return strcasecmp($this->value, $value) === 0;
    }
863714
public static function isEqual($value1, $value2, $roundPrecision = 0)
    {
        $equal = false;

        if (static::floor($value1, $roundPrecision) == static::floor($value2, $roundPrecision)) {
            $equal = true;
        }

        return $equal;
    }