# defender-security/5.8.1/lib/packages/DI/Definition/Source/DefinitionFile.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 5.8.1. 63 lines.

- Page: https://pluginprobe.com/plugins/defender-security/5.8.1/code/lib/packages/DI/Definition/Source/DefinitionFile.php
- Raw: https://pluginprobe.com/plugins/defender-security/5.8.1/raw/lib/packages/DI/Definition/Source/DefinitionFile.php
- Modified: 2026-01-12T12:13:50+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/defender-security/5.8.1/code/lib/packages/DI/Definition/Source/DefinitionFile.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace WPMU_DEV\Defender\Vendor\DI\Definition\Source;

use WPMU_DEV\Defender\Vendor\DI\Definition\Definition;

/**
 * Reads WPMU_DEV\Defender\Vendor\DI definitions from a file returning a PHP array.
 *
 * @author Matthieu Napoli <matthieu@mnapoli.fr>
 */
class DefinitionFile extends DefinitionArray
{
    private bool $initialized = false;

    /**
     * @param string $file File in which the definitions are returned as an array.
     */
    public function __construct(
        private string $file,
        ?Autowiring $autowiring = null,
    ) {
        // Lazy-loading to improve performances
        parent::__construct([], $autowiring);
    }

    public function getDefinition(string $name) : ?Definition
    {
        $this->initialize();

        return parent::getDefinition($name);
    }

    public function getDefinitions() : array
    {
        $this->initialize();

        return parent::getDefinitions();
    }

    /**
     * Lazy-loading of the definitions.
     */
    private function initialize() : void
    {
        if ($this->initialized === true) {
            return;
        }

        $definitions = require $this->file;

        if (! is_array($definitions)) {
            throw new \Exception("File $this->file should return an array of definitions");
        }

        $this->addDefinitions($definitions);

        $this->initialized = true;
    }
}

```
