Add and use isArray() and isString() methods to Core Loader. #98
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.
Provide PHP enumerations that can perform the appropriate checks themselves.
I considered implementing the logic within the
CoreFunctionsbut opted to keep all of the verification logic self-contained within the enumerations themselves.This allows for the reduction of the extra type parameter.
The enumeration knows its own type and can perform the appropriate check.
This is designed to ensure that all appropriate checks are performed in order to guarantee that a boolean is returned.
The caller need only perform the
is()or thein()check using the appropriate configuration type.Only the most simplistic types are chosen.
If additional php
is_*()types are needed, then enumerations may be added.The special
NULLsupporting types are done to reduce the needed checks should something care to check if the type is either NULL or a given type.This doesn't increase the code complexity much at all and the use should reduce code complexity.
The
NULLchecks need to be performed anyway.A specific type
ANYcan be used to test if a configuration type exists as is NULL.The
in()method allows for array key existence checks and then a type check on some child property.This should allow for shallow array value type checks.
The non-
$configbasedisset()andis_string()checks are reverted to previous behavior.This should allow for the configuration checks to be performed anywhere without warnings or problems.
Original Description and Design
These allow for cleaner existence checks on arrays without PHP warnings or problems.
An
isset()must be called to safely perform something likeis_string()on a value at some array index.Adding an
isset()inline can make the code messier so move this logic out into two methods:isArray().isString().Update all code in
CoreLoaderclass to utilize these methods.This approach was changed to the enum functions approach based on this comment: