Returns a callback that checks the values types depending on the operator specifications.

@param int $valueTypes The accepted values, as a bit field of Specifications::TYPE_* constants

@return \Closure
509108
private function getValueTypeCheckCallback($valueTypes)
    {
        $callback = function ($value) {
            return false;
        };

        // the callback code will return true as soon as an accepted value type is found
        if ($valueTypes & Specifications::TYPE_INTEGER) {
            $callback = function ($value) use ($callback) {
                return is_numeric($value) || $callback($value);
            };
        }
        if ($valueTypes & Specifications::TYPE_STRING) {
            $callback = function ($value) use ($callback) {
                return is_string($value) || $callback($value);
            };
        }
        if ($valueTypes & Specifications::TYPE_BOOLEAN) {
            $callback = function ($value) use ($callback) {
                return is_bool($value) || $callback($value);
            };
        }

        return $callback;
    }
1276692
protected function getTypedValue ($rawValue) {
		if (gettype($rawValue) == "array") {
			foreach ($rawValue as $key => $value) {
				$rawValue[$key] = $this->getTypedValue($value);
			}
			return $rawValue; // array
		} else if (mb_strlen($rawValue) > 0) {
			if (is_numeric($rawValue)) {
				return $this->getTypedValueFloatOrInt($rawValue);
			} else {
				return $this->getTypedSpecialValueOrString($rawValue);
			}
		} else {
			return $this->getTypedSpecialValueOrString($rawValue);
		}
	}
398813
private function prepareValues($values, callable $valueCallable = null)
    {
        if (is_array($values)) {
            foreach ($values as &$value) {
                if ($valueCallable) {
                    $value = call_user_func_array($valueCallable, [(string) $value]);
                }

                $value = (string) $value;
            }
            unset($value);

            $values = array_values($values);
        } else {
            if ($valueCallable) {
                $values = call_user_func_array($valueCallable, [(string) $values]);
            }

            $values = (string) $values;
        }

        return $values;
    }
521047
public function values($values) {
        ValuesImpl::values($this->context, $values);
        return new ExecRule($this->context);
    }
1022116
public function valufy($values)
    {
        // we'll only deal with arrays so let's turn it into one if it isn't
        if ( ! is_array($values)) $values = [$values];

        // escape and wrap them with a quote.
        $values = array_map(function ($value)
        {
            // We need to keep the data type of values
            // except when they're strings, we need to
            // escape wrap them.
            if (is_string($value))
            {
                $value = "'" . addslashes($value) . "'";
            }
            // In order to support boolean value types and not have PHP convert them to their
            // corresponding string values, we'll have to handle boolean values and add their literal string representation.
            elseif (is_bool($value))
            {
                $value = ($value) ? 'true' : 'false';
            }

            return $value;

        }, $values);

        // stringify them.
        return implode(', ', $values);
    }
1170154
public function argTypes($types) {
		is_array($types) ? $this->argumentTypes = $types : $this->argumentTypes = func_get_args();
		return $this;
	}
