laminas / laminas-di

Automated dependency injection for PSR-11 containers
https://docs.laminas.dev/laminas-di/
BSD 3-Clause "New" or "Revised" License
36 stars 20 forks source link

Simplify `RuntimeDefinition::class` by normalizing `RuntimeDefinition::$explicitClasses` #48

Closed sjokkateer closed 2 years ago

sjokkateer commented 2 years ago
Q A
Documentation no
Bugfix no
BC Break no
New Feature no
RFC no
QA no

Description

This PR might be considered a minor refactor/improvement.

Currently in RuntimeDefinition::__construct() a test for truthiness of $explicitClasses is done. This means that RuntimeDefinition::setExplicitClasses() is only called whenever the constructor argument$explicitClasses is not null and not an empty array. This means that after construction, RuntimeDefinition::$explicitClasses can be null, and hence the tests for truthiness throughout some of the methods is required to account for that. This pull request normalizes the null value to an empty array in the constructor, simplifying some methods and ensuring that users do not have to deal with tests for null in code in case they extend the class.

Ocramius commented 2 years ago

Thanks @sjokkateer!