- settype: documentation ( source)
<?php
/**
* @author: hakre <http://hakre.wordpress.com>
* @link http://stackoverflow.com/a/17628617/367456
*/
/**
* dereference a value and optionally setting its type
*
* @param mixed $mixed
* @param null $type (optional)
*
* @return mixed $mixed set as $type
*/
function rettype($mixed, $type = NULL) {
$type === NULL || settype($mixed, $type);
return $mixed;
}
$array = Array('status' => 'Figure A. ...');
echo rettype($array, 'object')->status; // prints "Figure A. ..."