205855
public static function to($type, $value, $pseudoTypes = null)
    {
        switch ($type) {
            case 'any':
                $returnValue = $value;
                break;
            case 'boolean':
                $returnValue = BooleanType::toBoolean($value);
                break;
            case '[EnforceRange] byte':
                $returnValue = IntegerType::toByte($value, '[EnforceRange]');
                break;
            case '[Clamp] byte':
                $returnValue = IntegerType::toByte($value, '[Clamp]');
                break;
            case 'byte':
                $returnValue = IntegerType::toByte($value);
                break;
            case '[EnforceRange] octet':
                $returnValue = IntegerType::toOctet($value, '[EnforceRange]');
                break;
            case '[Clamp] octet':
                $returnValue = IntegerType::toOctet($value, '[Clamp]');
                break;
            case 'octet':
                $returnValue = IntegerType::toOctet($value);
                break;
            case '[EnforceRange] short':
                $returnValue = IntegerType::toShort($value, '[EnforceRange]');
                break;
            case '[Clamp] short':
                $returnValue = IntegerType::toShort($value, '[Clamp]');
                break;
            case 'short':
                $returnValue = IntegerType::toShort($value);
                break;
            case '[EnforceRange] unsigned short':
                $returnValue = IntegerType::toUnsignedShort($value, '[EnforceRange]');
                break;
            case '[Clamp] unsigned short':
                $returnValue = IntegerType::toUnsignedShort($value, '[Clamp]');
                break;
            case 'unsigned short':
                $returnValue = IntegerType::toUnsignedShort($value);
                break;
            case '[EnforceRange] long':
                $returnValue = IntegerType::toLong($value, '[EnforceRange]');
                break;
            case '[Clamp] long':
                $returnValue = IntegerType::toLong($value, '[Clamp]');
                break;
            case 'long':
                $returnValue = IntegerType::toLong($value);
                break;
            case '[EnforceRange] unsigned long':
                $returnValue = IntegerType::toUnsignedLong($value, '[EnforceRange]');
                break;
            case '[Clamp] unsigned long':
                $returnValue = IntegerType::toUnsignedLong($value, '[Clamp]');
                break;
            case 'unsigned long':
                $returnValue = IntegerType::toUnsignedLong($value);
                break;
            case '[EnforceRange] long long':
                $returnValue = IntegerType::toLongLong($value, '[EnforceRange]');
                break;
            case '[Clamp] long long':
                $returnValue = IntegerType::toLongLong($value, '[Clamp]');
                break;
            case 'long long':
                $returnValue = IntegerType::toLongLong($value);
                break;
            case '[EnforceRange] unsigned long long':
                $returnValue = IntegerType::toUnsignedLongLong($value, '[EnforceRange]');
                break;
            case '[Clamp] unsigned long long':
                $returnValue = IntegerType::toUnsignedLongLong($value, '[Clamp]');
                break;
            case 'unsigned long long':
                $returnValue = IntegerType::toUnsignedLongLong($value);
                break;
            case 'float':
                $returnValue = FloatType::toFloat($value);
                break;
            case 'unrestricted float':
                $returnValue = FloatType::toUnrestrictedFloat($value);
                break;
            case 'double':
                $returnValue = FloatType::toDouble($value);
                break;
            case 'unrestricted double':
                $returnValue = FloatType::toUnrestrictedDouble($value);
                break;
            case 'DOMString':
                $returnValue = StringType::toDOMString($value);
                break;
            case 'ByteString':
                $returnValue = StringType::toByteString($value);
                break;
            case 'USVString':
                $returnValue = StringType::toUSVString($value);
                break;
            case 'object':
                $returnValue = ObjectType::toObject($value);
                break;
            case 'Error':
                $returnValue = self
                    ::to('(esperecyan\\webidl\\Error or TypeError or DOMException or \\Error)', $value, $pseudoTypes);
                break;
            case 'DOMException':
                $returnValue = ObjectType::toInterface($value, 'DOMException');
                break;
            default:
                $pattern = '/^(?:(?<nullable>.+)\\?|sequence<(?<sequence>.+)>|record<(?<recordK>(?:DOMString|USVString|ByteString)), (?<recordV>.+)>|(?<union>\\(.+\\))|FrozenArray<(?<FrozenArray>.+)>)$/u';
                if (preg_match($pattern, $type, $matches) === 1) {
                    if (!empty($matches['nullable'])) {
                        $returnValue = NullableType::toNullable($value, $matches['nullable'], $pseudoTypes);
                    } elseif (!empty($matches['sequence'])) {
                        $returnValue = SequenceType::toSequence($value, $matches['sequence'], $pseudoTypes);
                    } elseif (!empty($matches['recordK'])) {
                        $returnValue
                            = DictionaryType::toRecord($value, $matches['recordK'], $matches['recordV'], $pseudoTypes);
                    } elseif (!empty($matches['union'])) {
                        $returnValue = UnionType::toUnion($value, $matches['union'], $pseudoTypes);
                    } elseif (!empty($matches['FrozenArray'])) {
                        $returnValue = SequenceType::toFrozenArray($value, $matches['FrozenArray'], $pseudoTypes);
                    }
                } elseif (isset($pseudoTypes[$type])) {
                    $pseudoType = $pseudoTypes[$type];
                    switch ($pseudoType) {
                        case 'callback interface':
                        case 'single operation callback interface':
                            $returnValue = ObjectType::toCallbackInterface(
                                $value,
                                $pseudoType === 'single operation callback interface'
                            );
                            break;
                        case 'callback function':
                            $returnValue = ObjectType::toCallbackFunction($value);
                            break;
                        default:
                            if (is_string($pseudoType) || isset($pseudoType[0])) {
                                $returnValue = StringType::toEnumerationValue($value, $type, $pseudoType);
                            } else {
                                $returnValue = DictionaryType::toDictionary($value, $type, $pseudoTypes);
                            }
                    }
                } else {
                    $returnValue = ObjectType::toInterface($value, $type);
                }
        }
        
        return $returnValue;
    }
886048
private function bindUntypedValues(array $values)
    {
        $params = [];
        $types  = str_repeat('s', count($values));

        foreach ($values as &$v) {
            $params[] =& $v;
        }

        return $this->_stmt->bind_param($types, ...$params);
    }
