<commit_before><?php

namespace React\Promise;

final class Deferred implements PromisorInterface
{
    private $promise;
    private $resolveCallback;
    private $rejectCallback;
    private $canceller;

    public function __construct(callable $canceller = null)
    {
        $this->canceller = $canceller;
    }

    public function promise(): PromiseInterface
    {
        if (null === $this->promise) {
            $canceller = $this->canceller;
            $this->canceller = null;

            $this->promise = new Promise(function ($resolve, $reject): void {
                $this->resolveCallback = $resolve;
                $this->rejectCallback  = $reject;
            }, $canceller);
        }

        return $this->promise;
    }

    public function resolve($value = null): void
    {
        $this->promise();

        ($this->resolveCallback)($value);
    }

    public function reject(\Throwable $reason): void
    {
        $this->promise();

        ($this->rejectCallback)($reason);
    }
}<commit_msg>Initialize Deferred's state in constructor<commit_after><?php

namespace React\Promise;

final class Deferred implements PromisorInterface
{
    private $promise;
    private $resolveCallback;
    private $rejectCallback;

    public function __construct(callable $canceller = null)
    {
        $this->promise = new Promise(function ($resolve, $reject): void {
            $this->resolveCallback = $resolve;
            $this->rejectCallback  = $reject;
        }, $canceller);
    }

    public function promise(): PromiseInterface
    {
        return $this->promise;
    }

    public function resolve($value = null): void
    {
        ($this->resolveCallback)($value);
    }

    public function reject(\Throwable $reason): void
    {
        ($this->rejectCallback)($reason);
    }
}
{'fraction_non_alphanumeric': 0.12328013208585581, 'fraction_numerical': 0.0, 'mean_word_length': 2.469465648854962, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '5140689', 'n_tokens_mistral': 511, 'n_tokens_neox': 495, 'n_words': 113}