<commit_before><?php
/**
 *
 */

namespace Valar\Plugin;

use Mvc5\Arg;
use Mvc5\Http\HttpHeaders;
use Mvc5\Plugin\ScopedCall;
use Mvc5\Plugin\Shared;
use Zend\Diactoros\ServerRequestFactory;

class Headers
    extends Shared
{
    /**
     * @param $name
     */
    function __construct($name = 'headers')
    {
        parent::__construct($name, new ScopedCall($this));
    }

    /**
     * @return \Closure
     */
    function __invoke()
    {
        return function() {
            /** @var \Valar\ServerRequest $this */
            $headers = ServerRequestFactory::marshalHeaders($this[Arg::SERVER]);

            !isset($headers[Arg::HOST]) && ($uri = $this[Arg::URI]) && ($host = $uri->getHost()) &&
                $headers[Arg::HOST] = [$host . (($port = $uri->getPort()) ? ':' . $port : '')];

            return new HttpHeaders($headers);
        };
    }
}
<commit_msg>empty cli headers causes recursion<commit_after><?php
/**
 *
 */

namespace Valar\Plugin;

use Mvc5\Arg;
use Mvc5\Http\HttpHeaders;
use Mvc5\Plugin\ScopedCall;
use Mvc5\Plugin\Shared;
use Zend\Diactoros\ServerRequestFactory;

class Headers
    extends Shared
{
    /**
     * @param $name
     */
    function __construct($name = 'headers')
    {
        parent::__construct($name, new ScopedCall($this));
    }

    /**
     * @return \Closure
     */
    function __invoke()
    {
        return function() {
            return new HttpHeaders(ServerRequestFactory::marshalHeaders($this[Arg::SERVER]));
        };
    }
}

{'fraction_non_alphanumeric': 0.16169648774022533, 'fraction_numerical': 0.005301524188204109, 'mean_word_length': 2.4953703703703702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2061871', 'n_tokens_mistral': 493, 'n_tokens_neox': 479, 'n_words': 87}