Skip to content

Impossible do define "null" value #79

@mnapoli

Description

@mnapoli
public function set($name, $value = null)

Impossible to define explicitly a null value:

$container->set('service', null);

because:

if null, returns a ClassDefinitionHelper

so it will create a ClassDefinition for the entry name ("service" in the example).


One solution would be to check the numbers of arguments given: if $value was given and specified explicitly to null, then we define a null value.

Another would be to return a more generic helper that would allow:

$container->set('service')->value(null);

but that seems complex because of how it currently works with the ClassDefinitionHelper.

Finally, by adding a NullValue class:

$container->set('service', new NullValue());

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions