This repository was archived by the owner on Aug 25, 2025. It is now read-only.
addReturn/returnCase consistency, support for lambda value renderers
addReturn() and returnCase() consistency
These methods now take an IHackBuilderValueRenderer instance to be consistent with other methods such as addAssignment and addValue.
This means that addReturn('literal') is no longer valid - you can replace it with any of:
addReturn($any_literal, HackBuilderValues::literal())addReturnf('some literal with no placeholders')addReturnf('%s', $any_literal)
A similar change is needed for returnCase() -returnCasef() has also been added to this release
Lambda key/value renderers
If you need to generate code for a value in a way that hack-codegen doesn't have built-in support, you now have 3 options:
- pre-process the data and use
HackBuilderValues::literal()orHackBuilderKeys::literal() - add a new class implements
IHackBuilderValueRenderer<T>orIHackBuilderKeyRenderer<T> - use
HackBuilderKeys::lambda(($config, $value) ==> 'code')orHackBuilderValues::lambda(($config, $value) ==> $code)
The lambda approach is especially useful for containers.