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.      *
  14.      * note that traceReturn() calls traceArguments() by default which is fine here
  15.      * since this method does call other methods to trace
  16.      */
  17.     public static function prod($x$y)
  18.     {
  19.         // class_exists('PHP_FunctionCallTracer', false) and
  20.         // PHP_FunctionCallTracer::traceArguments();
  21.         $p $x $y;
  22.  
  23.         class_exists('PHP_FunctionCallTracer'falseand
  24.         PHP_FunctionCallTracer::traceReturn($pand
  25.  
  26.         return $p;
  27.     }
  28.  
  29.     /**
  30.      * tracing the arguments and the returned parameter
  31.      *
  32.      * processing all arguments (true means all)
  33.      *
  34.      * traceArguments() and/or processVariables() must be called here
  35.      * since this method calls other methods
  36.      * that may be traced, so that traced calls are displayed in the right order
  37.      *
  38.      * note that processVariables() calls traceArguments() by default
  39.      */
  40.     public static function square($x)
  41.     {
  42.         class_exists('PHP_FunctionCallTracer'falseand
  43.         // PHP_FunctionCallTracer::traceArguments() and
  44.  
  45.         $x2 = self::prod($x$x);
  46.  
  47.         class_exists('PHP_FunctionCallTracer'falseand
  48.         PHP_FunctionCallTracer::traceReturn($x2);
  49.         return $x2;
  50.     }
  51. }
  52.  
  53. class geometry {
  54.     private $pi = 3.14;
  55.  
  56.     /**
  57.      * tracing the arguments and the returned parameter
  58.      * another variable is traced along with the returned parameter
  59.      *
  60.      * processing the first and the second returned parameters
  61.      */
  62.     public function circle($r)
  63.     {
  64.         class_exists('PHP_FunctionCallTracer'falseand
  65.  
  66.         $pi2 = 2 * $this->pi;
  67.         $c math::prod($r$pi2);
  68.  
  69.         class_exists('PHP_FunctionCallTracer'falseand
  70.         PHP_FunctionCallTracer::traceReturn($c$pi2and
  71.         PHP_FunctionCallTracer::processVariables(01);
  72.         return $c;
  73.     }
  74.  
  75.     /**
  76.      * tracing the arguments, some variables and the returned parameter
  77.      *
  78.      * processing the second traced variable only
  79.      */
  80.     public function disk($r)
  81.     {
  82.         class_exists('PHP_FunctionCallTracer'falseand
  83.  
  84.         $r2 math::square($r);
  85.         class_exists('PHP_FunctionCallTracer'falseand
  86.         PHP_FunctionCallTracer::traceVariables($r2$this->piand
  87.  
  88.         $d math::prod($r2$this->pi);
  89.  
  90.         class_exists('PHP_FunctionCallTracer'falseand
  91.         PHP_FunctionCallTracer::traceReturn($d);
  92.         return $d;
  93.     }
  94. }
  95.  
  96. ?>

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