Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Jul 30, 2022

This changeset adds support for null values in container configuration that are used in factory functions:

<?php

require __DIR__ . '/../vendor/autoload.php';

$container = new FrameworkX\Container([
    Acme\Todo\UserController::class => function (?string $name) {
        // example UserController class uses $name as string or null
        return new Acme\Todo\UserController($name);
    },
    'name' => fn(): ?string => $_ENV['APP_NAME'] ?? null
]);

// …

The previous version only supported object and scalar values, we now also support null values. #181 already added support for passing null values for nullable arguments that are not set at all, this changeset now also includes support for explicit null values in the configuration. This is the next step in adding better configuration support and support for environment variables and .env (dotenv) files as discussed in #101.

Builds on top of #182, #181, #180, #179, #178, #163, #97, #95 and others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants