Page MenuHomePhabricator

Add support for nullable return types
ClosedPublic

Authored by joshuaspence on Sep 18 2017, 11:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 3:03 AM
Unknown Object (File)
Thu, Apr 11, 9:59 AM
Unknown Object (File)
Tue, Apr 9, 7:43 AM
Unknown Object (File)
Tue, Apr 9, 7:43 AM
Unknown Object (File)
Tue, Apr 9, 7:43 AM
Unknown Object (File)
Tue, Apr 9, 7:14 AM
Unknown Object (File)
Tue, Apr 9, 6:19 AM
Unknown Object (File)
Fri, Apr 5, 1:05 PM

Details

Summary

Ref T4334. Adds support for nullable return type, which are a thing as of PHP 7.1.

Test Plan

Updated test cases.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Sep 18 2017, 11:08 AM

Oh cool. I'm somewhat surprised this is being accepted as I expected it to be blocked on T4334#222499.

Do you want to just delete all the tests and I'll accept those and abandon D17819?

support/xhpast/parser.y
1089

I was trying to avoid adding a new node type (which is technically a breaking API change), but it seems necessary to accommodate nullability.

1089

This technically allows ?void, which is a fatal error... but I'm not sure it's worth special casing that here.

support/xhpast/xhpast.cpp
15

Actually, given that nullable types were added in PHP 7.1, maybe I'll bump this to 7.1.0.

Do you want to just delete all the tests and I'll accept those and abandon D17819?

I can if you want, but I think the tests are somewhat useful... if not only because they show me when a parser change has a bigger scope than I had anticipated. I think it would be good (or, at least, an improvement) to land D17819 or some variation thereupon, but I'm guessing it's not a priority.

wjiang added inline comments.
support/xhpast/parser.y
1089

Maybe we should add a new T_VOID token and exclude void from type.

support/xhpast/parser.y
1089

Yeah, that sounds reasonable. I'll do that in a separate diff though.

This revision was automatically updated to reflect the committed changes.