> function add( ... ): float {}
I think a much better choice would have been:
> float function add( ... ) {}
Or just:
> float add( ... ) {}
Since that's how it's done in other languages and people would feel at home with it.
> function add( ... ): float {}
I think a much better choice would have been:
> float function add( ... ) {}
Or just:
> float add( ... ) {}
Since that's how it's done in other languages and people would feel at home with it.
The thing you mention ("float function add(){}") keeps the option to search for "function add", but I am unsure why this is not taken into account in this proposal.
Anyhow, I am pretty happy this finally made it to the php language.
[1] https://wiki.php.net/rfc/return_types#position_of_type_decla...
Which if you read it out, it sounds entirely natural "This is a function called foo, which takes some params, and returns a float". Most of the other variants don't read as naturally.
> Since that's how it's done in other languages and people would feel at home with it.
PHP doesn't need to copy the mistakes of other languages. It's got plenty of its own mistakes.
It makes very little sense for PHP. A function definition now even has both styles:
`function foo(argtype arg) : rettype` instead of `function rettype foo(argtype arg)` or `function foo(arg : argtype) : rettype`.
But then, it wouldn't be PHP if it was too consistent ;).
function foo(a:int,b:string):bool{}
in PHP this will be function foo(int a,string b):bool{}Everything old is new again.