@param string|resource $input

@return mixed|null
198675
public static function readMessage($input)
    {
        $line = fgets($input);
        $values = explode(':', $line);
        if (count($values) !== 2 || trim($values[0]) !== self::CONTENT_LENGTH) {
            return null;
        }
        $length = intval(trim($values[1]));

        // read one empty line.
        while (trim(fgets($input)) !== '') {}

        $json = fread($input, $length);
        return Common::decode($json);
    }
474767
public function with_input( array $input = null ) {
		$this->get_session()->flash_input(
			$this->clean_input( ! is_null( $input ) ? $input : $this->get_request()->input() )
		);

		return $this;
	}
100292
protected function parse($input): string
    {
        if (!is_array($input)) {
            return json_encode($input);
        }

        $parsed = "";
        foreach ($input as $key => $value) {
            $key = (!is_numeric($key) ? ($key . ": " ) : '');
            if (!is_array($value)) {
                $parsed .= $key . $this->parse($value) . ', ';
            } elseif (is_null(key($value)) || is_numeric(key($value))) {
                $parsed .= $key . "[" . $this->parse($value) . "], ";
            } else {
                $parsed .= $key . "{" . $this->parse($value) . "}, ";
            }
        }

        return rtrim($parsed, ', ');
    }
609079
protected function generateRequestOptions( $input ) {
    $options = [
      'dataType' => 'json',
      'headers' => array_merge(self::$header, (array)$input['header']),
    ];
    $options = array_merge($options, ArrayUtils::array_pick($input, 'json', 'form', 'query'));
    return $options;
  }
508304
public function parse($input = null)
    {
        if (null !== $input) {
            $this->input = $input;
        }

        $this->nextCardinal = null;
        $this->nextSymbol   = null;

        $this->lexer->setInput($this->input);

        // Move Lexer to first token
        $this->lexer->moveNext();

        // Parse and return value
        return $this->point();
    }
1368304
public static function url($input, $domain = false)
    {
        if (!trim((string)$input)) {
            $input = '/';
        }

        if (Grav::instance()['config']->get('system.absolute_urls', false)) {
            $domain = true;
        }

        if (Grav::instance()['uri']->isExternal($input)) {
            return $input;
        }

        /** @var Uri $uri */
        $uri = Grav::instance()['uri'];

        $root = $uri->rootUrl();
        $input = Utils::replaceFirstOccurrence($root, '', $input);

        $input = ltrim((string)$input, '/');

        if (Utils::contains((string)$input, '://')) {
            /** @var UniformResourceLocator $locator */
            $locator = Grav::instance()['locator'];

            $parts = Uri::parseUrl($input);

            if ($parts) {
                $resource = $locator->findResource("{$parts['scheme']}://{$parts['host']}{$parts['path']}", false);

                if (isset($parts['query'])) {
                    $resource = $resource . '?' . $parts['query'];
                }
            } else {
                // Not a valid URL (can still be a stream).
                $resource = $locator->findResource($input, false);
            }


        } else {
            $resource = $input;
        }



        return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?? '');
    }
238539
protected function value($input)
    {
        $output = $input;

        if (is_string($input) === false) {
            switch (gettype($input)) {
                case 'boolean':
                    $output = ($input === true) ? 'true' : 'false';
                    break;
                case 'integer':
                case 'double':
                    $output = (string) $input;
                    break;
                case 'object':
                case 'array':
                case 'resource':
                case 'unknown type':
                    $output = serialize($input);
                    break;
                case 'NULL':
                default:
                    // intentionally omitted
                    break;
            }
        }

        return $output;
    }
733148
protected function validate($input)
    {
        if (true === is_string($input)) {
            $input = @json_decode($input, true);
            if (json_last_error() !== JSON_ERROR_NONE) {
                $input = false;
            }
        }

        return $input;
    }
1261953
public static function inputToResource($input)
    {
        //jeśli resource zwrot
        if (gettype($input) == 'resource') {
            return $input;
        }
        //jeśli krótki content zakłada że to ścieżka pliku
        return imagecreatefromstring((strlen($input) < self::BINARY_MIN_LENGTH) ? file_get_contents($input) : $input);
    }
418790
public function parse(Input $input)
    {
        // fill config
        $this->config = $this->default;

        if ($input instanceof RequestInput) {
            $this->config['optional_item_id'] = true;
        }

        $object = $input->getAsObject();

        $document = $this->getFactory()->make(
            'Document',
            [$object, $this, new RootAccessable]
        );

        // Clear config
        $this->config = [];

        return $document;
    }
490200
public function correct(array $input, array $metadata = [], $resourceName = null)
    {
        $corrected = $input;

        foreach ($this->buildChain() as $name => $parameters) {
            $corrector = $this->getExtension($name);
            $result = $corrector($corrected, $metadata, $resourceName);
            $corrected = &$result;
        }

        return $corrected;
    }
902408
public function html($input = null) {
        if (is_null($input)) {
            return $this->getHtml();
        } else {
            return $this->setHtml($input);
        }
    }
130984
public function genSalt($input = null)
    {
        if (!$input) {
            $input = $this->_getRandomBytes(3);
        }

        // Hash identifier
        $identifier = '_';

        // Cost factor - must be between 1 and 16777215
        $costFactor = min(max($this->_iterationCount, 1), 0xffffff);
        // Should be odd to avoid revealing weak DES keys
        if (($costFactor % 2) == 0) {
            --$costFactor;
        }

        // Salt string
        $salt = $this->_encode64($input, 3);

        // _CCCCSSSS
        return $identifier . $this->_encodeInt24($costFactor) . $salt;
    }
757313
public function parse($input)
    {
        if (is_null($input) || empty($input)) {
            return $input;
        }
        $character = $this->getOption('character');
        $regex = strtr($this->getOption('regex'), $this->getOption('regex_replacement'));

        preg_match_all($regex, $input, $matches);

        $matches = array_map([$this, 'mapper'], $matches[0]);

        $matches = $this->removeNullKeys($matches);
        $matches = $this->prepareArray($matches);

        $output = preg_replace_callback($matches, [$this, 'replace'], $input);

        return $output;
    }
1207660
public function file($input = null)
    {
        // The input name must be defined
        if (!isset($input) || !isset($_FILES[$input])) {
            throw new \InvalidArgumentException('Invalid file', 400);
        }

        // Return the file info
        return $_FILES[$input];
    }
74171
public static function load($input)
    {
        $config = '';
        if (isset($input['config'])) {
            // set the location of the configuration file
            $config = $input['config'];
        }
        $instance = new self($config);
        $instance->loadUserInput($input);
        $instance->go();
        return $instance;
    }
855846
public function input($input = null, $default = null)
    {
        // Get all inputs
        $inputs = array_merge($this->getInputs(), $this->additionalInputs);

        // Exclude reserved inputs
        foreach ($inputs as $key => $value) {
            if (in_array($key, $this->reserved)) {
                unset($inputs[$key]);
            }
        }

        // Return one input
        if ($input) {
            return isset($inputs[$input])? $inputs[$input] : $default;
        }

        // Or the complete array of inputs
        return $inputs;
    }