Ok, I see where I went too Java in this.
So here's a refinement of what I think PHP should have (optionally):
- Return types specified. Any syntax, as long as you can. Personally, I'd prefer:
So replace function with whatever the return type is - but still allow function.PHP Code:<?php
string uselessFunction($string){
return $string; //must be a string.
}
?>
Another way could be:
That's more user friendly but more lengthy - but the 'returns' could be abreviated to _ or something, i.e:PHP Code:<?php
function uselessFunction($string) returns string{
return $string;
}
?>
PHP Code:<?php
function uselessFunction($string) _ string{
}?>- More type hinting! Yeah, you can specify a type of object or implementation. I mean full:
That surely can't cause issues, especially because (a)the manual has the types listed anyway and (b)it would be optional.PHP Code:function uselessFunction(string $string){
- The ability to use an ordinary variable as it's object. For example:
Again, optional, but I think it would revolutionise PHP's functions - especially because they're so jumbled up as they are.PHP Code:$str = "hello";
echo $str->replace('h', 'H');
All of the above wouldn't mess up current code, but it would surely help make code cleaner and more structured.
Agree?








Bookmarks