13c13
<    Time stamp: 2025-06-19 20:58:18
---
>    Time stamp: 2025-06-20 19:18:19
3739a3740,3742
> #      $this->echoBackTrace($trace,false);
> #      echo "Shown? ".var_export($trace[0]['shown'],true)."<br>\n";
> #      exit();
3744a3748
>     $this->echoBackTrace($trace,true);
3755a3760,3761
>       static $count = 0;
>       $count++;
3757,3758c3763,3773
<       while ($bt[$start]['function'] == '__call' || $bt[$start]['function'] == 'start')
<         $start++;
---
>       echo "<!-- Instance $count; depth: ".count($bt)." -->\n";
>       while ($start < count($bt))
>       {
>         if (gettype($bt[$start]['function']) != 'string')
>         {
>           echo "Expecting a string for function at index $start\n";
>           $this->echoBackTrace($bt,false);
>         }
>         if ($bt[$start]['function'] == '__call' || $bt[$start]['function'] == 'start')
>           $start++;
>       }
3761a3777,3778
>         if (array_key_exists('shown',$bt[0]))
>           echo "Processing $i<br>\n";
3843a3861,3961
>   # EXTREME DEBUGGING: Echo a backtrace and possibly exit
>   private function echoBacktrace(&$trace,$exit=false)
>   {
>     if (is_array($trace))
>     {
>       if (!array_key_exists('shown',$trace[0]))
>       {
>         $trace[0]['shown'] = true;
>         echo "Depth: ".count($trace)."<br>\n";
>         for ($i = 0; $i < count($trace); $i++)
>         {
>           echo "trace[$i][file]: ".    $this->echoBacktraceValue($trace[$i]['file'])."<br>\n";
>           echo "trace[$i][line]: ".    $this->echoBacktraceValue($trace[$i]['line'])."<br>\n";
>           echo "trace[$i][function]: ".$this->echoBacktraceValue($trace[$i]['function'])."<br>\n";
>           echo "trace[$i][class]: ".   $this->echoBacktraceValue($trace[$i]['class'])."<br>\n";
>           echo "trace[$i][object]: ".  $this->echoBacktraceValue($trace[$i]['object'])."<br>\n";
>           echo "trace[$i][type]: ".    $this->echoBacktraceValue($trace[$i]['type'])."<br>\n";
>           for ($j = 0; $j < count($trace[$i]['args']); $j++)
>           {
>             echo "trace[$i][args][$j]: ".$this->echoBacktraceValue($trace[$i]['args'][$j])."<br>\n";
>           }
>         }
>         echo "--------------------------------------------------<br>\n";
>       }
>     } else {
>       echo "\$trace: ".$this->echoBacktraceValue($trace,true)."<br>\n";
>     }
>     if ($exit)
>     {
>       echo "Exiting...<br>\n";
>       exit();
>     }
>   }
> 
>   private function echoBacktraceValue($v)
>   {
>     if (is_object($v))
>     {
>       return 'object class '.get_class($v);
>     } elseif (is_array($v)) {
>       if (count($v) == 2 && is_object($v[0]) && gettype($v[1]) == 'string')
>       {
>         return get_class($v[0]).'::'.$v[1];
>       } else {
>         return 'array['.count($v).']';
>       }
>     }
>     return gettype($v).' '.var_export($v,true);
>   }
> 
>   private function checkBacktrace($trace)
>   {
>     if (!is_array($trace))
>       return array(false,'backtrace is not an array; is '.gettype($trace));
> 
>     if (!is_array($trace))
>       return array(false,'backtrace is not a simple array; keys: '.array_keys($trace));
> 
>     $keys = array('file','line','function','class','object','type');
>     for ($i = 0; $i < count($trace); $i++)
>     {
>       $missing = array();
>       foreach ($keys as $field => $type)
>       {
>         if (!array_key_exists($field,$trace[$i]))
>           array_push($missing,$field);
>       }
>       if (count($missing) > 0)
>         return array(false,'index '.$i.': missing '.implode(',',$missing));
>     }
>   }
> /*
>       if (!array_key_exists('shown',$trace[0]))
>       {
>         $trace[0]['shown'] = true;
>         echo "Depth: ".count($trace)."<br>\n";
>         for ($i = 0; $i < count($trace); $i++)
>         {
>           echo "trace[$i][file]: ".    $this->echoBacktraceValue($trace[$i]['file'])."<br>\n";
>           echo "trace[$i][line]: ".    $this->echoBacktraceValue($trace[$i]['line'])."<br>\n";
>           echo "trace[$i][function]: ".$this->echoBacktraceValue($trace[$i]['function'])."<br>\n";
>           echo "trace[$i][class]: ".   $this->echoBacktraceValue($trace[$i]['class'])."<br>\n";
>           echo "trace[$i][object]: ".  $this->echoBacktraceValue($trace[$i]['object'])."<br>\n";
>           echo "trace[$i][type]: ".    $this->echoBacktraceValue($trace[$i]['type'])."<br>\n";
>           for ($j = 0; $j < count($trace[$i]['args']); $j++)
>           {
>             echo "trace[$i][args][$j]: ".$this->echoBacktraceValue($trace[$i]['args'][$j])."<br>\n";
>           }
>         }
>         echo "--------------------------------------------------<br>\n";
>       }
>     } else {
>       echo "\$trace: ".$this->echoBacktraceValue($trace,true)."<br>\n";
>     }
>     if ($exit)
>     {
>       echo "Exiting...<br>\n";
>       exit();
>     }
> */
> 
