Пример #1
0
 /**
  * Tests the various calls to the API made from scripts/phpuml
  * 
  */
 public function testPhpUmlScript()
 {
     $output = self::TEMP_DIR . 'new_phpumlscript.xmi';
     $version = 1;
     $modelName = 'Foo';
     $encoding = 'iso-8859-1';
     $errorLevel = 1;
     $uml = new PHP_UML();
     $uml->setInput(self::SUITE_DIR . 'test1.php');
     $uml->deploymentView = true;
     $uml->componentView = true;
     $uml->dollar = true;
     $uml->docblocks = true;
     $uml->onlyApi = false;
     $uml->showInternal = true;
     $uml->pureObject = false;
     $uml->setMatchPatterns('*.php');
     $uml->setIgnorePatterns('.svn');
     PHP_UML_Warning::clear();
     $uml->parse('test');
     $e = PHP_UML_Output_Exporter::getInstance('xmi');
     $uml->setExporter($e);
     if ($e instanceof PHP_UML_Output_Xmi_Exporter) {
         $e->setEncoding($encoding);
         $e->setXmiVersion($version);
     }
     if ($e instanceof PHP_UML_Output_Xmi_Exporter) {
         $e->generateXmi();
         echo $e->getXmiDocument()->dump();
     }
     $e->export($output);
     foreach (PHP_UML_Warning::$stack as $msg) {
         echo $msg . "\n";
     }
     $this->assertTrue(file_exists($output));
 }
Пример #2
0
$t->setInput('test1.php.txt, test2.php.txt');
// We want only "test1.php.txt" and "test2.php.txt"
$t->parse('testModel');
// The files are parsed, and a UML model named "testModel" is built
// we retrieve an XMI implementation of an Exporter object, and set the model:
$e = new PHP_UML_Output_Xmi_Exporter();
$e->setModel($t->getModel());
// we set the XMI version (2.1 being the default if not set)
$e->setXmiVersion(1);
// we set the encoding (iso-8859-1 being the default if not set):
$e->setEncoding('UTF-8');
// and we export XMI to a file:
$e->export('test_example2.xmi');
// we can also print the serialized XMI by retrieving an XmiDocument from the exporter object:
echo htmlentities($e->getXmiDocument()->dump());
/**
 * Example 3 : Example with a whole directory of PHP files to parse. We just want to
 * generate the API documentation in HTML.
 */
$t = new PHP_UML();
$t->setMatchPatterns(array('*.php', '*.txt'));
// We want to parse every file with an extension "php" or "txt"
$t->setIgnorePatterns('.svn');
// We want all directories to be scanned, except the ".svn"
$t->setInput('./');
// ... in the current directory
$t->parse();
// Starts parsing
$t->export('htmlnew', 'doc/');
// And the HTML API is exported into the folder "doc/"
echo '<br/>Done !!';