Clones a PHP variable.

@param mixed $var    Any PHP variable
@param int   $filter A bit field of Caster::EXCLUDE_* constants

@return Data The cloned variable represented by a Data object
18687
public function cloneVar($var, $filter = 0)
    {
        $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) {
            if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) {
                // Cloner never dies
                throw new \ErrorException($msg, 0, $type, $file, $line);
            }

            if ($this->prevErrorHandler) {
                return ($this->prevErrorHandler)($type, $msg, $file, $line, $context);
            }

            return false;
        });
        $this->filter = $filter;

        if ($gc = gc_enabled()) {
            gc_disable();
        }
        try {
            return new Data($this->doClone($var));
        } finally {
            if ($gc) {
                gc_enable();
            }
            restore_error_handler();
            $this->prevErrorHandler = null;
        }
    }
321764
public function getVar($name, $filter = '', $default = '', $verb = 'get', $options = array())
    {

        if (strtolower($verb) == 'request') {
            $verb = $this->getVerb();
        }
        //just form casting
        $verb = strtolower($verb);

        if (!($input = $this->data($verb))) {
            return $default;
        }

        //Undefined
        if (empty($name) || !isset($input) || !isset($input[$name])) {
            if (isset($default) && !empty($default)) {
                return $default;
            } else {
                return null; //nothing for that name;
            }
        }

        //Do we have a filter;
        if (!isset($filter) || !is_int($filter)) {
            //PHP warns against using gettype to get type,
            //but its much easier than running every is_* to determine type
            //so fo now we go with gettype;
            $type = gettype($input[$name]);

            switch ($type) {
                case "interger":
                    $filter = \IS\INTERGER;
                    break;
                case "float":
                case "double":
                    $filter = \IS\FLOAT;
                    $options = array(
                        "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND,
                        "options" => $options
                    );
                    break;
                case "string":
                    $filter = \IS\STRING;
                    $options = array(
                        "flags" => !FILTER_FLAG_STRIP_LOW,
                        "options" => $options
                    );
                    break;
                case "object": //@TODO,
                case "resource":
                case "NULL":
                case "unknown type":
                default:
                    $filter = \IS\RAW;
                    $options = array(
                        "flags" => !FILTER_FLAG_STRIP_LOW,
                        "options" => $options
                    );
                    break;
            }
        }
        //uhhhnrrr...
        $variable = $input[$name];

        //Pre treat;
        if (get_magic_quotes_gpc() && ($input[$name] != $default) && ($verb != 'files')) {
            $variable = stripslashes($input[$name]); //??
        }

        return $this->filter($variable, $filter, $options);
    }
836070
protected function getUserFunctionariesFilter(string $filter = null)
    {
        $mappingConfiguration = new PropertyMappingConfiguration();
        return $this->convertFunctionariesFilter($mappingConfiguration, $filter);
    }
39357
public function removeFilter($filter)
    {
        $key = is_callable($filter) ? 0 : 1;

        $this->filters = array_values(array_filter(
            $this->filters,
            function ($tuple) use ($key, $filter) {
                return $tuple[$key] !== $filter;
            }
        ));

        $this->updateInternalState();

        $this->handleChangedParameters();

        return $this;
    }
184922
public function getProperties($filter = -1)
    {
        $properties = parent::getProperties($filter);
        foreach ($properties as $key => $val) {
            $properties[$key] = new ReflectionProperty($this->getName(), $val->getName());
        }

        return $properties;
    }
137566
public function getStreams($filter = null)
	{
		if ($filter !== null)
		{
			if ( ! is_callable($filter))
			{
				$filter = function (StreamInterface $stream) use ($filter) {
					return (bool) ($filter & $stream->getType());
				};
			}
			
			$streams = clone $this->streams;
			
			foreach ($streams as $index => $stream)
			{
				if ($filter($stream) === false)
				{
					$streams->offsetUnset($index);
				}
			}
			
			return $streams;
		}
		
		return $this->streams;
	}
1357001
protected function getFunctionariesFilter(string $filter = null)
    {
        $mappingConfiguration = new PropertyMappingConfiguration();
        $mappingConfiguration->setTypeConverter($this->typeConverterObjectConverter);
        $mappingConfiguration->setTypeConverterOption(\RGU\Dvoconnector\Property\TypeConverter\ObjectConverter::class, \RGU\Dvoconnector\Property\TypeConverter\ObjectConverter::CONFIGURATION_OBJECT, $this->getDefaultFunctionariesFilter());

        return $this->convertFunctionariesFilter($mappingConfiguration, $filter);
    }
