How to handle default values? #8

gossi opened this Issue Mar 22, 2013 · 0 comments


None yet
1 participant

gossi commented Mar 22, 2013

Composer has some values for properties that are not present in the composer.json. Some examples:

/config/vendor-dir -> vendor
/config/bin-dir -> vendor/bin
/repositories/{x}/packagist -> true

The question is, what should the API return, in case they are not set written in the composer.json file, e.g.:


It returns the value that is set in the composer.json (or through API). However when the value isn't set: can return null to indicate that or the default value.

If null the developer can decide what to do and ComposerConstants.DEFAULT_VENDOR_DIR has the default value. If it returns the default value, even if not set, the developer has no idea if that value is a user-set value or the returned default and must check the with getConfig().has("vendor-dir") if the value is set or not.

Another idea is a parameter that should return the default value, even if not set:


which will return the default value, if value isn't set?


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