Project

General

Profile

Actions

Feature #23472

closed

Introducing t3lib_div::getObjectEnv($input) and t3lib_div::getType ($input)

Added by David Bruchmann about 14 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
-
Target version:
-
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

t3lib_div.20100828_01.diff (1.92 KB) t3lib_div.20100828_01.diff Administrator Admin, 2010-08-28 12:42
Actions #1

Updated by David Bruchmann about 14 years ago

As additional information:

I need the functions for changes in t3lib_div, so there is no option to note them in an extension.

Actions #2

Updated by Benni Mack about 14 years ago

As stated by the author in the TYPO3 Core list, this bug can be closed.

Actions

Also available in: Atom PDF