class math {
/**
* tracing the arguments and the returned parameter
*
* note that traceReturn() calls traceArguments() by default which is fine here
* since this method does call other methods to trace
*/
public static function prod($x, $y)
{
// class_exists('PHP_FunctionCallTracer', false)
// and PHP_FunctionCallTracer::traceArguments();
$p = $x * $y;
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceReturn($p);
return $p;
}
/**
* tracing the arguments and the returned parameter
*
* traceArguments() must be called here since this method calls other methods
* that may be traced, so that traced calls are displayed in the right order
*/
public static function square($x)
{
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceArguments();
$x2 = self::prod($x, $x);
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceReturn($x2);
return $x2;
}
}
class geometry {
private $pi = 3.14;
/**
* tracing the arguments and the returned parameter
* another variable is traced along with the returned parameter
*/
public function circle($r)
{
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceArguments();
$pi2 = 2 * $this->pi;
$c = math::prod($r, $pi2);
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceReturn($c, $pi2);
return $c;
}
/**
* tracing the arguments, some variables and the returned parameter
*/
public function disk($r)
{
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceArguments();
$r2 = math::square($r);
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceVariables($r2, $this->pi);
$d = math::prod($r2, $this->pi);
class_exists('PHP_FunctionCallTracer', false) and
PHP_FunctionCallTracer::traceReturn($d);
return $d;
}
} |