HHI: Change the options arrays for dispatchers to shapes - #83
Conversation
It's currently not possible to specify the cacheDisabled option, as it is a bool. To fix, actually define the acceptable options and their types. HHVM allows nullable shape fields to not be specified. This is BC breaking, as it must now be passed in as a shape instead of an array. A non-BC-breaking alternative would be to change the array to `array<string, mixed>`.
|
cc @SiebelsTim |
There was a problem hiding this comment.
these are classnames actually. Can we typehint them as those?
|
I got all of my information from the documentation or source code. I did not look thoroughly, so I might have done some mistakes like here. Having the shapes seems more correct. It is very unfortunate that we can't pass an array to them tough. |
|
I'm fine with the BC break, as the HHI file probably isn't being used a lot. |
|
Cool - I'llsee about changing this to use |
Allows the typechecker to be ran against this in isolation. Doesn't affect projects pulling this in via composer, as hhconfig outside of the root are ignored. assume_php=false makes the typechecker complain about classes that it doesn't know about, instead of assuming they're defined in PHP instead.
|
The Travis HHVM check will fail as Travis is still on HHVM 3.6 (EOL: 2016-01-28), and |
|
@fredemmott It looks like the HHVM check timed out. Is that expected as well? |
|
It's not :( Ill look into that on Monday. Once that's resolved, would you rather change to strings to support the 3.6 type checker, or skip that test on <3.9? |
|
@fredemmott I'd rather skip the test :) |
8dff260 to
9922e64
Compare
|
Force-pushed with the version check amended on. I'll still investigate 3.6, but might as well check this works over the weekend :) |
|
This reliably hangs hh_server/hh_client on 3.6: <?hh // decl
namespace FastRoute {
function cachedDispatcher(
shape(
'routeParser' => classname<RouteParser>,
) $options): Dispatcher;
}It errors out (correctly, given changes to shapes and classnames) if I skip the namespace. Tested with the 3.9 LTS package on ubuntu, that's fine. Given this is features that aren't supported in 3.6 and 3.6 dies in January anyway, I think this is good to go in anyway. |
HHI: Change the options arrays for dispatchers to shapes
|
Thanks for your work on this! I've tagged a release including these changes: https://github.com/nikic/FastRoute/releases/tag/v0.7.0 |
It's currently not possible to specify the cacheDisabled option, as it
is a bool. To fix, actually define the acceptable options and their
types.
HHVM allows nullable shape fields to not be specified.
This is BC breaking, as it must now be passed in as a shape instead of
an array.
A non-BC-breaking alternative would be to change the array to
array<string, mixed>fromarray<string, string>