This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
Use hack-codegen v2.1, use shapes for URIBuilders and request parameters
Pre-release
Pre-release
Documentation is still the blocker on moving out of RC state.
Hack-Codegen
facebook/hack-codegen v2.1 or above is now required; the 2.x series is a major break from 1.x; please see:
Shapes for URIBuilders
Old:
$uri = (new FooControllerUriBuilder())->setHerp('herp')->setDerp('derp')->getPath();
// or, if using trait:
$uri = FooController::getUriBuilder()->setHerp('herp')->setDerp('derp')->getPath();
New:
$uri = FooControllerUriBuilder::getPath(shape('herp' => 'herp', 'derp' => 'derp'));
// or, if using trait:
$uri = FooController::getPath(shape('herp' => 'herp', 'derp' => 'derp'));
The primary benefit is that instead of depending on runtime enforcement, the typechecker will now tell you if you are missing a required parameter.
Shapes for request parameters
Old:
$foo = $this->getParameters()->getFoo();
New:
$foo = $this->getParameters()['foo'];
The benefits are:
- consistency with URI builders
- able to easily get a link to the current page by passing the request parameters shape directly to the URI builder
- If you use the trait, you only need to specify how to get the underlying non-codegen parameters object, not provide the full method implementation.
Misc
- added
<<Codegen>>
attribute to generated classes and tests - added
discardChanges
bool option to configuration shape; this will ignore signatures, and remove any changes outside of manual sections.