# betterdocs/4.9.0/includes/Dependencies/DI/Definition/ArrayDefinition.php

BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ &amp; Chatbot, version 4.9.0. 75 lines.

- Page: https://pluginprobe.com/plugins/betterdocs/4.9.0/code/includes/Dependencies/DI/Definition/ArrayDefinition.php
- Raw: https://pluginprobe.com/plugins/betterdocs/4.9.0/raw/includes/Dependencies/DI/Definition/ArrayDefinition.php
- Modified: 2026-06-23T11:52:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterdocs/4.9.0/code/includes/Dependencies/DI/Definition/ArrayDefinition.php#L10-L20`.

```php
<?php
// phpcs:ignoreFile -- Bundled third-party (Mozart) dependency; exempt from plugin coding standards.

declare(strict_types=1);

namespace WPDeveloper\BetterDocs\Dependencies\DI\Definition;

/**
 * Definition of an array containing values or references.
 *
 * @since 5.0
 * @author Matthieu Napoli <matthieu@mnapoli.fr>
 */
class ArrayDefinition implements Definition
{
    /**
     * Entry name.
     * @var string
     */
    private $name = '';

    /**
     * @var array
     */
    private $values;

    public function __construct(array $values)
    {
        $this->values = $values;
    }

    public function getName() : string
    {
        return $this->name;
    }

    public function setName(string $name)
    {
        $this->name = $name;
    }

    public function getValues() : array
    {
        return $this->values;
    }

    public function replaceNestedDefinitions(callable $replacer)
    {
        $this->values = array_map($replacer, $this->values);
    }

    public function __toString()
    {
        $str = '[' . PHP_EOL;

        foreach ($this->values as $key => $value) {
            if (is_string($key)) {
                $key = "'" . $key . "'";
            }

            $str .= '    ' . $key . ' => ';

            if ($value instanceof Definition) {
                $str .= str_replace(PHP_EOL, PHP_EOL . '    ', (string) $value);
            } else {
                $str .= var_export($value, true);
            }

            $str .= ',' . PHP_EOL;
        }

        return $str . ']';
    }
}

```
