Compile next states of each state.

@param TransitionChain $transitionChain Transition chain

@return $this Self object

@throws StateNotValidException state is not valid
972012
private function checkStates(TransitionChain $transitionChain)
    {
        /**
         * @var Transition $transition
         */
        foreach ($transitionChain->getTransitions() as $transition) {
            $initialStateName = $transition->getStart()->getName();

            if ($initialStateName === $this->pointOfEntry) {
                continue;
            }

            if (!$this->transitionChain->getTransitionsByFinalState($initialStateName)) {
                throw new StateNotValidException($initialStateName);
            }
        }

        return $this;
    }
146763
protected function _setTransition($transition)
    {
        if ($transition !== null && !is_string($transition) && !($transition instanceof Stringable)) {
            throw $this->_createInvalidArgumentException(
                $this->__('Argument is not a valid transition'),
                null,
                null,
                $transition
            );
        }

        $this->transition = $transition;
    }
25635
public function addTransition(Transition $transition)
    {
        if (!$this->transitions->contains($transition)) {
            $this->transitions->add($transition);
            $transition->setTask($this);
        }

        return $this;
    }
1320994
public function processPolicies(ValidatorState $state, Certificate $cert): ValidatorState
    {
        $policies = $cert->tbsCertificate()
            ->extensions()
            ->certificatePolicies();
        $tree = clone $this;
        // (d.1) for each policy P not equal to anyPolicy
        foreach ($policies as $policy) {
            if ($policy->isAnyPolicy()) {
                $tree->_processAnyPolicy($policy, $cert, $state);
            } else {
                $tree->_processPolicy($policy, $state);
            }
        }
        // if whole tree is pruned
        if (!$tree->_pruneTree($state->index() - 1)) {
            return $state->withoutValidPolicyTree();
        }
        return $state->withValidPolicyTree($tree);
    }
705827
public function generate(
        $machineId,
        TransitionChain $transitionChain,
        $pointOfEntry
    ) {
        $machine = new Machine(
            $machineId,
            $transitionChain,
            $pointOfEntry
        );

        return $machine;
    }
837298
public function reachState(
        $startStateName,
        $finalStateName
    ) {
        $transition = $this
            ->transitionChain
            ->getTransitionByStartingStateAndFinalState(
                $startStateName,
                $finalStateName
            );

        if (!($transition instanceof Transition)) {
            throw new StateNotReachableException();
        }

        return $transition;
    }
1249223
public function processMappings(ValidatorState $state, Certificate $cert): ValidatorState
    {
        $tree = clone $this;
        if ($state->policyMapping() > 0) {
            $tree->_applyMappings($cert, $state);
        } else if ($state->policyMapping() == 0) {
            $tree->_deleteMappings($cert, $state);
        }
        // if whole tree is pruned
        if (!$tree->_root) {
            return $state->withoutValidPolicyTree();
        }
        return $state->withValidPolicyTree($tree);
    }
862083
public function addStates(array $states): self
    {
        $builder = clone $this;
        foreach ($states as $state) {
            $builder->states[$state->getName()] = $state;
        }
        return $builder;
    }
708836
public function call(TransitionEvent $event)
    {
        if (!isset($this->specs['args'])) {
            $args = array($event);
        } else {
            $expr = new ExpressionLanguage();
            $args = array_map(
                function($arg) use($expr, $event) {
                    if (!is_string($arg)) {
                        return $arg;
                    }

                    return $expr->evaluate($arg, array(
                        'object' => $event->getStateMachine()->getObject(),
                        'event'  => $event
                    ));
                }, $this->specs['args']
            );
        }

        $callable = $this->filterCallable($this->callable, $event);

        return call_user_func_array($callable, $args);
    }
116326
final public function chain(PipeChainInterface $chain): PipeChainInterface
    {
        if ( $this->next instanceof PipeChainInterface ) {
            $this->next->chain($chain);
        }
        else {
            $this->next = $chain;
        }

        return $this;
    }
976956
protected function _setTransitioner($transitioner)
    {
        if ($transitioner !== null && !($transitioner instanceof TransitionerInterface)) {
            throw $this->_createInvalidArgumentException(
                $this->__('Argument is not a valid booking transitioner'),
                null,
                null,
                $transitioner
            );
        }

        $this->transitioner = $transitioner;
    }
1051609
public function addTransition(TransitionInterface $transition): self
    {
        if (!$this->states->hasKey($transition->getFrom())) {
            throw new UnknownState('Trying to add transition from unknown state: ' . $transition->getFrom());
        }
        if (!$this->states->hasKey($transition->getTo())) {
            throw new UnknownState('Trying to add transition to unknown state: ' . $transition->getTo());
        }
        $transition_key = $transition->getFrom().$transition->getTo();
        if ($this->transitions->hasKey($transition_key)) {
            throw new InvalidStructure(
                sprintf('Trying to add same transition twice: %s -> %s', $transition->getFrom(), $transition->getTo())
            );
        }
        $builder = clone $this;
        $builder->transitions[$transition_key] = $transition;
        return $builder;
    }
238353
private function doTransitionFromY() : self
    {
        if ($this->getToken() !== '$') {
            throw (new Exception('Invalid Roman', Exception::INVALID_ROMAN))
                ->setPosition($this->getPosition())
                ->setToken($this->getToken());
        }

        // done!
        $this->setState(self::STATE_Z);
        return $this;
    }
543833
public function multi()
    {
        if ($this->state->check(MultiExecState::INITIALIZED | MultiExecState::CAS)) {
            $this->state->unflag(MultiExecState::CAS);
            $this->call('MULTI');
        } else {
            $this->initialize();
        }

        return $this;
    }
1083115
public function execute(State $state) {
        $errors = [];
        foreach ($state->newCalls as $new) {
            $type = null;
            if ($new->class instanceof Operand\Literal) {
                $type = $new->class->value;
            } elseif ($new->class->type->type !== Type::TYPE_OBJECT) {
                $errors[] = ["Unknown class type for new call", $new];
                continue;
            } else {
                $type = $new->class->type->userType;
            }
            $name = strtolower($type);
            if (!isset($state->classResolves[$name])) {
                if (isset($state->internalTypeInfo->methods[$name])) {
                    // TODO
                } else {
                    $errors[] = ["Could not find class definition for $type", $new];
                }
                continue;
            }
            foreach ($state->classResolves[$name] as $sub => $class) {
                $constructor = $this->findConstructor($class);
                if ($constructor) {
                    // validate parameters!!!
                    $errors = array_merge($errors, $this->verifyCall($constructor, $new, $state, "{$class->name->value}::__construct"));
                }
            }
        }
        return $errors;
    }
41684
private function makeFailStates(): self {
        $seeker   = new Seeker($this->check, $this->base, []);
        $this->traverseTreeForMakeFailCursor($this->tmp_tree, [], $seeker);
        return $this;
    }
251343
public static function setValidationState( $state = true)
	{
		$previousState = XBRL::$validating;
		XBRL::$validating = $state;
		return $previousState;
	}