Actions
Feature #23472
closedIntroducing t3lib_div::getObjectEnv($input) and t3lib_div::getType ($input)
Start date:
2010-08-28
Due date:
% Done:
0%
Estimated time:
PHP Version:
4.3
Tags:
Complexity:
Sprint Focus:
Description
Hi,
I'd like to add two new methods to t3lib_div.
Due to some planned changes I need them and think they are useful in global scope.
t3lib_div::getType($input) returns type-information about a variable because it's not very smooth to do it each required case inline somewhere ...
t3lib_div::getObjectEnv($input) returns the enviroment of an object. It uses all available, concerning functions of PHP to build an array with information about the object.
Furthermore each method is integrated in a new section.
/*************************
*
* TYPE FUNCTIONS
******************/
/**
* Returns the type-information for $input.
*
* @param mixed input to test for type
* @return string type of input as string
*/
public static function getType ($input) {
$type = 'string';
if (is_array($input)) $type = 'array';
elseif (is_object($input)) $type = 'object';
elseif (is_resource($input)) $type = 'resource';
elseif (is_int($input)) $type = 'int';
elseif (is_float($input)) $type = 'float';
elseif (is_bool($input)) $type = 'bool';
return $type;
}
/*************************
*
* OBJECT-FUNCTIONS
******************/
/**
* Returns an Array with Information about an Object.
* For Details look at the Function below and the used PHP-Functions in the PHP-Manual.
*
* @param mixed Should be of Type Object but can be of any Type.
* @return array Object-Information or empty if $input is no Object
*/
public static function getObjectEnv($input) {
$obj = array();
if (is_object($input)) {
$class = get_class($input);
$obj = array(
'Type' => 'object',
'Classname' => $class,
'Parent Class' => get_parent_class($class),
'Methods' => get_class_methods($class),
'Class Variables' => get_class_vars($class),
'Object Variables' => get_object_vars($input),
'Implemented Interfaces' => class_implements($class)
);
}
return $obj;
}
(issue imported from #M15585)
Files
Actions