1238669
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->name) && ($filter === null || isset($filter['name']))) {
			foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $k => $v) {
				$output .= "\x12";
				$buffer = NamePartMeta::toProtobuf($v, $filter === null ? null : $filter['name']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		if (isset($object->identifierValue) && ($filter === null || isset($filter['identifierValue']))) {
			$output .= "\x1a";
			$output .= Binary::encodeVarint(strlen($object->identifierValue));
			$output .= $object->identifierValue;
		}

		if (isset($object->positiveIntValue) && ($filter === null || isset($filter['positiveIntValue']))) {
			$output .= "\x20";
			$output .= Binary::encodeVarint($object->positiveIntValue);
		}

		if (isset($object->negativeIntValue) && ($filter === null || isset($filter['negativeIntValue']))) {
			$output .= "\x28";
			$output .= Binary::encodeVarint($object->negativeIntValue);
		}

		if (isset($object->doubleValue) && ($filter === null || isset($filter['doubleValue']))) {
			$output .= "\x31";
			$output .= Binary::encodeDouble($object->doubleValue);
		}

		if (isset($object->stringValue) && ($filter === null || isset($filter['stringValue']))) {
			$output .= "\x3a";
			$output .= Binary::encodeVarint(strlen($object->stringValue));
			$output .= $object->stringValue;
		}

		if (isset($object->aggregateValue) && ($filter === null || isset($filter['aggregateValue']))) {
			$output .= "\x42";
			$output .= Binary::encodeVarint(strlen($object->aggregateValue));
			$output .= $object->aggregateValue;
		}

		return $output;
	}
223374
public static function create($filter = array())
    {
        if ($filter instanceof self) {
            return $filter;
        }

        if (is_int($filter)) {
            $filter = array('page' => $filter);
        }

        return new self($filter);
    }
366894
public function server($name = "", $default = null, $filter = null) {
        if (empty($this->server)) {
            $this->server = $_SERVER;
        }
        if (!$name) {
            $value = $this->server;
        } else {
            $value = $this->server[ $name ];
        }
        return $this->value($value, $default, $filter);
    }
630274
public function dataTypesGet( $filter = null )
    {

        // array of string
        if( func_num_args() > 1 and \Bond\array_check( 'is_string', func_get_args() ) ) {
            $filter = func_get_args();
        }

        // filter constants
        if( is_int( $filter ) ) {

            $dataTypes = array();

            if( $filter & DataType::PRIMARY_KEYS ) {
                $dataTypes += array_filter(
                    $this->dataTypes,
                    function( $dataType ) {
                        return $dataType->isPrimaryKey();
                    }
                );
            }

            if( $filter & DataType::FORM_CHOICE_TEXT ) {
                $dataTypes += array_filter(
                    $this->dataTypes,
                    function( $dataType ) {
                        return $dataType->isFormChoiceText();
                    }
                );
            }

            if( $filter & DataType::AUTOCOMPLETE ) {
                $dataTypes += array_filter(
                    $this->dataTypes,
                    function( $dataType ) {
                        return $dataType->isAutoComplete();
                    }
                );
            }

            // todo. build a datatype from the $this->links et al
            if( $filter & DataType::LINKS ) {
            }

            return $dataTypes;

        }

        if( is_string( $filter ) ) {
            $filter = array( $filter );
        }

        if( is_array($filter) ) {

            $result = array_intersect_key( $this->dataTypes, array_flip( $filter ) );

            if ( count($result) != count($filter) ) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Unknown columns "%s" passed to %s->dataTypesGet()',
                        implode( '","', array_diff( $filter, array_keys( $result ) ) ),
                        $this->entity
                    )
                );
            }

            return $result;
        }

        if( $filter instanceof \Closure ) {
            return array_filter( $this->dataTypes, $filter );
        }

        return $this->dataTypes;
    }
462841
public static function filterAll(&$var)
    {
        if (is_array($var)) {
            foreach ($var as &$v) {
                self::filterAll($v);
            }
        } else {
            $var = addslashes($var);
            $var = self::filterStr($var);
            $var = self::filterSql($var);
        }
        return $var;
    }
384070
public function toArray($filterVariableContent = false, &$filtered = array()){

        $data = array(
            'serial' => $this->getSerial(),
            'body' => $this->getBody(),
            'elements' => $this->getArraySerializedElementCollection($this->getElements(), $filterVariableContent, $filtered),
        );
        
        if(DEBUG_MODE){
            //in debug mode, add debug data, such as the related item
            $data['debug'] = array('relatedItem' => is_null($this->getRelatedItem())?'':$this->getRelatedItem()->getSerial());
        }   
        
        return $data;
    }
210866
public function server($name = '', $default = null, $filter = '')
    {
        if (empty($this->server)) {
            $this->server = $_SERVER;
        }
        if (is_array($name)) {
            return $this->server = array_merge($this->server, $name);
        }
        return $this->input($this->server, false === $name ? false : strtoupper($name), $default, $filter);
    }
636677
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->location) && ($filter === null || isset($filter['location']))) {
			foreach ($object->location instanceof \Traversable ? $object->location : (array)$object->location as $k => $v) {
				$output .= "\x0a";
				$buffer = LocationMeta::toProtobuf($v, $filter === null ? null : $filter['location']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		return $output;
	}
286548
protected static function parseParameterFilter($filter)
	{
		list($name, $parameters) = explode(':', $filter, 2);

		return array($name, explode(',', $parameters));
	}
1012283
public function filter($filter = null)
    {
        if (is_null($filter)) {
            return $this->filter;
        } else {
            $this->filter = $filter;
        }
    }