protected function getDescription(PHP_UML_Metamodel_Stereotype $s, $annotatedElement = '') { $tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description'); if (!is_null($tag)) { return nl2br(htmlspecialchars($tag->value)); } else { return ''; } }
/** * Retrieve the PHP_UML_Metamodel_Package object related to a package path * (ie, to a qualified name, like A\B\C). * Relies on the model->$packages, when references are still named * (= before their resolution) * * @param string $path The path to find * * @return PHP_UML_Metamodel_Package The package to find. Null if not found. */ protected function getPackageByPath($path) { $pkg = $this->topPackage; do { list($pos, $first, $path) = PHP_UML_Metamodel_Helper::getPackagePathParts($path); if ($first != '') { $pkg = PHP_UML_Metamodel_Helper::findSubpackageByName($pkg, $first); } if ($pkg === false) { return false; } } while (!($pos === false)); return $pkg; }
/** * Parse the directories and the files (depending on what the $directories * and $files properties have been set to with setInput()) and return a * UML model. * * @param string $modelName A model name (e.g., the name of your application) * * @return PHP_UML_Metamodel_Superstructure The resulting UML model */ public function parse($modelName = 'default') { $this->model->initModel($modelName); if ($this->importer instanceof PHP_UML_Input_PHP_FileScanner) { $this->setInputPhpParserOptions(); } $this->importer->setFiles($this->files); $this->importer->setDirectories($this->directories); $this->importer->setMatchPatterns($this->matchPatterns); $this->importer->setIgnorePatterns($this->ignorePatterns); $this->importer->import(); if ($this->removeEmptyNamespaces) { PHP_UML_Metamodel_Helper::deleteEmptyPackages($this->model->packages); } return $this->model; }
/** * Finalizes the main object structure that the Parser has built. * Launches the resolution of the references for all stacks from the root pkg * * Every reference (a temporary string) is replaced by a PHP reference * to the corresponding type (that is, a class or a datatype) * Must be run once the model is complete (= once PHP parsing is done) * * @param bool $noEmptyPkg True to force removal of empty packages * @param array $defPkg Array of PHP_UML_Metamodel_Package where to look into, * in order to resolve the orphaned elements. * By default, it will look in the root package. This is, * by the way, where the PHP datatypes are. */ public function finalizeAll($noEmptyPkg = true, $defPkg = array()) { if ($noEmptyPkg) { PHP_UML_Metamodel_Helper::deleteEmptyPackages($this->packages); } $resolver = new PHP_UML_Metamodel_TypeResolverByName(); $resolver->package = $this->packages; if (empty($defPkg)) { $defPkg = array($this->packages); } else { $defPkg[] =& $this->packages; } $resolver->resolveReferences($this->packages, $defPkg); }
/** * Does the type resolution for a given element in a given package * * @param PHP_UML_Metamodel_Package $pkg The nesting package * @param string &$element The element to resolve, provided as a name * @param PHP_UML_Metamodel_Type $context The context (the nesting class/interface, which * is the only element to know the nesting file) */ private function resolveType(PHP_UML_Metamodel_Package $pkg, &$element, PHP_UML_Metamodel_NamedElement $context) { if (empty($element)) { $targetElement = PHP_UML_Metamodel_Helper::searchTypeIntoPackage($this->topPackage, 'mixed'); } else { $targetElement = PHP_UML_Metamodel_Helper::findTypeById($this->topPackage, $element); } if ($targetElement === false) { $targetElement = $this->resolveTypeByUri($element); } if ($targetElement === false) { self::resolutionWarning($element, $context); } else { $element = $targetElement; } }
public function getComment(PHP_UML_Metamodel_Stereotype $s, $annotatedElement = '') { $tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description'); if (!is_null($tag)) { return $this->getTaggedValue($tag->value, self::getUID('Tag_documentation')); } else { return ''; } }
/** * Sets the nesting package of an isolated attribute (the PHP "const") * * @param PHP_UML_Metamodel_Property &$a A property * @param PHP_UML_Metamodel_Package $nestingPkg The enclosing package */ private function setNestingPackageOfAttribute(PHP_UML_Metamodel_Property &$a, PHP_UML_Metamodel_Package $nestingPkg) { $a->package = $nestingPkg; if (PHP_UML_Metamodel_Helper::searchAttributeIntoPackage($a->package, $a->name) === false) { $nestingPkg->ownedAttribute[] =& $a; $this->file->manifested[] =& $a; } else { PHP_UML_Warning::add('Constant ' . $a->name . ' already defined, in ' . $this->file->name); } }
/** * Does the type resolution for a given element in a given package * * @param PHP_UML_Metamodel_Package $pkg The nesting package * @param string &$element The element to resolve, provided as a name * @param PHP_UML_Metamodel_Type $context The context (the nesting class/interface, which * is the only element to know the nesting file) */ private function resolveType(PHP_UML_Metamodel_Package $pkg, &$element, PHP_UML_Metamodel_NamedElement $context) { // Is there a ns separator (\) in it ? list($pos, $first, $last) = PHP_UML_Metamodel_Helper::getPackagePathParts($element, false); if (!($pos === false)) { $tmpPkg = $this->getPackageByPath($first); if ($tmpPkg === false) { self::resolutionWarning($element, $context); $element = null; } else { // Do we know that type? $_o = PHP_UML_Metamodel_Helper::searchTypeIntoPackage($tmpPkg, $last); if (!($_o === false)) { $element = $_o; } else { self::resolutionWarning($element, $context); //$element = null; } } } else { // Is it in the current package? $_o = PHP_UML_Metamodel_Helper::searchTypeIntoPackage($pkg, $element); if (!($_o === false)) { $element = $_o; } else { // Is it in one of the "default" packages? $found = false; foreach ($this->defaultRepo as $itemPkg) { $_o = PHP_UML_Metamodel_Helper::searchTypeIntoPackage($itemPkg, $element); if (!($_o === false)) { $element = $_o; $found = true; break; } } if (!$found) { self::resolutionWarning($element, $context); //$element = null; } } } }
public function getComment(PHP_UML_Metamodel_Stereotype $s, $annotatedElement = '') { $tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description'); if (!is_null($tag)) { return '<ownedComment xmi:type="uml:Comment" xmi:id="' . self::getUID() . '" annotatedElement="' . $annotatedElement . '"><body>' . htmlspecialchars($tag->value) . '</body></ownedComment>'; } else { return ''; } }