"must be an instance of int, integer given"!?

Hi guys, have a bit of a problem here. Hope someone can help me out:


Class Test
{
  public function __construct()
  {
  }

  public static function Apple(int $a)
  {
     return 0;
  }
}

///////////////////////////////////////

Test::Apple(1);


And its giving me the following error: “Argument 1 passed to Test::Apple() must be an instance of int, integer given, called in…”

Any help appreciated.

Try this:

Test::Apple((int)1);

btw, unless you are strict on it being an integer, you don’t need the “int” keyword in the function variable definition.

Hope that helps,
Jake Arkinstall

Hey Jake,

I tried casting it to an integer without luck. After some searching, I think it seems that PHP does not support type-hinting for the standard data types (int, doubles), but does support type-hinting of objects (phew!).

Any other opinions appreciated!