OutOfBoundsException example

/** * Replaces a specific argument. * * @return $this * * @throws OutOfBoundsException When the replaced argument does not exist */
    public function replaceArgument(int|string $index, mixed $argument)static
    {
        if (0 === \count($this->arguments)) {
            throw new OutOfBoundsException(sprintf('Cannot replace arguments for class "%s" if none have been configured yet.', $this->class));
        }

        if (\is_int($index) && ($index < 0 || $index > \count($this->arguments) - 1)) {
            throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d] of the arguments of class "%s".', $index, \count($this->arguments) - 1, $this->class));
        }

        if (!\array_key_exists($index$this->arguments)) {
            throw new OutOfBoundsException(sprintf('The argument "%s" doesn\'t exist in class "%s".', $index$this->class));
        }

        $this->arguments[$index] = $argument;

        
/** * Replaces a specific argument. * * @return $this * * @throws OutOfBoundsException When the replaced argument does not exist */
    public function replaceArgument(int|string $index, mixed $argument)static
    {
        if (0 === \count($this->arguments)) {
            throw new OutOfBoundsException(sprintf('Cannot replace arguments for class "%s" if none have been configured yet.', $this->class));
        }

        if (\is_int($index) && ($index < 0 || $index > \count($this->arguments) - 1)) {
            throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d] of the arguments of class "%s".', $index, \count($this->arguments) - 1, $this->class));
        }

        if (!\array_key_exists($index$this->arguments)) {
            throw new OutOfBoundsException(sprintf('The argument "%s" doesn\'t exist in class "%s".', $index$this->class));
        }

        $this->arguments[$index] = $argument;

        
