Hi, > On 14 Feb 2015, at 05:03, Xinchen Hui <larue...@php.net> wrote: > > Hey: > be honest, I think it's only part of the idea is implemented. > > which make it useless. > > in PHP, even if you don't return anything, NULL is returned implicitly. > > even if a function is declared return nothing(void). > > like: > > function a() : void {}; > > following codes still works: > > $b = a(); > > so, if you want a void return type, and if you want it to be a useful > feature.. > > above expr should be invalid with an error " a() return nothing"
I'm not sure about this. PHP has always made functions valid rvalues, for better or for worse. This RFC could make void functions "truly" void, but that would be a massive change to support value-less function returns. It would also break existing code which assumes all functions return a value, which isn't good. I think this RFC is enough: it would let you enforce that a function doesn't return anything and makes code more self-documenting. It doesn't affect anything trying to use the function's implicit return value of NULL, but IDEs and code linters would surely pick up on it for you. It's still useful even if it doesn't bind the caller. Thanks. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php