Auth\Basic: add input validation to constructor #574
Merged
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.
The
Basic::__construct()
method expects to receive an array of exactly two element and did validate the input received, but only threw an exception when the passed parameter did not match the expected element count, not when the passed parameter wasn't an array.At the same time, the default value of
$args
isnull
, not an empty array and the$user
and$pass
properties are both public.The only reason I can think of to have these properties
public
and the default value set tonull
, is to allow for delayed setting of the$user
and$pass
, after the class has already been instantiated.To maintain the existing behaviour, but still add input validation, an exception is now thrown when the
$args
parameter is neither an array, nornull
.Includes;
$user
and$pass
directly on the instantiated object. This test is solely added to document that this is a supported feature (and to safeguard against regressions in that respect).