if ($this->cke4ButtonsMap !== NULL) {
      return;
    }

    foreach ($this->getDefinitions() as $upgrade_plugin_id => $definition) {
      // Only one CKEditor4To5Upgrade plugin can define the upgrade path for a       // CKEditor 4 button.       if (isset($definition['cke4_buttons'])) {
        assert(Inspector::assertAllStrings($definition['cke4_buttons']));
        foreach ($definition['cke4_buttons'] as $cke4_button_id) {
          if (isset($this->cke4ButtonsMap[$cke4_button_id])) {
            throw new \OutOfBoundsException(sprintf('The "%s" CKEditor 4 button is already being upgraded by the "%s" CKEditor4To5Upgrade plugin, the "%s" plugin is as well. This conflict needs to be resolved.', $cke4_button_id$this->cke4ButtonsMap[$cke4_button_id]$upgrade_plugin_id));
          }
          $this->cke4ButtonsMap[$cke4_button_id] = $upgrade_plugin_id;
        }
      }

      // Only one CKEditor4To5Upgrade plugin can define the upgrade path for a       // CKEditor 4 plugin's settings.       if (isset($definition['cke4_plugin_settings'])) {
        assert(Inspector::assertAllStrings($definition['cke4_plugin_settings']));
        foreach ($definition['cke4_plugin_settings'] as $cke4_plugin_id) {
          if (isset($this->cke4PluginSettingsMap[$cke4_plugin_id])) {
            

    public function offsetGet(mixed $position): FormError|self
    {
        if (!isset($this->errors[$position])) {
            throw new OutOfBoundsException('The offset '.$position.' does not exist.');
        }

        return $this->errors[$position];
    }

    /** * Unsupported method. * * @throws BadMethodCallException */
    public function offsetSet(mixed $position, mixed $value): void
    {
public function has(string $name): bool
    {
        return isset($this->children[$name]);
    }

    public function get(string $name): FormInterface
    {
        if (isset($this->children[$name])) {
            return $this->children[$name];
        }

        throw new OutOfBoundsException(sprintf('Child "%s" does not exist.', $name));
    }

    /** * Returns whether a child with the given name exists (implements the \ArrayAccess interface). * * @param string $name The name of the child */
    public function offsetExists(mixed $name): bool
    {
        return $this->has($name);
    }

    
return $parent;
    }

    public function getElements(): array
    {
        return $this->elements;
    }

    public function getElement(int $index): string
    {
        if (!isset($this->elements[$index])) {
            throw new OutOfBoundsException(sprintf('The index "%s" is not within the violation path.', $index));
        }

        return $this->elements[$index];
    }

    public function isProperty(int $index): bool
    {
        if (!isset($this->isIndex[$index])) {
            throw new OutOfBoundsException(sprintf('The index "%s" is not within the violation path.', $index));
        }

        
$this->size = $size;
    }

    public function offsetExists(mixed $key): bool
    {
        return isset($this->indices[$key]);
    }

    public function offsetGet(mixed $key): mixed
    {
        if (!isset($this->indices[$key])) {
            throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $key));
        }

        return $this->values[$this->indices[$key]];
    }

    public function offsetSet(mixed $key, mixed $value): void
    {
        if (false !== ($keyToRemove = array_search($this->cursor, $this->indices))) {
            unset($this->indices[$keyToRemove]);
        }

        

    public function addAll(ConstraintViolationListInterface $otherList)
    {
        foreach ($otherList as $violation) {
            $this->violations[] = $violation;
        }
    }

    public function get(int $offset): ConstraintViolationInterface
    {
        if (!isset($this->violations[$offset])) {
            throw new OutOfBoundsException(sprintf('The offset "%s" does not exist.', $offset));
        }

        return $this->violations[$offset];
    }

    public function has(int $offset): bool
    {
        return isset($this->violations[$offset]);
    }

    /** * @return void */
return ['specialCharacters'];

      // @see \Drupal\ckeditor\Plugin\CKEditorPlugin\Language       case 'Language':
        return ['textPartLanguage'];

      // @see \Drupal\media_library\Plugin\CKEditorPlugin\DrupalMediaLibrary       case 'DrupalMediaLibrary':
        return ['drupalMedia'];

      default:
        throw new \OutOfBoundsException();
    }
  }

  /** * {@inheritdoc} */
  public function mapCKEditor4SettingsToCKEditor5Configuration(string $cke4_plugin_id, array $cke4_plugin_settings): ?array {
    switch ($cke4_plugin_id) {
      // @see \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo       case 'stylescombo':
        if (!isset($cke4_plugin_settings['styles'])) {
          
return new PropertyPathIterator($this);
    }

    public function getElements(): array
    {
        return $this->elements;
    }

    public function getElement(int $index): string
    {
        if (!isset($this->elements[$index])) {
            throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index));
        }

        return $this->elements[$index];
    }

    public function isProperty(int $index): bool
    {
        if (!isset($this->isIndex[$index])) {
            throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index));
        }

        

  private function getPrecedingConstraints(Constraint $needle): iterable {
    assert($this->context instanceof ExecutionContext);
    $constraints = $this->context->getMetadata()->getConstraints();
    if (!in_array($needle$constraints)) {
      throw new \OutOfBoundsException();
    }
    foreach ($constraints as $constraint) {
      if ($constraint != $needle) {
        yield $constraint;
      }
    }
  }

}
public function mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem(string $cke4_button, HTMLRestrictions $text_format_html_restrictions): ?array {
    switch ($cke4_button) {
      // @see https://www.drupal.org/project/codetag       case 'Code':
        return ['code'];

      // @see https://www.drupal.org/project/codesnippet       case 'CodeSnippet':
        return ['codeBlock'];

      default:
        throw new \OutOfBoundsException();
    }
  }

  /** * {@inheritdoc} */
  public function mapCKEditor4SettingsToCKEditor5Configuration(string $cke4_plugin_id, array $cke4_plugin_settings): ?array {
    switch ($cke4_plugin_id) {
      case 'codesnippet':
        $languages = [];
        $enabled_cke4_languages = array_filter($cke4_plugin_settings['highlight_languages']);
        
/** * Removes elements from the current path. * * @return void * * @throws OutOfBoundsException if offset is invalid */
    public function remove(int $offset, int $length = 1)
    {
        if (!isset($this->elements[$offset])) {
            throw new OutOfBoundsException(sprintf('The offset "%s" is not within the property path.', $offset));
        }

        $this->resize($offset$length, 0);
    }

    /** * Replaces a sub-path by a different (sub-) path. * * @param int $pathOffset The offset where the inserted piece starts in $path * @param int $pathLength The length of the inserted piece; if 0, the full path is inserted * * @return void * * @throws OutOfBoundsException If the offset is invalid */

    public function addAll(ConstraintViolationListInterface $otherList)
    {
        foreach ($otherList as $violation) {
            $this->violations[] = $violation;
        }
    }

    public function get(int $offset): ConstraintViolationInterface
    {
        if (!isset($this->violations[$offset])) {
            throw new OutOfBoundsException(sprintf('The offset "%s" does not exist.', $offset));
        }

        return $this->violations[$offset];
    }

    public function has(int $offset): bool
    {
        return isset($this->violations[$offset]);
    }

    /** * @return void */

  public function insertComponent($delta, SectionComponent $new_component) {
    $components = $this->getComponentsByRegion($new_component->getRegion());
    $count = count($components);
    if ($delta > $count) {
      throw new \OutOfBoundsException(sprintf('Invalid delta "%s" for the "%s" component', $delta$new_component->getUuid()));
    }

    // If the delta is the end of the list, append the component instead.     if ($delta === $count) {
      return $this->appendComponent($new_component);
    }

    // Find the weight of the component that exists at the specified delta.     $weight = array_values($components)[$delta]->getWeight();
    $this->setComponent($new_component->setWeight($weight++));

    
Home | Imprint | This part of the site doesn't use cookies.