Пример #1
0
 /**
  * The MarkdownGenerator constructor.
  *
  * @constructor
  * @param {string} $source The source code to parse.
  * @param {Array} $options The options array.
  */
 public function __construct($source, $options = array())
 {
     // juggle arguments
     if (is_array($source)) {
         $options = $source;
     } else {
         $options['source'] = $source;
     }
     if (isset($options['source']) && realpath($options['source'])) {
         $options['path'] = $options['source'];
     }
     if (isset($options['path'])) {
         preg_match('/(?<=\\.)[a-z]+$/', $options['path'], $ext);
         $options['source'] = file_get_contents($options['path']);
         $ext = array_pop($ext);
         if (!isset($options['lang']) && $ext) {
             $options['lang'] = $ext;
         }
         if (!isset($options['title'])) {
             $options['title'] = ucfirst(basename($options['path'])) . ' API documentation';
         }
     }
     if (!isset($options['lang'])) {
         $options['lang'] = 'js';
     }
     if (!isset($options['toc'])) {
         $options['toc'] = 'properties';
     }
     $this->options = $options;
     $this->source = str_replace(PHP_EOL, "\n", $options['source']);
     $this->entries = Entry::getEntries($this->source);
     foreach ($this->entries as $index => $value) {
         $this->entries[$index] = new Entry($value, $this->source, $options['lang']);
     }
 }
Пример #2
0
 /**
  * Checks if an entry is *not* assigned to a prototype.
  * @member Entry
  * @returns {Boolean} Returns true if not assigned to a prototype, else false.
  */
 public function isStatic()
 {
     $public = !$this->isPrivate();
     $result = $public && !!preg_match('/\\*\\s*@static\\b/', $this->entry);
     // set in cases where it isn't explicitly stated
     if ($public && !$result) {
         if ($parent = array_pop(preg_split('/[#.]/', $this->getMembers(0)))) {
             foreach (Entry::getEntries($this->source) as $entry) {
                 $entry = new Entry($entry, $this->source);
                 if ($entry->getName() == $parent) {
                     $result = !$entry->isCtor();
                     break;
                 }
             }
         } else {
             $result = true;
         }
     }
     return $result;
 }