验证字段值是否是一个 int list(key是从0自然增长的, val是数字)
@param array|mixed $val
@return bool
504727
public static function intList($val): bool
    {
        if (!\is_array($val) || !isset($val[0])) {
            return false;
        }

        $lastK = -1;

        /** @var array $val */
        foreach ($val as $k => $v) {
            if (!\is_int($k) || $k !== $lastK + 1) {
                return false;
            }

            if (!\is_numeric($v)) {
                return false;
            }

            $lastK = $k;
        }

        return true;
    }
480842
protected function validValue(&$val)
    {
        if (!is_array($val)) {
            return $val == null || is_scalar($val) || $val instanceof JsonSerializable;
        }

        foreach ($val as $k => $v) {
            if (!$this->validValue($v)) {
                $val[$k] = null;
            } else {
                $val[$k] = $v;
            }
        }
        return true;
    }
213118
public static function boolean($val): bool
    {
        if (!\is_scalar($val)) {
            return false;
        }

        // $ret = filter_var($val, \FILTER_VALIDATE_BOOLEAN, $settings);
        if (($val = (string)$val) === '') {
            return true;
        }

        return false !== \stripos(Helper::IS_BOOL, '|' . $val . '|');
    }
831330
private static function mapNum($val, $key)
        {
            $except = array (
                '1',
                 '2',
                 '3',
                 '4',
                 '5',
                 'e',
                 'f',
                 'g',
                 'h',
                 'i',
                 'k',
                 'l',
                 'n',
                 'o',
                 'r',
                 's',
                 't',
                 'u',
                 'w',
                 'x',
                 'y',
                 'z'
            );

            $num = array_search($val, $except);
            $num *= pow (22, - ($key + 1));

            return $num;
        }
1071884
public static function isPrime($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        if (
            ($val<=1) ||
            ($val>2 && ($val%2)===0)
        ) {
            return false;
        }
        for ($i=2;$i<$val;$i++) {
            if (($val%$i)===0) {
                return false;
            }
        }
        return true;
    }
951211
public function isSelected($val)
    {
        if ($this->isMulti()) {
            return in_array($val, $this->getValue());
        } else {
            return $val === $this->getValue();
        }
    }
839071
function update( $key, $val = false ) {
			if ( ! is_array( $key ) ) {
				$key = array( $key => $val );
			}

			$is_updated = false;

			foreach ( $key as $k => $v ) {
				if ( $this->{$k} === $v ) {
					continue;
				}

				if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
				       ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
				     $this->{$k} == $v
				) {
					continue;
				}

				// Update value.
				$this->{$k} = $v;

				$is_updated = true;
			}

			$this->_is_updated = $is_updated;

			return $is_updated;
		}
1169307
public static function getLuhnKey($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $val = $val.'0';
        $length = strlen($val);
        $checksum = 0;
        for ($i=($length - 1); $i>=0; $i--) { 
            $digit = $val[$i];
            if ((($length - $i) % 2) == 0) {
                $digit = $digit * 2;
                if ($digit > 9) {
                    $digit = $digit - 9;
                }
            }
            $checksum += $digit;
        }
        $luhn_key = 10 - ( $checksum % 10 );
        if ($luhn_key == 10) {
            $luhn_key = 0;
        }
        return $luhn_key;
    }
545486
public function dataToBinary($val)
    {
        $saved_object_count = $this->writtenObjectCount++;

        $bdata = self::typeBytes("4", strlen($val)); // a is 1000, type indicator for data
        $this->objectTable[$saved_object_count] = $bdata.$val;

        return $saved_object_count;
    }
273800
public static function isLuhn($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $_num = substr($val, 0, strlen($val)-1);
        return (bool) (intval($val) == intval($_num.self::getLuhnKey($_num)));
    }
608659
public static function isList($array)
    {
        if( !is_array( $array ) )
            return false;

        // using Stripe's library as a base for this was a cluster fuck of an idea.
        // why? figure this out:
        $keys = array_keys( $array );
        foreach( array_keys( $array ) as $i )
            if( !is_numeric( $i ) )
                return false;

        return true;
    }
24602
protected function IDiv( $val )
	{
		return Integer::FromValue( floor( Convert::ToInt( $this->_value /  Convert::ToInt16( $val->getValue() ) ) ) );
	}
969459
protected function isValidTranslation($val)
    {
        if (empty($val) && !is_numeric($val)) {
            return false;
        }

        if (is_string($val)) {
            return !empty(trim($val));
        }

        if ($val instanceof Translation) {
            return true;
        }

        if (is_array($val)) {
            return !!array_filter(
                $val,
                function ($v, $k) {
                    if (is_string($k) && strlen($k) > 0) {
                        if (is_string($v) && strlen($v) > 0) {
                            return true;
                        }
                    }

                    return false;
                },
                ARRAY_FILTER_USE_BOTH
            );
        }
        return false;
    }
850307
public function contains($val,$key='_id') {
		$rel_ids = $this->getAll($key, true);
		if ($val instanceof Cursor)
			$val = $val->{$key};
		return in_array($val,$rel_ids);
	}
559662
public static function max($val, $max)
	{
	    if (is_array($max)) {
	        if (!isset($max['max'])) {
	            throw new \InvalidArgumentException('The $max argument must have "max" key');
	        }
	        $max = $max['max'];
	    }

	    return $val <= $max;
	}
128068
public static function isSelfDescribing($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $val = (string) $val;
        for ($i=0; $i<strlen($val); $i++) {
            $_val   = $val{$i};
            $occ    = substr_count($val, $i);
            if ($_val != $occ) {
                return false;
            }
        }
        return true;
    }
49673
public static function set($key, $val)
    {
        if( ! is_string($key)) {
            return;
        }
        $key = strtoupper($key);
        if ( ! strpos($key, '.')) {
            self::$config[$key] = $val;
        } else {
            // 试图获取二维数组值
            $d = explode('.', $key);
            $d1 = array_shift($d);
            $d2 = implode('.', $d);

            if (is_array(self::$config[$d1]) || ! isset(self::$config[$d1])) {
                self::$config[$d1][$d2] = $val;
            }
        }
    }