summaryrefslogtreecommitdiff
path: root/framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php
diff options
context:
space:
mode:
authorxue <>2006-09-23 01:51:57 +0000
committerxue <>2006-09-23 01:51:57 +0000
commita5467e842316daf6a8a4345740f05a9731167ce1 (patch)
tree0a982dd52df5c682fd2de8f9b22137471cee2dbe /framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php
parent9af56fd93ed071d86f14296cec618073f6c0941a (diff)
merge from 3.0 branch till 1435.
Diffstat (limited to 'framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php')
-rw-r--r--framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php
new file mode 100644
index 00000000..3926ff9e
--- /dev/null
+++ b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/AutoloadDebug.php
@@ -0,0 +1,84 @@
+<?php
+/**
+* Autoload debugging
+*
+* The internal __autoload() function of the shell-wrapper has two hooks.
+* The first is called before the include is done, the second afterwards.
+*
+* we use it to track the order the includes are handled. That makes it
+* easier to find implicit dependency problems.
+*
+* :set autoloaddebug = on
+* :set autoloaddebug = off
+*
+* the depth functions track the recursive depth of the includes. The
+* wrapper uses it to print the dots at the beginning of the line.
+*/
+class PHP_Shell_Extensions_AutoloadDebug implements PHP_Shell_Extension {
+ /**
+ * is the extenion enabled
+ *
+ * @var bool
+ */
+ protected $autoload_debug = false;
+
+ /**
+ * recursive depth of the includes
+ *
+ * @var int
+ */
+ protected $autoload_depth = 0;
+
+ public function register() {
+ $opt = PHP_Shell_Options::getInstance();
+ $opt->registerOption('autoloaddebug', $this, 'optSetAutoloadDebug');
+ }
+
+ /**
+ * handle the autoloaddebug flag
+ *
+ * @param string
+ */
+ public function optSetAutoloadDebug($key, $value) {
+ switch ($value) {
+ case "enable":
+ case "1":
+ case "on":
+ $this->autoload_debug = true;
+ break;
+ case "disable":
+ case "0":
+ case "off":
+ $this->autoload_debug = false;
+ break;
+ default:
+ printf(":set %s failed, unknown value. Use :set %s = (on|off)", $key, $key);
+ return;
+ }
+
+ }
+
+ /**
+ * is the autoload-debug flag set ?
+ *
+ * @return bool true if debug is enabled
+ */
+ public function isAutoloadDebug() {
+ return $this->autoload_debug;
+ }
+
+ /**
+ * increment the depth counter
+ */
+ public function incAutoloadDepth() {
+ return $this->autoload_depth++;
+ }
+
+ /**
+ * decrement the depth counter
+ */
+ public function decAutoloadDepth() {
+ return --$this->autoload_depth;
+ }
+}
+