<commit_before><?php

    /**
    * Web Operational Kit
    * The neither huger nor micro humble framework
    *
    * @copyright   All rights reserved 2015, <NAME> <<EMAIL>>
    * @author      <NAME> <<EMAIL>>
    * @license     BSD <license.txt>
    **/

    namespace WOK\HttpMessage;

    use \WOK\Uri\Uri;
    use \WOK\Collection\Collection;
    use \Psr\Http\Message\ServerRequestInterface;

    use Components\Headers;
    use Components\FilesCollection;

    /**
     * The Request class provide an interface
     * to manage an HTTP request
    **/
    class ServerRequest extends Request implements ServerRequestInterface {

        /**
         * @var Collection      $server     Server collection instance
        **/
        protected $server;

        /**
         * @var Cookies         $cookies     Cookies collection instance
        **/
        protected $cookies;

        /**
         * @var Files           $files        Files collection instance
        **/
        protected $files;


        /**
         * @var Collection     $attributes    Request meta data collection (attributes)
        **/
        protected $attributes;


        /**
         * Instanciate a new ServerRequest object
         * @param   string              $method             Response HTTP code associated notice
         * @param   string|Uri          $uri                Response HTTP code associated notice
         * @param   array               $headers            Response headers
         * @param   string|Stream       $body               Response body
         * @param   string              $protocolVersion    Response HTTP protocol version
         * @param   array|Files         $files              Server Request files collection
         * @param   array|Cookies       $cookies            Server Request cookies collection
         * @param   array|collection    $server             Server Request server data collection
        **/
        public function __construct(
            $method,
            $uri,
            $headers      = array(),
            $body               = null,
            $protocolVersion    = '1.1',
            $files        = array(),
            $cookies      = array(),
            $server       = array()
        ) {

            parent::__construct($method, $uri, $headers, $body, $protocolVersion);

            $this->files    = (is_array($files)   ? new FilesCollection($files) : $files);
            $this->cookies  = (is_array($cookies) ? new Cookies($cookies)       : $cookies);
            $this->server   = (is_array($server)  ? new Collection($server)     : $server);

        }

        /**
         * Generate a new ServerRequest instance from internal server data
         * @return  ServerRequest       Returns a ServerRequest Instance
        **/
        public static function createFromGlobals() {

            // Calculate protocol version
            $protocolVersion = mb_substr(mb_strstr($_SERVER['SERVER_PROTOCOL'], '/'), 1);

            // Instanciate Uri component
            $path = parse_url($_SERVER['REQUEST_URI']);
            $uri = new Uri(
                (!empty($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : (strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http')),
                $_SERVER['PHP_AUTH_USER'],
                $_SERVER['PHP_AUTH_PW']
                $_SERVER['HTTP_HOST'],
                (!empty($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : ''/*80*/),
                $path['path'],
                $path['query'],
                $path['fragment']
            );

            // Instanciate ServerRequest
            return self::__construct(
                $_SERVER['REQUEST_METHOD'],     // Method
                $uri,                           // Uri
                new Headers(getallheaders()),   // Headers
                fopen('php://input', 'r+'),     // Body
                $protocolVersion,               // Protocol version
                new FilesCollection($_FILES),             // Files
                new Cookies($_COOKIES),         // Cookies
                new Collection($_SERVER)        // Server informations
            );

        }


        /**
         * Get the uploaded files
         * @return  Files       Return the Files collection object
        **/
        public function getUploadedFiles() {
<commit_msg>Fix createFromGlobals syntax error<commit_after><?php

    /**
    * Web Operational Kit
    * The neither huger nor micro humble framework
    *
    * @copyright   All rights reserved 2015, <NAME> <<EMAIL>>
    * @author      <NAME> <<EMAIL>>
    * @license     BSD <license.txt>
    **/

    namespace WOK\HttpMessage;

    use \WOK\Uri\Uri;
    use \WOK\Collection\Collection;
    use \Psr\Http\Message\ServerRequestInterface;

    use Components\Headers;
    use Components\FilesCollection;

    /**
     * The Request class provide an interface
     * to manage an HTTP request
    **/
    class ServerRequest extends Request implements ServerRequestInterface {

        /**
         * @var Collection      $server     Server collection instance
        **/
        protected $server;

        /**
         * @var Cookies         $cookies     Cookies collection instance
        **/
        protected $cookies;

        /**
         * @var Files           $files        Files collection instance
        **/
        protected $files;


        /**
         * @var Collection     $attributes    Request meta data collection (attributes)
        **/
        protected $attributes;


        /**
         * Instanciate a new ServerRequest object
         * @param   string              $method             Response HTTP code associated notice
         * @param   string|Uri          $uri                Response HTTP code associated notice
         * @param   array               $headers            Response headers
         * @param   string|Stream       $body               Response body
         * @param   string              $protocolVersion    Response HTTP protocol version
         * @param   array|Files         $files              Server Request files collection
         * @param   array|Cookies       $cookies            Server Request cookies collection
         * @param   array|collection    $server             Server Request server data collection
        **/
        public function __construct(
            $method,
            $uri,
            $headers      = array(),
            $body               = null,
            $protocolVersion    = '1.1',
            $files        = array(),
            $cookies      = array(),
            $server       = array()
        ) {

            parent::__construct($method, $uri, $headers, $body, $protocolVersion);

            $this->files    = (is_array($files)   ? new FilesCollection($files) : $files);
            $this->cookies  = (is_array($cookies) ? new Cookies($cookies)       : $cookies);
            $this->server   = (is_array($server)  ? new Collection($server)     : $server);

        }

        /**
         * Generate a new ServerRequest instance from internal server data
         * @return  ServerRequest       Returns a ServerRequest Instance
        **/
        public static function createFromGlobals() {

            // Calculate protocol version
            $protocolVersion = mb_substr(mb_strstr($_SERVER['SERVER_PROTOCOL'], '/'), 1);

            // Instanciate Uri component
            $path = parse_url($_SERVER['REQUEST_URI']);
            $uri = new Uri(
                (!empty($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : (strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http')),
                $_SERVER['PHP_AUTH_USER'],
                $_SERVER['PHP_AUTH_PW'],
                $_SERVER['HTTP_HOST'],
                (!empty($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : ''/*80*/),
                $path['path'],
                $path['query'],
                $path['fragment']
            );

            // Instanciate ServerRequest
            return self::__construct(
                $_SERVER['REQUEST_METHOD'],     // Method
                $uri,                           // Uri
                new Headers(getallheaders()),   // Headers
                fopen('php://input', 'r+'),     // Body
                $protocolVersion,               // Protocol version
                new FilesCollection($_FILES),             // Files
                new Cookies($_COOKIES),         // Cookies
                new Collection($_SERVER)        // Server informations
            );

        }


        /**
         * Get the uploaded files
         * @return  Files       Return the Files collection object
        **/
        public function getUploadedFiles() {

{'fraction_non_alphanumeric': 0.10536529680365297, 'fraction_numerical': 0.002054794520547945, 'mean_word_length': 1.4818696883852691, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2059593', 'n_tokens_mistral': 2154, 'n_tokens_neox': 2043, 'n_words': 549}