Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Jul 29, 2022

This changeset adds support for values in container configuration that are used as untyped or mixed arguments in factory functions:

<?php

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

$container = new FrameworkX\Container([
    Acme\Todo\UserController::class => function ($debug, mixed $any) {
        // example UserController class uses two container arguments
        return new Acme\Todo\UserController($debug, $any);
    },
    'debug' => true,
    'any' => 'Alice'
]);

// …

The previous version would only apply default values to untyped arguments and would complain about any mixed arguments. We now first check to see if an explicit container variable is set and use this value if available. If this value is not available, we continue either using any default value if available or raise an error (as discussed in #181, we do not try to pass a null value here). 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 #181, #180, #179, #178, #163, #97, #95 and others

@clue clue added the new feature New feature or request label Jul 29, 2022
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