/** * Returns the content of the array in the file. * * If no array with the specified name exists, an empty array will be returned. * * @return array Array read from the file. */ function get() { if ($this->file->exists() == true) { @(include $this->file->relPath()); } if (isset(${$this->varname}) == false) { ${$this->varname} = array(); } return ${$this->varname}; }
/** * Constructs a new Debug-Object. * * The first parameter has to be the file name with extension, but without directory. The second * parameter has to be a valid and existing directory path with trainling directory separator * (make sure the directory is writable). Standard value for this paramteer is null. If the * directory is null or invalid "data/logs/" will be used. If the specified file doesn't exist * it will created. If it is not possible to create a file a NonFatalException will be thrown. * * @param string File for saving the logdata * @param string Valid Directory for saving the logfile or null (directory will be "data/logs/") * @throws NonFatalException */ public function __construct($file, $dir = null) { if ($dir === null || is_dir($dir) === false) { $dir = 'data/logs/'; } $this->file = new File($dir.basename($file)); if ($this->file->create() === false) { throw new NonFatalException('Could not create log file "'.$this->file->relPath().'".'); } if ($this->file->readable() === false || $this->file->writable() === false) { $this->file->setPermissions(666); } $this->logs = array(); $this->benchmarks = array(); $this->temp = array(); }
/** * Looks for class names in a PHP code * * @param string File to scan for class name. * @todo Reine PHP Alternative um Klassen zu erkennen (RegExp) */ private function parse($filepath) { $file = new File($filepath); if ($file->exists() == true) { $code = $file->read(); $tokens = @token_get_all($code); foreach ($tokens as $token) { if (!isset($token[0])) { continue; } // next token after this one is our desired class name if ($token[0] == T_CLASS) { $this->next = true; } if ($token[0] == T_STRING && $this->next === true) { if (isset($this->data[$token[1]]) == true) { Core::throwError('Class with name "' . $token[1] . '" was found more than once. Only file "' . $file->absPath() . '" has been indexed!', INTERNAL_NOTICE); } $this->data[$token[1]] = $file->relPath(); $this->next = false; } } } }