/*!
\public
Returns diff engine of \a $type
960159
function initDiffEngine()
    {
        if ( !$diffEngine = $this->DiffEngineInstance )
        {
            switch( $this->DiffEngine )
            {
                case '0': //Text
                {
                    $this->DiffEngineInstance = new eZDiffTextEngine();
                }break;

                case '1': //XML
                {
                    $this->DiffEngineInstance = new eZDiffXMLTextEngine();
                }break;

                case '2': //ObjectContainer
                {
                    $this->DiffEngineInstance = new eZDiffContainerObjectEngine();
                }
            }
        }
    }
633558
private static function defaultCompareWrapper( $a, $b ) {
			if ( $a === $b ) {
				return 0;
			} else {

				if ( is_string( $a ) ) {
					return strcmp( $a, $b . '' );
				} else
				if ( is_int( $a ) || is_float( $b ) ) {
					return (float)$a - $b;
				} else 
				return -1;

			}
		}
886702
private static function from($type, $key, $default, &$source = null) {

    	if(null === $source) {

	    	if(static :: isMethod($type)) {

	    		$source = [];
	    		static :: parseRawHttpRequest($source);
	    	}
    	}

    	static :: $method = ['method' => $type, 'data' => &$source];

    	if(null !== $key) {
    		return static :: get($key, $default);
    	}

    	return $source;
    }
1187983
public function type($type)
    {
        if (is_string($type)) {
            $map = array(
                'double' => 1,
                'string' => 2,
                'object' => 3,
                'array' => 4,
                'binary' => 5,
                'undefined' => 6,
                'objectid' => 7,
                'boolean' => 8,
                'date' => 9,
                'null' => 10,
                'regex' => 11,
                'jscode' => 13,
                'symbol' => 14,
                'jscodewithscope' => 15,
                'integer32' => 16,
                'timestamp' => 17,
                'integer64' => 18,
                'maxkey' => 127,
                'minkey' => 255,
            );

            $type = isset($map[$type]) ? $map[$type] : $type;
        }

        return $this->operator('$type', $type);
    }
913586
function serializeTypeDef($type)
    {
        //print "in sTD() for type $type<br>";
        if ($typeDef = $this->getTypeDef($type)) {
            $str .= '<' . $type;
            if (is_array($typeDef['attrs'])) {
                foreach ($typeDef['attrs'] as $attName => $data) {
                    $str .= " $attName=\"{type = " . $data['type'] . "}\"";
                }
            }
            $str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
            if (count($typeDef['elements']) > 0) {
                $str .= ">";
                foreach ($typeDef['elements'] as $element => $eData) {
                    $str .= $this->serializeTypeDef($element);
                }
                $str .= "</$type>";
            } elseif ($typeDef['typeClass'] == 'element') {
                $str .= "></$type>";
            } else {
                $str .= "/>";
            }

            return $str;
        }

        return FALSE;
    }
830204
public function getDiff()
    {
        $diff = [];

        foreach ($this->getUpdated() as $key) {
            $diff[$key]['old'] = $this->old($key);

            $diff[$key]['new'] = $this->new($key);
        }

        return $diff;
    }
748943
function diff () {
  const files = getConfigFiles()

  debug('diff files: %o', files)

  const output = []

  files.forEach(f => {
    const result = jsDiff.structuredPatch(f[0].name, f[1].name, f[0].content, f[1].content)

    debug('diff result: %o', result)

    output.push('-------------------------------------------------\n')
    // eslint-disable-next-line max-len
    output.push(`diff ${chalk.blue(result.newFileName)} ${chalk.blue(result.oldFileName)}\n`)
    output.push('-------------------------------------------------\n')

    result.hunks.forEach(hunk => {
      fillLineNumber(hunk)

      const lines = hunk.lines.map(line => {
        if (line.startsWith('+')) {
          return chalk.green(line)
        }
        if (line.startsWith('-')) {
          return chalk.red(line)
        }
        return line
      })

      output.push(lines.join('\n'))
      output.push('\n')
    })

    output.push('\n')
  })

  console.log(output.join(''))
}
211238
function _parseKey($key, $type)
    {
        if ($type != self::PUBLIC_FORMAT_RAW && !is_string($key)) {
            return false;
        }

        switch ($type) {
            case self::PUBLIC_FORMAT_RAW:
                if (!is_array($key)) {
                    return false;
                }
                $components = array();
                switch (true) {
                    case isset($key['e']):
                        $components['publicExponent'] = $key['e']->copy();
                        break;
                    case isset($key['exponent']):
                        $components['publicExponent'] = $key['exponent']->copy();
                        break;
                    case isset($key['publicExponent']):
                        $components['publicExponent'] = $key['publicExponent']->copy();
                        break;
                    case isset($key[0]):
                        $components['publicExponent'] = $key[0]->copy();
                }
                switch (true) {
                    case isset($key['n']):
                        $components['modulus'] = $key['n']->copy();
                        break;
                    case isset($key['modulo']):
                        $components['modulus'] = $key['modulo']->copy();
                        break;
                    case isset($key['modulus']):
                        $components['modulus'] = $key['modulus']->copy();
                        break;
                    case isset($key[1]):
                        $components['modulus'] = $key[1]->copy();
                }
                return isset($components['modulus']) && isset($components['publicExponent']) ? $components : false;
            case self::PRIVATE_FORMAT_PKCS1:
            case self::PRIVATE_FORMAT_PKCS8:
            case self::PUBLIC_FORMAT_PKCS1:
                /* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is
                   "outside the scope" of PKCS#1.  PKCS#1 then refers you to PKCS#12 and PKCS#15 if you're wanting to
                   protect private keys, however, that's not what OpenSSL* does.  OpenSSL protects private keys by adding
                   two new "fields" to the key - DEK-Info and Proc-Type.  These fields are discussed here:

                   http://tools.ietf.org/html/rfc1421#section-4.6.1.1
                   http://tools.ietf.org/html/rfc1421#section-4.6.1.3

                   DES-EDE3-CBC as an algorithm, however, is not discussed anywhere, near as I can tell.
                   DES-CBC and DES-EDE are discussed in RFC1423, however, DES-EDE3-CBC isn't, nor is its key derivation
                   function.  As is, the definitive authority on this encoding scheme isn't the IETF but rather OpenSSL's
                   own implementation.  ie. the implementation *is* the standard and any bugs that may exist in that
                   implementation are part of the standard, as well.

                   * OpenSSL is the de facto standard.  It's utilized by OpenSSH and other projects */
                if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) {
                    $iv = pack('H*', trim($matches[2]));
                    $symkey = pack('H*', md5($this->password . substr($iv, 0, 8))); // symkey is short for symmetric key
                    $symkey.= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8)));
                    // remove the Proc-Type / DEK-Info sections as they're no longer needed
                    $key = preg_replace('#^(?:Proc-Type|DEK-Info): .*#m', '', $key);
                    $ciphertext = $this->_extractBER($key);
                    if ($ciphertext === false) {
                        $ciphertext = $key;
                    }
                    switch ($matches[1]) {
                        case 'AES-256-CBC':
                            $crypto = new AES();
                            break;
                        case 'AES-128-CBC':
                            $symkey = substr($symkey, 0, 16);
                            $crypto = new AES();
                            break;
                        case 'DES-EDE3-CFB':
                            $crypto = new TripleDES(Base::MODE_CFB);
                            break;
                        case 'DES-EDE3-CBC':
                            $symkey = substr($symkey, 0, 24);
                            $crypto = new TripleDES();
                            break;
                        case 'DES-CBC':
                            $crypto = new DES();
                            break;
                        default:
                            return false;
                    }
                    $crypto->setKey($symkey);
                    $crypto->setIV($iv);
                    $decoded = $crypto->decrypt($ciphertext);
                } else {
                    $decoded = $this->_extractBER($key);
                }

                if ($decoded !== false) {
                    $key = $decoded;
                }

                $components = array();

                if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) {
                    return false;
                }
                if ($this->_decodeLength($key) != strlen($key)) {
                    return false;
                }

                $tag = ord($this->_string_shift($key));
                /* intended for keys for which OpenSSL's asn1parse returns the following:

                    0:d=0  hl=4 l= 631 cons: SEQUENCE
                    4:d=1  hl=2 l=   1 prim:  INTEGER           :00
                    7:d=1  hl=2 l=  13 cons:  SEQUENCE
                    9:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
                   20:d=2  hl=2 l=   0 prim:   NULL
                   22:d=1  hl=4 l= 609 prim:  OCTET STRING

                   ie. PKCS8 keys*/

                if ($tag == self::ASN1_INTEGER && substr($key, 0, 3) == "\x01\x00\x30") {
                    $this->_string_shift($key, 3);
                    $tag = self::ASN1_SEQUENCE;
                }

                if ($tag == self::ASN1_SEQUENCE) {
                    $temp = $this->_string_shift($key, $this->_decodeLength($key));
                    if (ord($this->_string_shift($temp)) != self::ASN1_OBJECT) {
                        return false;
                    }
                    $length = $this->_decodeLength($temp);
                    switch ($this->_string_shift($temp, $length)) {
                        case "\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01": // rsaEncryption
                            break;
                        case "\x2a\x86\x48\x86\xf7\x0d\x01\x05\x03": // pbeWithMD5AndDES-CBC
                            /*
                               PBEParameter ::= SEQUENCE {
                                   salt OCTET STRING (SIZE(8)),
                                   iterationCount INTEGER }
                            */
                            if (ord($this->_string_shift($temp)) != self::ASN1_SEQUENCE) {
                                return false;
                            }
                            if ($this->_decodeLength($temp) != strlen($temp)) {
                                return false;
                            }
                            $this->_string_shift($temp); // assume it's an octet string
                            $salt = $this->_string_shift($temp, $this->_decodeLength($temp));
                            if (ord($this->_string_shift($temp)) != self::ASN1_INTEGER) {
                                return false;
                            }
                            $this->_decodeLength($temp);
                            list(, $iterationCount) = unpack('N', str_pad($temp, 4, chr(0), STR_PAD_LEFT));
                            $this->_string_shift($key); // assume it's an octet string
                            $length = $this->_decodeLength($key);
                            if (strlen($key) != $length) {
                                return false;
                            }

                            $crypto = new DES();
                            $crypto->setPassword($this->password, 'pbkdf1', 'md5', $salt, $iterationCount);
                            $key = $crypto->decrypt($key);
                            if ($key === false) {
                                return false;
                            }
                            return $this->_parseKey($key, self::PRIVATE_FORMAT_PKCS1);
                        default:
                            return false;
                    }
                    /* intended for keys for which OpenSSL's asn1parse returns the following:

                        0:d=0  hl=4 l= 290 cons: SEQUENCE
                        4:d=1  hl=2 l=  13 cons:  SEQUENCE
                        6:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption
                       17:d=2  hl=2 l=   0 prim:   NULL
                       19:d=1  hl=4 l= 271 prim:  BIT STRING */
                    $tag = ord($this->_string_shift($key)); // skip over the BIT STRING / OCTET STRING tag
                    $this->_decodeLength($key); // skip over the BIT STRING / OCTET STRING length
                    // "The initial octet shall encode, as an unsigned binary integer wtih bit 1 as the least significant bit, the number of
                    //  unused bits in the final subsequent octet. The number shall be in the range zero to seven."
                    //  -- http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf (section 8.6.2.2)
                    if ($tag == self::ASN1_BITSTRING) {
                        $this->_string_shift($key);
                    }
                    if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) {
                        return false;
                    }
                    if ($this->_decodeLength($key) != strlen($key)) {
                        return false;
                    }
                    $tag = ord($this->_string_shift($key));
                }
                if ($tag != self::ASN1_INTEGER) {
                    return false;
                }

                $length = $this->_decodeLength($key);
                $temp = $this->_string_shift($key, $length);
                if (strlen($temp) != 1 || ord($temp) > 2) {
                    $components['modulus'] = new BigInteger($temp, 256);
                    $this->_string_shift($key); // skip over self::ASN1_INTEGER
                    $length = $this->_decodeLength($key);
                    $components[$type == self::PUBLIC_FORMAT_PKCS1 ? 'publicExponent' : 'privateExponent'] = new BigInteger($this->_string_shift($key, $length), 256);

                    return $components;
                }
                if (ord($this->_string_shift($key)) != self::ASN1_INTEGER) {
                    return false;
                }
                $length = $this->_decodeLength($key);
                $components['modulus'] = new BigInteger($this->_string_shift($key, $length), 256);
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['publicExponent'] = new BigInteger($this->_string_shift($key, $length), 256);
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['privateExponent'] = new BigInteger($this->_string_shift($key, $length), 256);
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['primes'] = array(1 => new BigInteger($this->_string_shift($key, $length), 256));
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['primes'][] = new BigInteger($this->_string_shift($key, $length), 256);
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['exponents'] = array(1 => new BigInteger($this->_string_shift($key, $length), 256));
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['exponents'][] = new BigInteger($this->_string_shift($key, $length), 256);
                $this->_string_shift($key);
                $length = $this->_decodeLength($key);
                $components['coefficients'] = array(2 => new BigInteger($this->_string_shift($key, $length), 256));

                if (!empty($key)) {
                    if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) {
                        return false;
                    }
                    $this->_decodeLength($key);
                    while (!empty($key)) {
                        if (ord($this->_string_shift($key)) != self::ASN1_SEQUENCE) {
                            return false;
                        }
                        $this->_decodeLength($key);
                        $key = substr($key, 1);
                        $length = $this->_decodeLength($key);
                        $components['primes'][] = new BigInteger($this->_string_shift($key, $length), 256);
                        $this->_string_shift($key);
                        $length = $this->_decodeLength($key);
                        $components['exponents'][] = new BigInteger($this->_string_shift($key, $length), 256);
                        $this->_string_shift($key);
                        $length = $this->_decodeLength($key);
                        $components['coefficients'][] = new BigInteger($this->_string_shift($key, $length), 256);
                    }
                }

                return $components;
            case self::PUBLIC_FORMAT_OPENSSH:
                $parts = explode(' ', $key, 3);

                $key = isset($parts[1]) ? base64_decode($parts[1]) : false;
                if ($key === false) {
                    return false;
                }

                $comment = isset($parts[2]) ? $parts[2] : false;

                $cleanup = substr($key, 0, 11) == "\0\0\0\7ssh-rsa";

                if (strlen($key) <= 4) {
                    return false;
                }
                extract(unpack('Nlength', $this->_string_shift($key, 4)));
                $publicExponent = new BigInteger($this->_string_shift($key, $length), -256);
                if (strlen($key) <= 4) {
                    return false;
                }
                extract(unpack('Nlength', $this->_string_shift($key, 4)));
                $modulus = new BigInteger($this->_string_shift($key, $length), -256);

                if ($cleanup && strlen($key)) {
                    if (strlen($key) <= 4) {
                        return false;
                    }
                    extract(unpack('Nlength', $this->_string_shift($key, 4)));
                    $realModulus = new BigInteger($this->_string_shift($key, $length), -256);
                    return strlen($key) ? false : array(
                        'modulus' => $realModulus,
                        'publicExponent' => $modulus,
                        'comment' => $comment
                    );
                } else {
                    return strlen($key) ? false : array(
                        'modulus' => $modulus,
                        'publicExponent' => $publicExponent,
                        'comment' => $comment
                    );
                }
            // http://www.w3.org/TR/xmldsig-core/#sec-RSAKeyValue
            // http://en.wikipedia.org/wiki/XML_Signature
            case self::PRIVATE_FORMAT_XML:
            case self::PUBLIC_FORMAT_XML:
                $this->components = array();

                $xml = xml_parser_create('UTF-8');
                xml_set_object($xml, $this);
                xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler');
                xml_set_character_data_handler($xml, '_data_handler');
                // add <xml></xml> to account for "dangling" tags like <BitStrength>...</BitStrength> that are sometimes added
                if (!xml_parse($xml, '<xml>' . $key . '</xml>')) {
                    return false;
                }

                return isset($this->components['modulus']) && isset($this->components['publicExponent']) ? $this->components : false;
            // from PuTTY's SSHPUBK.C
            case self::PRIVATE_FORMAT_PUTTY:
                $components = array();
                $key = preg_split('#\r\n|\r|\n#', $key);
                $type = trim(preg_replace('#PuTTY-User-Key-File-2: (.+)#', '$1', $key[0]));
                if ($type != 'ssh-rsa') {
                    return false;
                }
                $encryption = trim(preg_replace('#Encryption: (.+)#', '$1', $key[1]));
                $comment = trim(preg_replace('#Comment: (.+)#', '$1', $key[2]));

                $publicLength = trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3]));
                $public = base64_decode(implode('', array_map('trim', array_slice($key, 4, $publicLength))));
                $public = substr($public, 11);
                extract(unpack('Nlength', $this->_string_shift($public, 4)));
                $components['publicExponent'] = new BigInteger($this->_string_shift($public, $length), -256);
                extract(unpack('Nlength', $this->_string_shift($public, 4)));
                $components['modulus'] = new BigInteger($this->_string_shift($public, $length), -256);

                $privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$publicLength + 4]));
                $private = base64_decode(implode('', array_map('trim', array_slice($key, $publicLength + 5, $privateLength))));

                switch ($encryption) {
                    case 'aes256-cbc':
                        $symkey = '';
                        $sequence = 0;
                        while (strlen($symkey) < 32) {
                            $temp = pack('Na*', $sequence++, $this->password);
                            $symkey.= pack('H*', sha1($temp));
                        }
                        $symkey = substr($symkey, 0, 32);
                        $crypto = new AES();
                }

                if ($encryption != 'none') {
                    $crypto->setKey($symkey);
                    $crypto->disablePadding();
                    $private = $crypto->decrypt($private);
                    if ($private === false) {
                        return false;
                    }
                }

                extract(unpack('Nlength', $this->_string_shift($private, 4)));
                if (strlen($private) < $length) {
                    return false;
                }
                $components['privateExponent'] = new BigInteger($this->_string_shift($private, $length), -256);
                extract(unpack('Nlength', $this->_string_shift($private, 4)));
                if (strlen($private) < $length) {
                    return false;
                }
                $components['primes'] = array(1 => new BigInteger($this->_string_shift($private, $length), -256));
                extract(unpack('Nlength', $this->_string_shift($private, 4)));
                if (strlen($private) < $length) {
                    return false;
                }
                $components['primes'][] = new BigInteger($this->_string_shift($private, $length), -256);

                $temp = $components['primes'][1]->subtract($this->one);
                $components['exponents'] = array(1 => $components['publicExponent']->modInverse($temp));
                $temp = $components['primes'][2]->subtract($this->one);
                $components['exponents'][] = $components['publicExponent']->modInverse($temp);

                extract(unpack('Nlength', $this->_string_shift($private, 4)));
                if (strlen($private) < $length) {
                    return false;
                }
                $components['coefficients'] = array(2 => new BigInteger($this->_string_shift($private, $length), -256));

                return $components;
        }
    }
