/** * Debug reporting * * @param bool $debug * @return null */ public static function debug($debug = true) { if (is_bool($debug)) { self::$debug = $debug; } return new self(); }
public function __destruct() { Debug::debug('DefaultAdapter __destruct'); }
public function __destruct() { Debug::debug('ChannelAdapter __destruct'); }
<?php include dirname(dirname(__FILE__)) . '/src/Debug.php'; //Catch all Debug::register(); Debug::debug(false); //true = show erros; false hide errors //generate error "Use of undefined constant a - assumed 'a'" a; //Count errors if (Debug::count() > 0) { echo "Sorry, this code have a error. "; } else { echo "This code is beautiful!"; }
/** * * @param string $psFile * @param string $psPath */ public static function rmBalancedFile($psFile, $psPath) { $lsFileDir = self::getBalancedDir($psFile, $psPath); $lsFileDir = realpath(CLIENT_DIR . DS . $lsFileDir); if (file_exists($lsFileDir . DS . $psFile)) { Debug::debug('rm ' . $lsFileDir . DS . $psFile); self::removeFile($lsFileDir . DS . $psFile); } else { Debug::debug($lsFileDir . $psFile . ' not found.'); } }
public function stdin($buf) { Debug::debug(Debug::exportBytes($buf)); $this->buf .= $buf; start: if ($this->state === 0) { while (($l = $this->gets()) !== FALSE) { $e = explode(' ', rtrim($l, "\r\n")); if ($e[0] == 'VALUE') { $this->key = $e[1]; $this->valueFlags = $e[2]; $this->valueLength = $e[3]; $this->result = ''; $this->state = 1; break; } elseif ($e[0] == 'STAT') { if ($this->result === NULL) { $this->result = array(); } $this->result[$e[1]] = $e[2]; } elseif ($e[0] === 'STORED' || $e[0] === 'END' || $e[0] === 'DELETED' || $e[0] === 'ERROR' || $e[0] === 'CLIENT_ERROR' || $e[0] === 'SERVER_ERROR') { if ($e[0] !== 'END') { $this->result = FALSE; $this->error = isset($e[1]) ? $e[1] : NULL; } $cb = array_shift($this->callbacks); if ($cb) { call_user_func($cb, $this); } $this->valueSize = 0; $this->result = NULL; } } } if ($this->state === 1) { if ($this->valueSize < $this->valueLength) { $n = $this->valueLength - $this->valueSize; $buflen = strlen($this->buf); if ($buflen > $n) { $this->result .= binarySubstr($this->buf, 0, $n); $this->buf = binarySubstr($this->buf, $n); } else { $this->result .= $this->buf; $n = $buflen; $this->buf = ''; } $this->valueSize += $n; if ($this->valueSize >= $this->valueLength) { $this->state = 0; goto start; } } } }