Skip to content

HHI: Change the options arrays for dispatchers to shapes - #83

Merged
nikic merged 4 commits into
nikic:masterfrom
fredemmott:fastroute-hhi
Dec 20, 2015
Merged

HHI: Change the options arrays for dispatchers to shapes#83
nikic merged 4 commits into
nikic:masterfrom
fredemmott:fastroute-hhi

Conversation

@fredemmott

Copy link
Copy Markdown
Contributor

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> from array<string, string>

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>`.
@fredemmott

Copy link
Copy Markdown
Contributor Author

cc @SiebelsTim

@fredemmott fredemmott changed the title Change the options arrays for dispatchers to shapes HHI: Change the options arrays for dispatchers to shapes Dec 11, 2015
Comment thread FastRoute.hhi Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are classnames actually. Can we typehint them as those?

@SiebelsTim

Copy link
Copy Markdown
Contributor

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.
However, I don't feel strongly about this as the shapes can catch errors an array typehint would not.

@nikic

nikic commented Dec 11, 2015

Copy link
Copy Markdown
Owner

I'm fine with the BC break, as the HHI file probably isn't being used a lot.

@fredemmott

Copy link
Copy Markdown
Contributor Author

Cool - I'llsee about changing this to use ?classname<Dispatcher> and friends instead of ?string

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.
@fredemmott

Copy link
Copy Markdown
Contributor Author

The Travis HHVM check will fail as Travis is still on HHVM 3.6 (EOL: 2016-01-28), and classname<T> was introduced in 3.9

@nikic

nikic commented Dec 12, 2015

Copy link
Copy Markdown
Owner

@fredemmott It looks like the HHVM check timed out. Is that expected as well?

@fredemmott

Copy link
Copy Markdown
Contributor Author

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?

@nikic

nikic commented Dec 12, 2015

Copy link
Copy Markdown
Owner

@fredemmott I'd rather skip the test :)

@fredemmott

Copy link
Copy Markdown
Contributor Author

Force-pushed with the version check amended on. I'll still investigate 3.6, but might as well check this works over the weekend :)

@fredemmott

Copy link
Copy Markdown
Contributor Author

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.

nikic added a commit that referenced this pull request Dec 20, 2015
HHI: Change the options arrays for dispatchers to shapes
@nikic
nikic merged commit 8164b4a into nikic:master Dec 20, 2015
@nikic

nikic commented Dec 20, 2015

Copy link
Copy Markdown
Owner

Thanks for your work on this! I've tagged a release including these changes: https://github.com/nikic/FastRoute/releases/tag/v0.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants