<commit_before><?php

namespace Phpactor\WorseReflection\Core\Inference;

use Phpactor\WorseReflection\Core\Type;
use Phpactor\WorseReflection\Core\Types;
use Phpactor\WorseReflection\Core\Reflection\ReflectionScope;

final class SymbolContext
{
    /**
     * @var mixed
     */
    private $value;

    /**
     * @var Types
     */
    private $types;

    /**
     * @var Symbol
     */
    private $symbol;

    /**
     * @var Type
     */
    private $containerType;

    /**
     * @var string[]
     */
    private $issues = [];

    /**
     * @var ReflectionScope
     */
    private $scope;

    private function __construct(Symbol $symbol, Types $types, $value = null, Type $containerType = null, ReflectionScope $scope = null)
    {
        $this->value = $value;
        $this->symbol = $symbol;
        $this->containerType = $containerType;
        $this->types = $types;
        $this->containerType = $containerType;
        $this->scope = $scope;
    }

    public static function for(Symbol $symbol): SymbolContext
    {
        return new self($symbol, Types::fromTypes([ Type::unknown() ]));
    }

    /**
     * @deprecated
     */
    public static function fromTypeAndValue(Type $type, $value): SymbolContext
    {
        return new self(Symbol::unknown(), Types::fromTypes([ $type ]), $value);
    }

    /**
     * @deprecated Types are plural
     */
    public static function fromType(Type $type)
    {
        return new self(Symbol::unknown(), Types::fromTypes([ $type ]));
    }

    public static function none(): SymbolContext
    {
        return new self(Symbol::unknown(), Types::empty());
    }

    public function withValue($value): SymbolContext
    {
        return new self($this->symbol, $this->types, $value, $this->containerType, $this->scope);
    }

    public function withContainerType(Type $containerType): SymbolContext
    {
        return new self($this->symbol, $this->types, $this->value, $containerType, $this->scope);
    }

    /**
     * @deprecated Types are plural
     */
    public function withType(Type $type): SymbolContext
    {
        return new self($this->symbol, Types::fromTypes([ $type ]), $this->value, $this->containerType, $this->scope);
    }

    public function withTypes(Types $types): SymbolContext
    {
        return new self($this->symbol, $types, $this->value, $this->containerType, $this->scope);
    }

    public function withScope(ReflectionScope $scope)
    {
        return new self($this->symbol, $this->types, $this->value, $this->containerType, $scope);
    }

    public function withIssue(string $message): SymbolContext
    {
        $new = new self($this->symbol, $this->types, $this->value, $this->containerType, $this->scope);
        $new->issues[] = $message;

        return $new;
    }

    /**
     * @deprecated
     */
    public function type(): Type
    {
        foreach ($this->types() as $type) {
            return $type;
        }

        return Type::unknown();
    }

    public function types(): Types
    {
        return $this->types;
    }<commit_msg>Improved with'ers<commit_after><?php

namespace Phpactor\WorseReflection\Core\Inference;

use Phpactor\WorseReflection\Core\Type;
use Phpactor\WorseReflection\Core\Types;
use Phpactor\WorseReflection\Core\Reflection\ReflectionScope;

final class SymbolContext
{
    /**
     * @var mixed
     */
    private $value;

    /**
     * @var Types
     */
    private $types;

    /**
     * @var Symbol
     */
    private $symbol;

    /**
     * @var Type
     */
    private $containerType;

    /**
     * @var string[]
     */
    private $issues = [];

    /**
     * @var ReflectionScope
     */
    private $scope;

    private function __construct(Symbol $symbol, Types $types, $value = null, Type $containerType = null, ReflectionScope $scope = null)
    {
        $this->value = $value;
        $this->symbol = $symbol;
        $this->containerType = $containerType;
        $this->types = $types;
        $this->containerType = $containerType;
        $this->scope = $scope;
    }

    public static function for(Symbol $symbol): SymbolContext
    {
        return new self($symbol, Types::fromTypes([ Type::unknown() ]));
    }

    /**
     * @deprecated
     */
    public static function fromTypeAndValue(Type $type, $value): SymbolContext
    {
        return new self(Symbol::unknown(), Types::fromTypes([ $type ]), $value);
    }

    /**
     * @deprecated Types are plural
     */
    public static function fromType(Type $type)
    {
        return new self(Symbol::unknown(), Types::fromTypes([ $type ]));
    }

    public static function none(): SymbolContext
    {
        return new self(Symbol::unknown(), Types::empty());
    }

    public function withValue($value): SymbolContext
    {
        $new = clone $this;
        $new->value = $value;

        return $new;
    }

    public function withContainerType(Type $containerType): SymbolContext
    {
        $new = clone $this;
        $new->containerType = $containerType;

        return $new;
    }

    /**
     * @deprecated Types are plural
     */
    public function withType(Type $type): SymbolContext
    {
        $new = clone $this;
        $new->types = Types::fromTypes([ $type ]);

        return $new;
    }

    public function withTypes(Types $types): SymbolContext
    {
        $new = clone $this;
        $new->types = $types;

        return $new;
    }

    public function withScope(ReflectionScope $scope)
    {
        $new = clone $this;
        $new->scope = $scope;

        return $new;
    }

    public function withIssue(string $message): SymbolContext
    {
        $new = clone $this;
        $new->issues[] = $message;

        return $new;
    }

    /**
     * @deprecated
     */
    public function type(): Type
    {
        foreach ($this->types() as $type) {
            return $type;
        }

        return Type::unknown();
    }

    public function types(): Types
    {
        return $this->types;
    }
{'fraction_non_alphanumeric': 0.14021956087824353, 'fraction_numerical': 0.0, 'mean_word_length': 2.276839237057221, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '5778531', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1721, 'n_words': 413}