Introduce ConfigValidatorInterface
for minimum runtime validation of SM configurations
#189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Starting with v4.0.0, the
ServiceManager
itself will not validate anymore as it provides psalm array-shape type for configuration values.As per existing projects, the
ServiceManager
is usually configured somehow like these examples:The first example does use deprecated
Config
instance which just verified that pre-defined array keys are provided.The second example does not verify anything and assumes the config to be correct.
Both cases do either need a psalm-baseline entry or a
psalm-suppress
once migrated to SM v4.0.0 (at least the second example already needs that as it uses theServiceManager#__construct
which is already properly typed.Closes #131
So every pluginmanager providing component (such as
laminas-cache
,laminas-form
, etc. - I've listed some more in the TSC meeting) would also need either a baseline entry or suppression due to the fact that there is no current way to verify that configuration matches expectations.To avoid that, we could in fact use a runtime configuration validator which is provided by this PR.
I have not yet a clue on how to effectively use it, as I would actually prefer to only validate prior configuration caching so that not every request has to validate the same valid/invalid config over and over again. I've created this PR as a draft so that we can find a way of how to effectively use such a validator. In mezzio projects, having this as some kind of
PostProcessor
forconfig-aggregator
would work but that won't work for i.e. laminas-formWould love to get some help here.