370554
private function convert($type, $reverse = false)
    {
        $replace = array_merge(
            $this->getJpgReplace(),
            $this->getBmpReplace()
        );

        if ( $reverse ) {
            $replace = array_flip($replace);
        }

        return str_replace(array_keys($replace), array_values($replace), $type);
    }
1268806
public static function find($type = self::TYPE_PRIVATEKEY, $dir = null)
    {
        $dir = $dir ?: self::findUserDir().'/.ssh';
        if (0 === strpos($dir, '~')) {
            $dir = self::findUserDir() . substr($dir, 1);
        }

        $iterator = Finder::create()
            ->files()
            ->name('id_?sa'.($type == self::TYPE_PUBLICKEY ? '.pub' : ''))
            ->depth(0)
            ->in($dir)
        ;

        foreach ($iterator as $file) {
            return $file->getPathName();
        }

        return null;
    }
463282
public function visitResourceType(ResourceType $type)
    {
        $difference = $this->comparePrimaryType($type);

        if (0 !== $difference) {
            return $difference;
        }

        return $this->compareAttribute($this->type->ofType(), $type->ofType());
    }
250460
private function getTypeSuffix($type)
    {
        self::$TYP_MAPPING = array_merge(self::$TYP_COMPLEX_MAPPING, self::$TYP_SIMPLE_MAPPING);

        if ($type == '') {
            return '';
        }

        if (!isset(self::$TYP_MAPPING[$this->type])) {
            return '';
        }

        return self::$TYP_MAPPING[$this->type];
    }
