0

This may be a stupid question, but I need to know how to cast a variable in zf2.

$var = (string) $id ;

How ca I do it with this kind of type :

\MediaLayer\Argument\SelectMediaArguments

This doesn't work:

$arg = (\MediaLayer\Argument\SelectMediaArguments) $var
justSaid
  • 1,540
  • 2
  • 12
  • 23

1 Answers1

3

There is no need to type cast in php.

i could be wrong but i a, guesting that you want you IDE to recognize the $var az the selected class , in that case you need to use phpdoc block :

/* @var $var \MediaLayer\Argument\SelectMediaArguments */
$var = X;

if this is not what you want please be more clear because there is not object casting in php

also Type casting for user defined objects

Community
  • 1
  • 1
Exlord
  • 5,009
  • 4
  • 31
  • 51