Releases: phpgt/Input
Loosen dependencies
For consistency, all PHP.Gt repositories are adopting a "* by default" dependency policy for internal dependencies. This will make future merges simpler.
Dependency bump
A number of internal PhpGt releases are made this week. This patch release synchronises all repositories.
Changes to nullable type returning
For all get* functions on InputDataGetter classes, there is now a slightly modified behavior. Apart from with getString, if the input data contains an empty string, it is represented by null, rather than the default for that type.
This means that if there is a number input on the page, and the user does not enter any data into it, calling getInt() on that field will now return null instead of 0 - properly representing an absence of data, without making any assumptions.
This is a minor release, due to minor backwards breaking changes.
"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
Inputclass is now mutable, allowing extra parameters to be added after initial construction.InputDataclasses 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
whenin 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.