Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

aggregate_info(3) [php man page]

AGGREGATE_INFO(3)							 1							 AGGREGATE_INFO(3)

aggregate_info - Gets aggregation information for a given object

SYNOPSIS
array aggregate_info (object $object) DESCRIPTION
Gets the aggregation information for the given $object. PARAMETERS
o $object - RETURN VALUES
Returns the aggregation information as an associative array of arrays of methods and properties. The key for the main array is the name of the aggregated class. EXAMPLES
Example #1 Using aggregate_info(3) <?php class Slicer { var $vegetable; function Slicer($vegetable) { $this->vegetable = $vegetable; } function slice_it($num_cuts) { echo "Doing some simple slicing "; for ($i=0; $i < $num_cuts; $i++) { // do some slicing } } } class Dicer { var $vegetable; var $rotation_angle = 90; // degrees function Dicer($vegetable) { $this->vegetable = $vegetable; } function dice_it($num_cuts) { echo "Cutting in one direction "; for ($i=0; $i < $num_cuts; $i++) { // do some cutting } $this->rotate($this->rotation_angle); echo "Cutting in a second direction "; for ($i=0; $i < $num_cuts; $i++) { // do some more cutting } } function rotate($deg) { echo "Now rotating {$this->vegetable} {$deg} degrees "; } function _secret_super_dicing($num_cuts) { // so secret we cannot show you ;-) } } $obj = new Slicer('onion'); aggregate($obj, 'Dicer'); print_r(aggregate_info($obj)); ?> The above example will output: Array ( [dicer] => Array ( [methods] => Array ( [0] => dice_it [1] => rotate ) [properties] => Array ( [0] => rotation_angle ) ) ) As you can see, all properties and methods of the Dicer class have been aggregated into our new object, with the exception of the class constructor and the method _secret_super_dicing SEE ALSO
aggregate(3), aggregate_methods(3), aggregate_methods_by_list(3), aggregate_methods_by_regexp(3), aggregate_properties(3), aggregate_prop- erties_by_list(3), aggregate_properties_by_regexp(3), deaggregate(3). PHP Documentation Group AGGREGATE_INFO(3)

Check Out this Related Man Page

GET_CLASS_VARS(3)							 1							 GET_CLASS_VARS(3)

get_class_vars - Get the default properties of the class

SYNOPSIS
array get_class_vars (string $class_name) DESCRIPTION
Get the default properties of the given class. PARAMETERS
o $class_name - The class name RETURN VALUES
Returns an associative array of declared properties visible from the current scope, with their default value. The resulting array elements are in the form of varname => value. In case of an error, it returns FALSE. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.0.3 | | | | | | | get_class_vars(3) will only return the properties | | | that can be accessed from the current scope. | | | | | 5.0.2 | | | | | | | Calling get_class_vars(3) will now expose all | | | the properties as an array, unlike previous be- | | | haviour where protected and private properties | | | were prefixed with nul bytes. | | | | | 5.0.1 | | | | | | | Calling get_class_vars(3) will expose all prop- | | | erties, as when converting an object to a class. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 get_class_vars(3) example <?php class myclass { var $var1; // this has no default value... var $var2 = "xyz"; var $var3 = 100; private $var4; // constructor function myclass() { // change some properties $this->var1 = "foo"; $this->var2 = "bar"; return true; } } $my_class = new myclass(); $class_vars = get_class_vars(get_class($my_class)); foreach ($class_vars as $name => $value) { echo "$name : $value "; } ?> The above example will output: var1 : var2 : xyz var3 : 100 Example #2 get_class_vars(3) and scoping behaviour <?php function format($array) { return implode('|', array_keys($array)) . " "; } class TestCase { public $a = 1; protected $b = 2; private $c = 3; public static function expose() { echo format(get_class_vars(__CLASS__)); } } TestCase::expose(); echo format(get_class_vars('TestCase')); ?> The above example will output: // 5.0.0 a| * b| TestCase c a| * b| TestCase c // 5.0.1 - 5.0.2 a|b|c a|b|c // 5.0.3 + a|b|c a SEE ALSO
get_class_methods(3), get_object_vars(3). PHP Documentation Group GET_CLASS_VARS(3)
Man Page