959291
public function get($type)
    {
        if (!isset($this->instances[$type])) {
            $this->instances[$type] = $this->loadFile($type);
        }

        return $this->instances[$type];
    }
1268947
static function diff($traversable, $traversable2) 
    {
        return static::filter($traversable, function($value) use ($traversable2) {
            return ! Collection::contains($traversable2, $value);
        });
    }
242191
function diffKeys($arr) {
        if($arr instanceof self) {
            $arr = $arr->all();
        }
        
        return (new self(\array_diff_key($this->data, $arr)));
    }
1325547
function Compare( $a, $b )
	{
		if ( $a instanceof UntypedAtomic || $a instanceof AnyUriValue )
		{
			$a = $a->ToString();
		}

		if ( $b instanceof UntypedAtomic || $b instanceof AnyUriValue )
		{
			$b = $b->ToString();
		}

		if ( is_float( $a ) && is_nan( $a ) && is_float( $b ) && is_nan( $b )  )
		{
			return 0;
		}

		if ( ! is_null( $this->collation ) && is_string( $a ) && is_string( $b ) )
		{
			if ( $this->collation == "http://www.w3.org/2005/xpath-functions/collation/codepoint" )
			{
				$a = \normalizer_normalize( $a, \Normalizer::FORM_C );
				$b = \normalizer_normalize( $b, \Normalizer::FORM_C );

				return strcmp( $a, $b );
			}
			else
			{
				return strcoll( $a, $b ) == 0;
			}
		}

		if ( true )
		{
			$aTypeCode = $a instanceof XPath2Item ? $a->getSchemaType()->TypeCode : ( is_string( $a ) ? XmlTypeCode::String : XmlTypeCode::AnyAtomicType );
			$bTypeCode = $b instanceof XPath2Item ? $b->getSchemaType()->TypeCode : ( is_string( $b ) ? XmlTypeCode::String : XmlTypeCode::AnyAtomicType );
			$numericTypes =& DistinctComparer::$numericTypes;
			$durationTypes =& DistinctComparer::$durationTypes;

			if ( $aTypeCode != $bTypeCode )
			{
				// Handle the exceptions
				$exceptions = (
					( $aTypeCode == XmlTypeCode::Integer && in_array( $bTypeCode, $numericTypes ) ) ||
				 	( $bTypeCode == XmlTypeCode::Integer && in_array( $aTypeCode, $numericTypes ) ) ||
					( $aTypeCode == XmlTypeCode::Decimal && in_array( $bTypeCode, $numericTypes ) ) ||
					( $bTypeCode == XmlTypeCode::Decimal && in_array( $aTypeCode, $numericTypes ) ) ||
					( $aTypeCode == XmlTypeCode::Double && in_array( $bTypeCode, $numericTypes ) ) ||
					( $bTypeCode == XmlTypeCode::Double && in_array( $aTypeCode, $numericTypes ) ) ||
					( $aTypeCode == XmlTypeCode::Float && in_array( $bTypeCode, $numericTypes ) ) ||
					( $bTypeCode == XmlTypeCode::Float && in_array( $aTypeCode, $numericTypes ) ) ||

					( $aTypeCode == XmlTypeCode::YearMonthDuration && in_array( $bTypeCode, $durationTypes ) ) ||
					( $bTypeCode == XmlTypeCode::YearMonthDuration && in_array( $aTypeCode, $durationTypes ) ) ||
					( $aTypeCode == XmlTypeCode::DayTimeDuration && in_array( $bTypeCode, $durationTypes ) ) ||
					( $bTypeCode == XmlTypeCode::DayTimeDuration && in_array( $aTypeCode, $durationTypes ) )
				);
				if ( ! $exceptions )
				{
					return 1;
				}
			}

			// Check for NaN in numeric XPath2Item
			if ( in_array( $aTypeCode, $numericTypes ) && in_array( $bTypeCode, $numericTypes ) )
			{
				$aValue = $a->getTypedValue();
				$bValue = $b->getTypedValue();

				if ( ! is_object( $aValue ) && ! is_object( $bValue ) && is_nan( $aValue ) && is_nan( $bValue ) )
				{
					return 0;
				}
			}

			if ( in_array( $aTypeCode, $durationTypes ) && in_array( $bTypeCode, $durationTypes ) )
			{
				$a = $a->getTypedValue();
				$b = $b->getTypedValue();
			}
		}

		if ( ! is_object( $a ) && ! is_object( $b ) )
		{
			if ( $a == $b )
			{
				return 0;
			}
		}
		else if ( is_object( $a ) && is_object( $b ) && method_exists( $a, "Equals" ) && method_exists( $b, "Equals" ) )
		{
			if ( $a->Equals( $b ) )
			{
				return 0;
			}
		}

		$res;
		if ( ValueProxy::EqValues( $a, $b, $res ) && $res )
    		return 0;

		if ( ValueProxy::GtValues( $a, $b, $res ) && $res )
			return 1;

		return -1;
	}
71213
public function getNodeVersion($type)
    {
        if ($type == 'public') {
            return $this->publicNodeVersion;
        }

        $nodeVersions = $this->getNodeVersions();

        $max = count($nodeVersions);
        for ($i = $max - 1; $i >= 0; --$i) {
            /* @var NodeVersion $nodeVersion */
            $nodeVersion = $nodeVersions[$i];

            if ($type == $nodeVersion->getType()) {
                return $nodeVersion;
            }
        }

        return null;
    }