1141857
protected function splitForOrder(array $validationTypes)
    {
        // pre-assume every item is sortable
        $sortable = $validationTypes;

        // hols temporary removed items
        $nonsortable = [];

        // types to be removed before ordering
        $removeTypes = [
            Doozr_Form_Service_Validator_Constant::VALIDATE_VALUE,
            Doozr_Form_Service_Validator_Constant::VALIDATE_MINLENGTH,
            Doozr_Form_Service_Validator_Constant::VALIDATE_MAXLENGTH,
            Doozr_Form_Service_Validator_Constant::VALIDATE_POSTCODE,
            Doozr_Form_Service_Validator_Constant::VALIDATE_USTID,
        ];

        // iterate over non-sortable validation-types and split
        foreach ($removeTypes as $removeType) {
            if (isset($sortable[$removeType])) {
                $nonsortable[$removeType] = $sortable[$removeType];
                // remove for sorting
                unset($sortable[$removeType]);
            }
        }

        // return prepared items
        return [
            'sortable'    => $sortable,
            'nonsortable' => $nonsortable,
        ];
    }
1114510
public static function types(array $types)
    {
        $defined = array('boolean', 'integer', 'double', 'string');
        $diff = array_diff($types, $defined);

        if (empty($diff))
        {
            return true;
        }
        throw new dbException('Wrong types: "' . implode(', ', $diff) . '". Available "boolean, integer, double, string, array, object"');
    }
1160783
public function type( $types )
	{
		if( !empty( $types ) ) {
			$this->conditions[] = $this->filter->compare( '==', 'stock.type', $types );
		}

		return $this;
	}
148342
public function setValues($values) {

		if(false === is_array($values)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($values)), E_USER_ERROR);
		}

		$this -> values = $values;

		return $this;
	}
540652
private static function hasType( $value, array $allowedTypes ) {
		// Apply strtolower because gettype returns "NULL" for null values.
		$type = strtolower( gettype( $value ) );

		if ( in_array( $type, $allowedTypes ) ) {
			return true;
		}

		if ( in_array( 'callable', $allowedTypes ) && is_callable( $value ) ) {
			return true;
		}

		if ( is_object( $value ) && self::isInstanceOf( $value, $allowedTypes ) ) {
			return true;
		}

		if ( is_array( $value ) && in_array( 'Traversable', $allowedTypes ) ) {
			return true;
		}

		return false;
	}
104006
public function hasAnyDynamicType($types)
    {
        if (\is_string($types)) {
            return isset($this->dynamicTypes[$types]);
        } else {
            foreach ($types as $type) {
                if (isset($this->dynamicTypes[$type])) {
                    return true;
                }
            }
        }

        return false;
    }
1046987
private function validateType(array $types): bool
    {
        $value = $this->value;
        $length = \strlen($value);
        $foundPrefix = false;
        $foundLength = false;
        foreach ($types as $type) {
            foreach ($this->validationData[$type]['prefixes'] as $prefix) {
                if (\substr($value, 0, \strlen($prefix)) == $prefix) {
                    $foundPrefix = true;
                    if (\in_array($length, $this->validationData[$type]['length'])) {
                        $foundLength = true;
                        break 2;
                    }
                }
            }
        }
        if (!$foundPrefix) {
            $this->setError(self::VALIDATOR_ERROR_CREDIT_CARD_NUMBER_PREFIX_NOT_MATCH);
        }
        if (!$foundLength) {
            $this->setError(self::VALIDATOR_ERROR_CREDIT_CARD_NUMBER_LENGTH_NOT_MATCH);
        }
        return $foundPrefix === true && $foundLength === true;
    }
863593
protected function determineType($value)
    {
        if ($value instanceof Expression || $value instanceof ValueGenerator) {
            return self::TYPE_EXPRESSION;
        }

        switch (gettype($value)) {
            case 'boolean':
                return self::TYPE_BOOLEAN;
            case 'integer':
                return self::TYPE_INTEGER;
            case 'string':
                return self::TYPE_STRING;
            case 'double':
            case 'float':
                return self::TYPE_NUMBER;
            case 'array':
                return self::TYPE_ARRAY;
            case 'NULL':
                return self::TYPE_NULL;
            case 'object':
                return self::TYPE_OBJECT;
            default:
                return self::TYPE_OTHER;
        }
    }
531648
public function hasDifferentDynamicType($types)
    {
        $number = 0;
        foreach ($types as $type) {
            if (isset($this->dynamicTypes[$type])) {
                ++$number;
            }
        }

        return 0 == $number;
    }