Type of hint and reason (s) for their limitations

Whether object, and arrayreally the only types allowed to be a hint of the type?

In addition, they declare in the documentation that they are standard types stringand intalso cannot be printed.

And that makes me more curious. What is the reason only for resolving the two types and reducing the standard?

Thanks in advance!

+5
source share
2 answers

Currently, PHP 5.3 only supports arrayand tags ClassName.
The upcoming version of PHP 5.4 also supports callabletypehints.

, , , :

  • , 1 '1'? → PHP
  • PHP-? 'hallo' 0 int typehint → Unintuitive
  • ?

, PHP 5.4 - .

+8

, , .

http://www.php.net/manual/en/language.oop5.typehinting.php

. :

( PHP 5.1). hinting int string .

0

All Articles