4 ms·
Why use public string $x = ''; instead of public $x:string = ''; It seems inconsistent to me, probably because I've used AS3/Haxe.
by wambotron 13y ago
Why use
public string $x = '';
instead of
public $x:string = '';
It seems inconsistent to me, probably because I've used AS3/Haxe.
- Rican7 13y agoIts not just inconsistent with other languages, its consistent with their own language. Property types are declared before the property name, while function return types are declared after (and with a colon). Very strange.
- fzltrp 13y agoIf you look at the original C syntax for function types, it is also a bit weird: part of the type (the return type) is placed before, and part (the parameters) after. That syntax in hack seems more "functional" to me. That said, I must admit that I kind of like the C syntax, because of its oddity.
- fauigerzigerk 13y agoBut inconsistency is consistent with PHP's philosophy ;-)
- kreek 13y agoI too programmed for a long time in AS3/Haxe, and while I prefer variable:type as I think it's more readable, most static languages (java, C#) do it the other way.
- wambotron 13y agoYeah, I'm just not sure why they have public function get_name(): string but use public string $x = ''; The incosistency drives me a bit crazy.
- wvenable 13y agoPHP is based on C. It's way more consistent with C, Java, C# , etc to do the former. So the real question is why function foobar() : int { .. } instead of function int foobar() { .. }