RealyUniqueName / haxe

Haxe - The Cross-Platform Toolkit

Home Page:http://haxe.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

type hints

mockey opened this issue · comments

Did you consider adding type hints to php output?

I did and had to refuse using hints.
E.g. this is a perfectly valid code which returns null

function get () : some.MyClass {
    return null;
}

With type hinting it will be generated like this:

function get() : MyClass {
   return null;
}

And you will get runtime erorr trying to call this method:

PHP Fatal error:  Uncaught TypeError: Return value of Test::get() must be an instance of \some\MyClass, null returned

The same applies to function arguments

IMO generated docblocks are good enough to let IDE (like phpStorm) provide correct autocompletion on generated code

I see. I this just a problem with null or is there more to it?
I haven't really used type hint so far, don't know if they are useful at all.

They help to pinpoint type-related bugs early when using PHP.
But it's hard to get type-related bugs with Haxe )

So, no type-hinting in generated php code for now