Example #1
0
 /**
  * @return static|null
  */
 public static function fromName($name, Language $lang = null, Project $proj = null)
 {
     $result = null;
     $name = \trim($name);
     if ('' !== $name) {
         $result = new static();
         $result->_name = $name;
         if (\interface_exists($name) || \trait_exists($name) || \class_exists($name)) {
             $result->_reflector = new \ReflectionClass($name);
             if (!$result->_reflector->isUserDefined()) {
                 // PHP type
                 $phpLang = 'en';
                 if (null !== $lang) {
                     $phpLang = $lang->id();
                 }
                 $result->_link = \sprintf('http://php.net/manual/%s/class.%s.php', $phpLang, \trim(\strtolower(\str_ireplace("\\", '.', $result->_reflector->getName()))));
             } else {
                 if (null !== $proj) {
                     foreach ($proj->classes() as $cls) {
                         if ($cls->reflector()->getName() === $result->_reflector->getName()) {
                             $result->_link = $cls->getDocumentFilename($lang);
                         }
                     }
                 }
             }
         } else {
             switch ($name) {
                 case 'callable':
                     $result->_link = 'https://github.com/mkloubert/phpLINQ/wiki/Callable';
                     break;
             }
         }
     } else {
         $result = null;
     }
     return $result;
 }
Example #2
0
    if (false === $docFile) {
        $docFileNotFound = true;
    }
} else {
    $docFile = realpath('./docs.xml');
    if (false !== $docFile) {
        $docFileNotFound = false;
    }
}
if (true === $docFileFound) {
    exit(1);
}
if (false === $docFileNotFound) {
    $docXml = simplexml_load_file($docFile);
}
if (false === $docXml) {
    exit(2);
}
if (!file_exists($outDir)) {
    if (!mkdir($outDir, 0777, true)) {
        exit(3);
    }
}
$outDir = realpath($outDir);
if (!is_dir($outDir)) {
    exit(4);
}
$proj = \phpLINQ\Docs\Project::fromXml($docXml);
$proj->baseDir(__DIR__);
$proj->outDir($outDir);
$proj->generate();