public function writeJson() { $fullname = $this->filename; //$path_parts = pathinfo($fullname); //$dir = CACHE_DIR . $path_parts['dirname'] . DIRECTORY_SEPARATOR; $dir = CACHE_DIR . dirname($fullname) . DIRECTORY_SEPARATOR; $dir = str_replace("/var/www/html/thabo/", "", $dir); /*echo $path_parts['basename'], "\n"; echo $path_parts['extension'], "\n"; echo $path_parts['filename'], "\n"; // since PHP 5.2.0*/ //$dir = CACHE_DIR . $this->namespace_['name'] . DIRECTORY_SEPARATOR; DirHelper::createDir($dir); $filename = $dir . basename($this->filename, ".php") . '.json'; /* if(empty($this->namespace_)) { $filename = CACHE_DIR .basename($this->filename,".php") .'.json'; } else { $dir = CACHE_DIR . $this->namespace_['name'] . DIRECTORY_SEPARATOR; DirHelper::createDir($dir); $filename = $dir . basename($this->filename,".php") .'.json'; }*/ $this->result['objects'] = $this->objects; $this->result['namespace'] = $this->namespace_; $this->result['use'] = $this->use_; $this->result['functions'] = $this->functions; $this->result['path'] = $fullname; //print_r($this->result); echo "Writing json file -> " . $filename . PHP_EOL; if (PHP_VERSION_ID >= 50400) { $content = json_encode($this->result, JSON_PRETTY_PRINT); } else { $content = json_encode($this->result); } if (IS_DEBUG) { echo "content: " . $content . PHP_EOL; } $fp = fopen($filename, 'w'); fwrite($fp, $content); fclose($fp); }