The poll on the main sitepoint page at current asks the user what they would like to do to rename the JavaScript ‘function’ keyword.
So, that make me think - what would you do to change PHP’s syntax?
Of course the characters must be available on the typical keyboard, so signs like the british pound £ and the euro aren’t viable.
I’d get rid of ‘$this->’ and ‘self::’ in object-oriented programming. I cannot stand it. I think methods and properties should be accessed like #method() and #property rather than $this->method() and $this->property (# is a comment operator, but it is rarely used compared to double-slashes //). I also think static functions and variables should be accessed with a double-colon alone, e.g. ::function() and :: property. (without the space; :: + p = : in vbulletin ;))
This would also apply in the declarations. I think the function keyword is unnecessary because the parser could tell whether it was a property or method.
I’d also allow multiple function declarations under the same function name but using different parameters. That would save quite a lot of framework-development pain!
I’d also allow arrays with the square braces, rather than the array function.
So ideally:
class Someclass{
#variable = 'hello';
#func(array $var){
printf($var);
}
#func($var1, $var2){
#func(['one' => $var1, 'two' => $var2]);
}
#__Construct(){
#func(#variable, 'world');
}
}
It looks a little confusing and the forum PHP highlighting certainly won’t help so I left it as plain code.
I’d find it necessary to have a distinction between global functions and object methods, because otherwise you wouldn’t be able to access typically-used functions if it is redefined in your class, which is supposedly common.
Of course, that’s just my idea of what I’d do - what would you do?