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

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