oop - Why is it possible to have an interface without a return type in PHP? -


Why is it possible to create an interface without specifying the return type? Why does not it waste this interface?

This makes it more obvious:

  interface run {public function getInteger (); } Class applies MyString {public function myNumber () {} public function getInteger () {return "no number"; In every interface in Java,  integer ,  string  or  zero  

I know that PHP is unfortunately typed in a loose Language but is not the solution to that problem?

Is return type like Integer ?

The signal type for function / method arguments or return values ​​is only supported on PHP7.0 or later

Check the details here:

If you are using PHP5, then the current approved practice is to use comments to indicate "contract".

  / ** * does something * @ layer intact ** / public event getInteger () {return 1; } If the code "contravenes the contract," then I suggest finding and repairing the original codec and filing the bug and / or setting it yourself if it is in your own codebase. 


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -