PHP_FunctionCallTracer
[ class tree: PHP_FunctionCallTracer ] [ index: PHP_FunctionCallTracer ] [ all elements ]

Source for file package.php

Documentation is available at package.php

  1. <?php
  2. /**
  3.  * this is an example of a package
  4.  *
  5.  * calls to the tracer are added wherever there is a need to trace a function call
  6.  * these calls can be left in the package, they are executed only if the tracer is loaded
  7.  */
  8. class math {
  9.     /**
  10.      * tracing the arguments and the returned parameter
  11.      *
  12.      * processing all return returned variables (empty means all)
  13.      * the first user function is used by defaut
  14.      *
  15.      * note that traceReturn() calls traceArguments() by default which is fine here
  16.      * since this method does call other methods to trace
  17.      */
  18.     public static function prod($x$y)
  19.     {
  20.         // class_exists('PHP_FunctionCallTracer', false) and
  21.         // PHP_FunctionCallTracer::traceArguments();
  22.         $p $x $y;
  23.  
  24.         class_exists('PHP_FunctionCallTracer'falseand
  25.         PHP_FunctionCallTracer::traceReturn($pand
  26.  
  27.         return $p;
  28.     }
  29.  
  30.     /**
  31.      * tracing the arguments and the returned parameter
  32.      *
  33.      * processing all arguments (true means all) with the second user function is used
  34.      *
  35.      * traceArguments() and/or processVariables() must be called here
  36.      * since this method calls other methods
  37.      * that may be traced, so that traced calls are displayed in the right order
  38.      *
  39.      * note that processVariables() calls traceArguments() by default
  40.      */
  41.     public static function square($x)
  42.     {
  43.         class_exists('PHP_FunctionCallTracer'falseand
  44.         // PHP_FunctionCallTracer::traceArguments() and
  45.         PHP_FunctionCallTracer::processVariables(nulltrue);
  46.  
  47.         $x2 = self::prod($x$x);
  48.  
  49.         class_exists('PHP_FunctionCallTracer'falseand
  50.         PHP_FunctionCallTracer::traceReturn($x2);
  51.         return $x2;
  52.     }
  53. }
  54.  
  55. class geometry {
  56.     private $pi = 3.14;
  57.  
  58.     /**
  59.      * tracing the arguments and the returned parameter
  60.      * another variable is traced along with the returned parameter
  61.      *
  62.      * processing the first and the second returned parameters
  63.      * the first one with the second user function and
  64.      * the second one with the third user function
  65.      */
  66.     public function circle($r)
  67.     {
  68.         class_exists('PHP_FunctionCallTracer'falseand
  69.  
  70.         $pi2 = 2 * $this->pi;
  71.         $c math::prod($r$pi2);
  72.  
  73.         class_exists('PHP_FunctionCallTracer'falseand
  74.         PHP_FunctionCallTracer::traceReturn($c$pi2and
  75.         PHP_FunctionCallTracer::processVariables(nullarray(0)array(1));
  76.         return $c;
  77.     }
  78.  
  79.     /**
  80.      * tracing the arguments, some variables and the returned parameter
  81.      *
  82.      * processing the first and second traced variables with the third user function
  83.      */
  84.     public function disk($r)
  85.     {
  86.         class_exists('PHP_FunctionCallTracer'falseand
  87.  
  88.         $r2 math::square($r);
  89.         class_exists('PHP_FunctionCallTracer'falseand
  90.         PHP_FunctionCallTracer::traceVariables($r2$this->piand
  91.         PHP_FunctionCallTracer::processVariables(nullnullarray(01));
  92.  
  93.         $d math::prod($r2$this->pi);
  94.  
  95.         class_exists('PHP_FunctionCallTracer'falseand
  96.         PHP_FunctionCallTracer::traceReturn($d);
  97.         return $d;
  98.     }
  99. }
  100.  
  101. ?>

Documentation generated on Mon, 11 Mar 2019 15:09:41 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.