Releases: PhpGt/Input
"or" function
On top of the call
functionality, it is now possible to set a callback function to call when the current input trigger is not triggered.
Improved consistency
No new features have been added since v0.4, only consistency improvements. After resolving the final v1 issues from the issue tracker, today marks the release of v1 of the PHP.Gt/Input repository.
Main improvements are:
- Implementation of PSR 7's UploadedFileInterface, allowing interoperability between other areas of PHP.Gt using the PHP.Gt/Http repository.
asArray
- naming compatibility with other PHP.Gt repositories.- The
Input
class is now mutable, allowing extra parameters to be added after initial construction.InputData
classes are still immutable, so this allows the framework to add properties without exposing the functionality to user code. - Return types of all get* functions are improved for readability and predictability.
File upload improvements
Simplification of how Input handles file uploads. There will probably be more small changes made as the FileUpload classes are tested fully.
The InputValueGetter
trait has also been introduced, which allows the Input
class to be used as if it were InputData
itself.
Improvements to two key functions
Multiple value parameter support (array fields)
This is the final new feature towards v1 release.
It adds support for array fields using square-bracket notation.
More tests will be written and example applications will be created before v1 release.
General API improvements
- More meaningful exceptions thrown.
- Tests' data providers improved.
- All parameters passed if there is no
when
in the trigger. - Different parameter types can be cast using getter functions on
InputData
.
FileUpload support
The main changes in this release consist of the way the three array-like objects are handled internally; QueryStringInputData
, BodyInputData
and FileUploadInputData
now all extend the same base class, InputData
allowing a consistent API with extended functionality where necessary.
FileUploadInputData
is a new array-like object used to access the user-uploaded files, introduced by this release. The object unwraps the $_FILES
superglobal into a data structure that makes sense, finally representing the individual files as FileUpload
objects.
Improve API design while moving towards FileUpload support
Two issues have come together to drastically improve the library:
FileUpload support is required now that key-value-pairs work.
An improvement to how callbacks are triggered required refactoring.
This update includes a large refactor compromising mainly of the following:
Classes broken out into more granular parts.
Namespaces bundle similar classes together.
All user input types, including FileUpload, extend common base class AbstractInputData.
All values of user input are handled as InputDatum instances.
API changes
As unit test coverage increases, APIs change.
The Input
class itself shares its data access methods with the InputData
class for ease of use and quick on-the-fly data access.
Accessing data is done using ArrayAccess now, rather than property access, due to the StyleGuide specifying "Only properties should be used when a predefined set of data attributes can be determined".
Input class fully tested
The basics are working. The Input class can be constructed from the $_GET, $_POST and $_FILES arrays. with(), without(), withAll() have been tested when calling them on the Input class themselves, and the correct callbacks are called.