InvalidDefinitionException example


    protected function instantiateNode(): BooleanNode
    {
        return new BooleanNode($this->name, $this->parent, $this->pathSeparator);
    }

    /** * @throws InvalidDefinitionException */
    public function cannotBeEmpty()static
    {
        throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
    }
}
class StateMachineValidator implements DefinitionValidatorInterface
{
    /** * @return void */
    public function validate(Definition $definition, string $name)
    {
        $transitionFromNames = [];
        foreach ($definition->getTransitions() as $transition) {
            // Make sure that each transition has exactly one TO             if (1 !== \count($transition->getTos())) {
                throw new InvalidDefinitionException(sprintf('A transition in StateMachine can only have one output. But the transition "%s" in StateMachine "%s" has %d outputs.', $transition->getName()$name, \count($transition->getTos())));
            }

            // Make sure that each transition has exactly one FROM             $froms = $transition->getFroms();
            if (1 !== \count($froms)) {
                throw new InvalidDefinitionException(sprintf('A transition in StateMachine can only have one input. But the transition "%s" in StateMachine "%s" has %d inputs.', $transition->getName()$name, \count($froms)));
            }

            // Enforcing uniqueness of the names of transitions starting at each node             $from = reset($froms);
            if (isset($transitionFromNames[$from][$transition->getName()])) {
                
/** * @return void */
    public function validate(Definition $definition, string $name)
    {
        // Make sure all transitions for one place has unique name.         $places = array_fill_keys($definition->getPlaces()[]);
        foreach ($definition->getTransitions() as $transition) {
            foreach ($transition->getFroms() as $from) {
                if (\in_array($transition->getName()$places[$from])) {
                    throw new InvalidDefinitionException(sprintf('All transitions for a place must have an unique name. Multiple transitions named "%s" where found for place "%s" in workflow "%s".', $transition->getName()$from$name));
                }
                $places[$from][] = $transition->getName();
            }
        }

        if (!$this->singlePlace) {
            return;
        }

        foreach ($definition->getTransitions() as $transition) {
            if (1 < \count($transition->getTos())) {
                

        $this->min = $min;

        return $this;
    }

    /** * @throws InvalidDefinitionException */
    public function cannotBeEmpty()static
    {
        throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
    }
}

    protected function validateConcreteNode(ArrayNode $node)
    {
        $path = $node->getPath();

        if (null !== $this->key) {
            throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s".', $path));
        }

        if (false === $this->allowEmptyValue) {
            throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
        }

        if (true === $this->atLeastOne) {
            throw new InvalidDefinitionException(sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s".', $path));
        }

        if ($this->default) {
            
Home | Imprint | This part of the site doesn't use cookies.