Skip to content

PHP-DI tip #117

@mnapoli

Description

@mnapoli

Hi!

I was curious and had a look at the package ;) Just one thing I noticed in your config:

    Color::class => factory(function (ContainerInterface $c) {
        $colors = new Color;
        $colors->setForceStyle(true);
        return $colors;
    }),

You can remove factory(), if a definition is a closure then it's implicitly interpreted as a factory by PHP-DI:

    Color::class => function (ContainerInterface $c) {
        $colors = new Color;
        $colors->setForceStyle(true);
        return $colors;
    },

Also you can skip the $c parameter if you don't use it (it's not required). That's just a matter of preference of course.

That's all, feel free to close that issue once you read since it was just a comment!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions