aggregate_info
(PHP 4 >= 4.3.0)
aggregate_info — Gets aggregation information for a given object
说明
array aggregate_info ( object $object )Gets the aggregation information for the given object.
参数
- object
-
返回值
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.
范例
Example #1 Using aggregate_info() 以上例程会输出:
<?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));
?>
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()
参见
- aggregate() - Dynamic class and object aggregation of methods and properties
- aggregate_methods() - Dynamic class and object aggregation of methods
- aggregate_methods_by_list() - Selective dynamic class methods aggregation to an object
- aggregate_methods_by_regexp() - Selective class methods aggregation to an object using a regular expression
- aggregate_properties() - Dynamic aggregation of class properties to an object
- aggregate_properties_by_list() - Selective dynamic class properties aggregation to an object
- aggregate_properties_by_regexp() - Selective class properties aggregation to an object using a regular expression
- deaggregate() - Removes the aggregated methods and properties from an object