See also: xp://io.collections.FileCollection
Inheritance: extends Object, implements IOElement
示例#1
0
 /**
  * Runs the analyzer on the given $files.
  * 
  * @param array<AnalyzedFile> $files The files to process
  */
 public function analyze($files)
 {
     $total_lines = 0;
     foreach ($files as $file) {
         if ($file->get_filetype() !== 'php') {
             continue;
         }
         $element = new FileElement($file);
         $visitor = new AnalyzerVisitor('CodeElementFactory', $element, $this->elements);
         $traverser = new PhpParser\NodeTraverser();
         $traverser->addVisitor($visitor);
         $traverser->traverse($file->get_node_tree());
         $this->elements['files']->add_child($visitor->get_root());
         $total_lines += (int) $element->get_stat('line_count');
     }
     $this->elements['totals']->add_stat('total_lines', $total_lines);
 }
示例#2
0
文件: Prc.php 项目: wallabag/php-mobi
 public function __construct($settings, $records)
 {
     parent::__construct(array('title' => new FileString(32), 'attributes' => new FileShort(), 'version' => new FileShort(), 'creationTime' => new FileDate(), 'modificationTime' => new FileDate(), 'backupTime' => new FileDate(), 'modificationNumber' => new FileInt(), 'appInfoID' => new FileInt(), 'sortInfoID' => new FileInt(), 'prcType' => new FileString(4), 'creator' => new FileString(4), 'uniqueIDSeed' => new FileInt(), 'nextRecordListID' => new FileInt(), 'numberRecords' => new FileShort(), 'recordList' => new FileElement(), 'filler' => new FileShort(), 'records' => new FileElement()));
     //Set values from the info block
     foreach ($this->elements as $name => $val) {
         if ($settings->exists($name)) {
             $this->get($name)->set($settings->get($name));
         }
     }
     $this->get('numberRecords')->set(sizeof($records));
     $i = 0;
     foreach ($records as $record) {
         $offset = new FileInt();
         $attr = new FileByte();
         $uniqueID = new FileTri($i);
         $this->elements['recordList']->add('Rec' . $i, new FileElement(array('offset' => $offset, 'attribute' => $attr, 'uniqueID' => $uniqueID)));
         $this->elements['records']->add('Rec' . $i, $record);
         ++$i;
     }
     $this->updateOffsets($records);
 }
示例#3
0
 public function __construct($settings, $records)
 {
     parent::__construct(array("title" => new FileString(32), "attributes" => new FileShort(), "version" => new FileShort(), "creationTime" => new FileDate(), "modificationTime" => new FileDate(), "backupTime" => new FileDate(), "modificationNumber" => new FileInt(), "appInfoID" => new FileInt(), "sortInfoID" => new FileInt(), "prcType" => new FileString(4), "creator" => new FileString(4), "uniqueIDSeed" => new FileInt(), "nextRecordListID" => new FileInt(), "numberRecords" => new FileShort(), "recordList" => new FileElement(), "filler" => new FileShort(), "records" => new FileElement()));
     //Set values from the info block
     foreach ($this->elements as $name => $val) {
         if ($settings->exists($name)) {
             $this->get($name)->set($settings->get($name));
         }
     }
     $this->get("numberRecords")->set(sizeof($records));
     $i = 0;
     foreach ($records as $record) {
         $offset = new FileInt();
         $attr = new FileByte();
         $uniqueID = new FileTri($i);
         $this->elements["recordList"]->add("Rec" . $i, new FileElement(array("offset" => $offset, "attribute" => $attr, "uniqueID" => $uniqueID)));
         $this->elements["records"]->add("Rec" . $i, $record);
         $i++;
     }
     $this->updateOffsets($records);
 }
示例#4
0
 public function unserialize($data)
 {
     $this->elements->unserialize($data);
 }
 /**
  * Finds an element inside this collection
  *
  * @param   string name
  * @return  io.collections.IOElement
  * @throws  io.OperationNotSupportedException
  * @throws  io.IOException
  */
 public function findElement($name)
 {
     $qualified = $this->qualifiedName($name);
     if (!is_file($qualified)) {
         return NULL;
     }
     $found = new FileElement($qualified);
     $found->setOrigin($this);
     return $found;
 }