Initial Commit
This commit is contained in:
32
database/php/pear/PHP/UML/Metamodel/Artifact.php
Normal file
32
database/php/pear/PHP/UML/Metamodel/Artifact.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 136 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Meta-File
|
||||
*
|
||||
*/
|
||||
class PHP_UML_Metamodel_Artifact extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
/**
|
||||
* Array of classes/interfaces declarations contained in that file
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $manifested = array();
|
||||
|
||||
public $package;
|
||||
}
|
||||
?>
|
||||
28
database/php/pear/PHP/UML/Metamodel/Class.php
Normal file
28
database/php/pear/PHP/UML/Metamodel/Class.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 135 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-11-30 01:21:11 +0100 (lun., 30 nov. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Meta-Class
|
||||
*
|
||||
*/
|
||||
class PHP_UML_Metamodel_Class extends PHP_UML_Metamodel_Classifier
|
||||
{
|
||||
public $ownedAttribute = array();
|
||||
public $isInstantiable;
|
||||
public $implements = array();
|
||||
}
|
||||
?>
|
||||
35
database/php/pear/PHP/UML/Metamodel/Classifier.php
Normal file
35
database/php/pear/PHP/UML/Metamodel/Classifier.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 138 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-12-13 04:23:11 +0100 (dim., 13 déc. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Metaclass for classifier
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
*/
|
||||
abstract class PHP_UML_Metamodel_Classifier extends PHP_UML_Metamodel_Type
|
||||
{
|
||||
public $superClass = array();
|
||||
public $ownedOperation = array();
|
||||
public $file;
|
||||
public $package;
|
||||
public $isAbstract;
|
||||
public $isReadOnly;
|
||||
}
|
||||
?>
|
||||
29
database/php/pear/PHP/UML/Metamodel/Datatype.php
Normal file
29
database/php/pear/PHP/UML/Metamodel/Datatype.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 138 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-12-13 04:23:11 +0100 (dim., 13 déc. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Datatype metaclass
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
*/
|
||||
class PHP_UML_Metamodel_Datatype extends PHP_UML_Metamodel_Classifier
|
||||
{
|
||||
}
|
||||
?>
|
||||
40
database/php/pear/PHP/UML/Metamodel/Enumeration.php
Normal file
40
database/php/pear/PHP/UML/Metamodel/Enumeration.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 136 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Meta-Enumeration
|
||||
* Enumerates some basic PHP classifiers.
|
||||
*
|
||||
*/
|
||||
class PHP_UML_Metamodel_Enumeration
|
||||
{
|
||||
/**
|
||||
* PHP datatypes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static public $datatypes = array('mixed', 'array', 'string', 'int', 'integer',
|
||||
'bool', 'boolean', 'float', 'void', 'null', 'object', 'resource');
|
||||
|
||||
static public $interfaces = array('Iterator', 'Countable');
|
||||
|
||||
static public $classes = array('Exception');
|
||||
|
||||
/**
|
||||
* Main file types. Used as stereotypes for qualifying the artifacts.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static public $filetype = array('PHP File');
|
||||
}
|
||||
?>
|
||||
244
database/php/pear/PHP/UML/Metamodel/Helper.php
Normal file
244
database/php/pear/PHP/UML/Metamodel/Helper.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (PHP/MOF program elements classes)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 175 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2011-09-15 17:07:58 +0200 (jeu., 15 sept. 2011) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper class to deal with Metamodel elements.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Metamodel_Helper
|
||||
{
|
||||
const META_INTERFACE = 'PHP_UML_Metamodel_Interface';
|
||||
const META_CLASS = 'PHP_UML_Metamodel_Class';
|
||||
const META_DATATYPE = 'PHP_UML_Metamodel_Datatype';
|
||||
const META_OPERATION = 'PHP_UML_Metamodel_Operation';
|
||||
const META_PROPERTY = 'PHP_UML_Metamodel_Property';
|
||||
|
||||
const PHP_PROFILE_NAME = 'php';
|
||||
const PHP_STEREOTYPE_DOCBLOCK = 'docblock';
|
||||
|
||||
|
||||
/**
|
||||
* Deletes all empty packages
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package &$ns Top package
|
||||
*/
|
||||
static public function deleteEmptyPackages(PHP_UML_Metamodel_Package &$ns)
|
||||
{
|
||||
if (!is_null($ns->nestedPackage)) {
|
||||
foreach ($ns->nestedPackage as $key => &$pkg) {
|
||||
if (self::isEmpty($pkg)) {
|
||||
unset($ns->nestedPackage[$key]);
|
||||
} else {
|
||||
if (self::deleteEmptyPackages($pkg)) {
|
||||
unset($ns->nestedPackage[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self::isEmpty($ns)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a package is empty
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $p Top package
|
||||
*/
|
||||
static private function isEmpty(PHP_UML_Metamodel_Package $p)
|
||||
{
|
||||
return empty($p->nestedPackage) && empty($p->ownedType) && empty($p->ownedOperation) && empty($p->ownedAttribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches in a given package for a typed element (likely, a class)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $ns A package element
|
||||
* @param string $value A name
|
||||
*
|
||||
* @return mixed Either FALSE if not found, or the element
|
||||
*/
|
||||
public static function searchTypeIntoPackage(PHP_UML_Metamodel_Package $ns, $value)
|
||||
{
|
||||
foreach ($ns->ownedType as $key => &$o) {
|
||||
if (strcasecmp($o->name, $value)==0) {
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches if an operation already exists in a given pkg
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $ns A package element
|
||||
* @param string $value A name
|
||||
*
|
||||
* @return mixed Either FALSE if not found, or the element
|
||||
*/
|
||||
static public function searchOperationIntoPackage(PHP_UML_Metamodel_Package $ns, $value)
|
||||
{
|
||||
foreach ($ns->ownedOperation as $key => &$o) {
|
||||
if (strcasecmp($o->name, $value)==0) {
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches if an attribute already exists in a given pkg
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $ns A package element
|
||||
* @param string $value A name
|
||||
*
|
||||
* @return mixed Either FALSE if not found, or the element
|
||||
*/
|
||||
public static function searchAttributeIntoPackage(PHP_UML_Metamodel_Package $ns, $value)
|
||||
{
|
||||
foreach ($ns->ownedAttribute as $key => &$o) {
|
||||
if (strcasecmp($o->name, $value)==0) {
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a particular tag in a given stereotype
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Stereotype $s The stereotype
|
||||
* @param string $tagName The tag name (eg "description")
|
||||
*
|
||||
* @return PHP_UML_Metamodel_Tag
|
||||
*/
|
||||
public static function getStereotypeTag(PHP_UML_Metamodel_Stereotype $s, $tagName)
|
||||
{
|
||||
if (!empty($s)) {
|
||||
foreach ($s->ownedAttribute as $tag) {
|
||||
if ($tag->name == $tagName)
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches recursively in a given package for an element, knowing its ID
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $np A package element (context)
|
||||
* @param string $value An ID
|
||||
*
|
||||
* @return mixed Either FALSE if not found, or the position in the stack
|
||||
*/
|
||||
public static function findTypeById(PHP_UML_Metamodel_Package $np, $value)
|
||||
{
|
||||
if ($np->id == $value)
|
||||
return $np;
|
||||
|
||||
foreach ($np->ownedType as $item) {
|
||||
if ($item->id == $value)
|
||||
return $item;
|
||||
}
|
||||
foreach ($np->ownedAttribute as $item) {
|
||||
if ($item->id == $value)
|
||||
return $item;
|
||||
}
|
||||
foreach ($np->ownedOperation as $item) {
|
||||
if ($item->id == $value)
|
||||
return $item;
|
||||
}
|
||||
foreach ($np->nestedPackage as $item) {
|
||||
$ret = self::findTypeById($item, $value);
|
||||
if (!($ret === false))
|
||||
return $ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches recursively in a given package for a package, knowing its name
|
||||
* Works with position numbers, not variable references.
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $np A package element (context)
|
||||
* @param string $value A package name (to find)
|
||||
*
|
||||
* @return mixed Either FALSE if not found, or the position in the stack
|
||||
*/
|
||||
public static function findSubpackageByName(PHP_UML_Metamodel_Package $np, $value)
|
||||
{
|
||||
foreach ($np->nestedPackage as $pkg) {
|
||||
if (strcasecmp($pkg->name, $value)==0) {
|
||||
return $pkg;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a package path into its first/last element, and the rest
|
||||
* Allows for the two different versions of package delimiter
|
||||
*
|
||||
* @param string $path A path to split
|
||||
* @param bool $modeFirst If true, splits into 1st and the rest
|
||||
* If false, splits into last and the rest
|
||||
* @param string $alt Alternate separator (eg, /, or ::)
|
||||
*
|
||||
* @return array Results array
|
||||
*/
|
||||
static public function getPackagePathParts($path, $modeFirst = true, $alt=PHP_UML_Input_PHP_Parser::T_NS_SEPARATOR2)
|
||||
{
|
||||
$first = '';
|
||||
$last = '';
|
||||
if ($modeFirst) {
|
||||
$pos1 = strpos($path, PHP_UML_Input_PHP_Parser::T_NS_SEPARATOR);
|
||||
$pos2 = strpos($path, $alt);
|
||||
if ($pos1!==false && ($pos1<$pos2 || $pos2===false)) {
|
||||
$pos = $pos1;
|
||||
$len = strlen(PHP_UML_Input_PHP_Parser::T_NS_SEPARATOR);
|
||||
} else {
|
||||
$pos = $pos2;
|
||||
$len = strlen($alt);
|
||||
}
|
||||
} else {
|
||||
$pos1 = strrpos($path, PHP_UML_Input_PHP_Parser::T_NS_SEPARATOR);
|
||||
$pos2 = strrpos($path, $alt);
|
||||
if ($pos1!==false && ($pos1>$pos2 || $pos2===false)) {
|
||||
$pos = $pos1;
|
||||
$len = strlen(PHP_UML_Input_PHP_Parser::T_NS_SEPARATOR);
|
||||
} else {
|
||||
$pos = $pos2;
|
||||
$len = strlen($alt);
|
||||
}
|
||||
}
|
||||
if ($pos===false)
|
||||
$first = $path;
|
||||
else {
|
||||
$first = substr($path, 0, $pos);
|
||||
$last = substr($path, $pos+$len);
|
||||
}
|
||||
return array($pos, $first, $last);
|
||||
}
|
||||
}
|
||||
?>
|
||||
22
database/php/pear/PHP/UML/Metamodel/Interface.php
Normal file
22
database/php/pear/PHP/UML/Metamodel/Interface.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 135 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-11-30 01:21:11 +0100 (lun., 30 nov. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_Interface extends PHP_UML_Metamodel_Classifier
|
||||
{
|
||||
}
|
||||
?>
|
||||
57
database/php/pear/PHP/UML/Metamodel/NamedElement.php
Normal file
57
database/php/pear/PHP/UML/Metamodel/NamedElement.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* This is a PHP metamodel, inspired by the MOF Metamodel.
|
||||
* It defines the various elements of the PHP language that have been parsed
|
||||
* by the parser, and that we want to reverse-engineer.
|
||||
*
|
||||
* For more information on language metamodels, see :
|
||||
* - The OMG website, and its MOF standard
|
||||
* - Ceejay, a Java/C++ Code Generation Metamodel for ULF-Ware (M. Piefel)
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 138 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-12-13 04:23:11 +0100 (dim., 13 déc. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* The NamedElement class
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
abstract class PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
/**
|
||||
* Unique identifier
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Reference to a "documention" stereotype
|
||||
*
|
||||
* @var PHP_UML_Metamodel_Stereotype
|
||||
*/
|
||||
public $description;
|
||||
}
|
||||
?>
|
||||
29
database/php/pear/PHP/UML/Metamodel/Operation.php
Normal file
29
database/php/pear/PHP/UML/Metamodel/Operation.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 133 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-11-15 23:46:39 +0100 (dim., 15 nov. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_Operation extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
public $isAbstract;
|
||||
public $isInstantiable;
|
||||
public $ownedParameter = array();
|
||||
public $class;
|
||||
public $package;
|
||||
public $visibility;
|
||||
public $file;
|
||||
}
|
||||
?>
|
||||
27
database/php/pear/PHP/UML/Metamodel/Package.php
Normal file
27
database/php/pear/PHP/UML/Metamodel/Package.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 133 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-11-15 23:46:39 +0100 (dim., 15 nov. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_Package extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
public $nestingPackage;
|
||||
public $nestedPackage = array();
|
||||
public $ownedType = array();
|
||||
public $ownedOperation = array();
|
||||
public $ownedAttribute = array();
|
||||
}
|
||||
?>
|
||||
25
database/php/pear/PHP/UML/Metamodel/Parameter.php
Normal file
25
database/php/pear/PHP/UML/Metamodel/Parameter.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 73 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2008-12-17 01:30:18 +0100 (mer., 17 déc. 2008) $
|
||||
*
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_Parameter extends PHP_UML_Metamodel_TypedElement
|
||||
{
|
||||
public $default;
|
||||
public $operation;
|
||||
public $direction;
|
||||
}
|
||||
?>
|
||||
29
database/php/pear/PHP/UML/Metamodel/Property.php
Normal file
29
database/php/pear/PHP/UML/Metamodel/Property.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 133 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-11-15 23:46:39 +0100 (dim., 15 nov. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_Property extends PHP_UML_Metamodel_TypedElement
|
||||
{
|
||||
public $isReadOnly;
|
||||
public $isInstantiable;
|
||||
public $visibility;
|
||||
public $default;
|
||||
public $class;
|
||||
public $package;
|
||||
public $file;
|
||||
}
|
||||
?>
|
||||
33
database/php/pear/PHP/UML/Metamodel/Stereotype.php
Normal file
33
database/php/pear/PHP/UML/Metamodel/Stereotype.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 97 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-01-04 21:57:08 +0100 (dim., 04 janv. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* The stereotype class
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Metamodel_Stereotype extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
public $element;
|
||||
public $ownedAttribute = array();
|
||||
public $profile;
|
||||
}
|
||||
?>
|
||||
287
database/php/pear/PHP/UML/Metamodel/Superstructure.php
Normal file
287
database/php/pear/PHP/UML/Metamodel/Superstructure.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (PHP/MOF program elements classes)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 175 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2011-09-15 17:07:58 +0200 (jeu., 15 sept. 2011) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A superstructure is a set composed of a UML model, a physical model,
|
||||
* and some stereotypes associated to the UML model.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Metamodel_Superstructure
|
||||
{
|
||||
const META_INTERFACE = 'PHP_UML_Metamodel_Interface';
|
||||
const META_CLASS = 'PHP_UML_Metamodel_Class';
|
||||
const META_DATATYPE = 'PHP_UML_Metamodel_Datatype';
|
||||
const META_OPERATION = 'PHP_UML_Metamodel_Operation';
|
||||
const META_PROPERTY = 'PHP_UML_Metamodel_Property';
|
||||
|
||||
const PHP_PROFILE_NAME = 'php';
|
||||
const PHP_STEREOTYPE_DOCBLOCK = 'docblock';
|
||||
|
||||
/**
|
||||
* The root package for a logical UML model
|
||||
*
|
||||
* @var PHP_UML_Metamodel_Package
|
||||
*/
|
||||
public $packages;
|
||||
|
||||
/**
|
||||
* The root package for a deployment (physical) model
|
||||
*
|
||||
* @var PHP_UML_Metamodel_Package
|
||||
*/
|
||||
public $deploymentPackages;
|
||||
|
||||
/**
|
||||
* Stack of all stereotypes
|
||||
* TODO: when real stereotypes will be implemented, deleting that array, and
|
||||
* reading the stereotypes from the $packages instead
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $stereotypes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the internal PHP metatypes, metaclasses, metainterfaces...
|
||||
*
|
||||
*/
|
||||
public function addInternalPhpTypes()
|
||||
{
|
||||
foreach (PHP_UML_Metamodel_Enumeration::$datatypes as $d) {
|
||||
$type = new PHP_UML_Metamodel_Datatype;
|
||||
$type->id = PHP_UML_SimpleUID::getUID();
|
||||
$type->name = $d;
|
||||
|
||||
$this->addRootType($type, 'Internal PHP type.');
|
||||
|
||||
}
|
||||
foreach (PHP_UML_Metamodel_Enumeration::$interfaces as $i) {
|
||||
$type = new PHP_UML_Metamodel_Interface;
|
||||
$type->id = PHP_UML_SimpleUID::getUID();
|
||||
$type->name = $i;
|
||||
|
||||
$this->addRootType($type, 'Internal PHP interface.');
|
||||
}
|
||||
foreach (PHP_UML_Metamodel_Enumeration::$classes as $c) {
|
||||
$type = new PHP_UML_Metamodel_Class;
|
||||
$type->id = PHP_UML_SimpleUID::getUID();
|
||||
$type->name = $c;
|
||||
|
||||
$this->addRootType($type, 'Internal PHP class.');
|
||||
}
|
||||
}
|
||||
|
||||
private function addRootType(PHP_UML_Metamodel_NamedElement $type, $desc)
|
||||
{
|
||||
if (!PHP_UML_Metamodel_Helper::searchTypeIntoPackage($this->packages, $type->name)) {
|
||||
$this->packages->ownedType[] = $type;
|
||||
$this->addDocTags($type, $desc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stereotype and the necessary Tag objects for a given element
|
||||
*
|
||||
* @param PHP_UML_Metamodel_NamedElement &$element The element to document
|
||||
* @param string $desc A textual description
|
||||
* @param array $docs An array containing docblocks
|
||||
*/
|
||||
public function addDocTags(PHP_UML_Metamodel_NamedElement &$element, $desc, array $docs = array())
|
||||
{
|
||||
$stereotype = $this->createStereotype($element, self::PHP_PROFILE_NAME, self::PHP_STEREOTYPE_DOCBLOCK);
|
||||
|
||||
if ($desc != '') {
|
||||
$tag = new PHP_UML_Metamodel_Tag;
|
||||
$tag->id = PHP_UML_SimpleUID::getUID();;
|
||||
$tag->name = 'description';
|
||||
$tag->value = $desc;
|
||||
|
||||
$stereotype->ownedAttribute[] = $tag;
|
||||
}
|
||||
foreach ($docs as $doc) {
|
||||
$tag = new PHP_UML_Metamodel_Tag;
|
||||
$tag->id = PHP_UML_SimpleUID::getUID();;
|
||||
$tag->name = $doc[1];
|
||||
$tag->value = trim(implode(' ', array_slice($doc, 2)));
|
||||
|
||||
$stereotype->ownedAttribute[] = $tag;
|
||||
}
|
||||
$element->description = $stereotype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively replaces all the "named types" by a proper "reference" to a
|
||||
* typed element. This impacts:
|
||||
* - the extended classes and implemented classes (through their
|
||||
* EMOF-"superClass" and "implements" relations)
|
||||
* - the function parameters (through their EMOF-"type" attribute)
|
||||
* - the properties in classes (through their EMOF-"type" attribute)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package &$ns Package to resolve the elements of
|
||||
* @param array &$_oDef Default packages to look for
|
||||
* orphaned elements
|
||||
*/
|
||||
private function resolveReferences(PHP_UML_Metamodel_Package &$ns, array &$_oDef)
|
||||
{
|
||||
if (!is_null($ns->nestedPackage)) {
|
||||
foreach ($ns->nestedPackage as $key => &$pkg) {
|
||||
$this->resolveReferences($pkg, $_oDef);
|
||||
}
|
||||
}
|
||||
if (!is_null($ns->ownedType))
|
||||
foreach ($ns->ownedType as &$elt) {
|
||||
if (isset($elt->superClass) && !is_null($elt->superClass)) {
|
||||
foreach ($elt->superClass as &$className) {
|
||||
$this->resolveType($ns, $className, $_oDef, $elt);
|
||||
}
|
||||
}
|
||||
if (isset($elt->implements) && !is_null($elt->implements)) {
|
||||
foreach ($elt->implements as &$className) {
|
||||
$this->resolveType($ns, $className, $_oDef, $elt);
|
||||
}
|
||||
}
|
||||
if (isset($elt->ownedOperation)) {
|
||||
foreach ($elt->ownedOperation as &$function) {
|
||||
foreach ($function->ownedParameter as &$parameter) {
|
||||
$this->resolveType($ns, $parameter->type, $_oDef, $elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($elt->ownedAttribute)) {
|
||||
foreach ($elt->ownedAttribute as &$attribute) {
|
||||
$this->resolveType($ns, $attribute->type, $_oDef, $elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($ns->ownedOperation)) {
|
||||
foreach ($ns->ownedOperation as &$function) {
|
||||
foreach ($function->ownedParameter as &$parameter) {
|
||||
$this->resolveType($ns, $parameter->type, $_oDef, $function);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($ns->ownedAttribute)) {
|
||||
foreach ($ns->ownedAttribute as &$attribute) {
|
||||
$this->resolveType($ns, $attribute->type, $_oDef, $attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the stereotype (named $name) associated to the element $element
|
||||
* If not found, returns null.
|
||||
*
|
||||
* @param PHP_UML_Metamodel_NamedElement $element Related object
|
||||
* @param string $profileName Profile name
|
||||
* @param string $stereotypeName Stereotype name
|
||||
*
|
||||
* @return PHP_UML_Metamodel_Stereotype
|
||||
*/
|
||||
public function getStereotype(PHP_UML_Metamodel_NamedElement $element, $profileName, $stereotypeName)
|
||||
{
|
||||
foreach ($this->stereotypes->getIterator() as $s) {
|
||||
if ($s->element == $element && $s->name == $stereotypeName && $s->profile == $profileName) {
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stereotype in a given profile, and binds it to a given element
|
||||
* Returns the stereotype that was created
|
||||
*
|
||||
* @param PHP_UML_Metamodel_NamedElement &$element The element
|
||||
* @param string $profileName The profile name
|
||||
* @param string $stereotypeName The stereotype name
|
||||
*
|
||||
* @return PHP_UML_Metamodel_Stereotype
|
||||
*/
|
||||
public function createStereotype(PHP_UML_Metamodel_NamedElement &$element, $profileName, $stereotypeName)
|
||||
{
|
||||
$stereotype = new PHP_UML_Metamodel_Stereotype;
|
||||
|
||||
$stereotype->profile = $profileName;
|
||||
$stereotype->name = $stereotypeName;
|
||||
$stereotype->element = $element;
|
||||
$this->stereotypes[] = $stereotype;
|
||||
return $stereotype;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the structure before use (we just instantiate the top objects in
|
||||
* the logical and deployment models)
|
||||
*
|
||||
* @param string $modelName Model name
|
||||
*/
|
||||
public function initModel($modelName = 'default')
|
||||
{
|
||||
$this->packages = new PHP_UML_Metamodel_Package;
|
||||
$this->packages->name = $modelName;
|
||||
$this->packages->id = PHP_UML_SimpleUID::getUID();
|
||||
$this->addInternalPhpTypes();
|
||||
|
||||
$this->deploymentPackages = new PHP_UML_Metamodel_Package;
|
||||
$this->deploymentPackages->name = 'Deployment View';
|
||||
$this->deploymentPackages->id = PHP_UML_SimpleUID::getUID();
|
||||
}
|
||||
}
|
||||
?>
|
||||
22
database/php/pear/PHP/UML/Metamodel/Tag.php
Normal file
22
database/php/pear/PHP/UML/Metamodel/Tag.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 97 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-01-04 21:57:08 +0100 (dim., 04 janv. 2009) $
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_Tag extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
public $value;
|
||||
}
|
||||
?>
|
||||
22
database/php/pear/PHP/UML/Metamodel/Type.php
Normal file
22
database/php/pear/PHP/UML/Metamodel/Type.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 135 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2009-11-30 01:21:11 +0100 (lun., 30 nov. 2009) $
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class PHP_UML_Metamodel_Type extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
}
|
||||
?>
|
||||
99
database/php/pear/PHP/UML/Metamodel/TypeResolver.php
Normal file
99
database/php/pear/PHP/UML/Metamodel/TypeResolver.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 175 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2011-09-15 17:07:58 +0200 (jeu., 15 sept. 2011) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A TypeResolver is a class designed to correct a Metamodel_Package whose
|
||||
* relationships between elements are not realized by direct references (nut
|
||||
* by means of a qualified name, or an ID...)
|
||||
* Such a tool is particularly needed when building a UML model, as during the
|
||||
* iteration process, some of the referenced elements may have not yet been met.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
abstract class PHP_UML_Metamodel_TypeResolver
|
||||
{
|
||||
/**
|
||||
* A reference of the top package of the model to resolve
|
||||
*
|
||||
* @var PHP_UML_Metamodel_Package
|
||||
*/
|
||||
protected $topPackage;
|
||||
|
||||
/**
|
||||
* List of default packages where to look for orphaned elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultRepo = array();
|
||||
|
||||
/**
|
||||
* Recursively replaces all the "named types" by a proper "reference" to a
|
||||
* typed element. This impacts:
|
||||
* - the extended classes and implemented classes (through their
|
||||
* EMOF-"superClass" and "implements" relations)
|
||||
* - the function parameters (through their EMOF-"type" attribute)
|
||||
* - the properties in classes (through their EMOF-"type" attribute)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package &$ns Package to resolve the elements of
|
||||
* @param array $default Default packages where to look for
|
||||
* orphaned elements
|
||||
*/
|
||||
abstract public function resolve(PHP_UML_Metamodel_Package &$ns, array $default);
|
||||
|
||||
|
||||
/**
|
||||
* Resolution error. Might later be isolated in a specific class.
|
||||
*
|
||||
* @param string $element Element
|
||||
* @param PHP_UML_Metamodel_NamedElement $na NamedElement
|
||||
*/
|
||||
static protected function resolutionWarning($element, $na)
|
||||
{
|
||||
PHP_UML_Warning::add('Could not resolve '.$element.
|
||||
(empty($na->file) ? '' : ' in '.$na->file->name));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
146
database/php/pear/PHP/UML/Metamodel/TypeResolverById.php
Normal file
146
database/php/pear/PHP/UML/Metamodel/TypeResolverById.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 175 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2011-09-15 17:07:58 +0200 (jeu., 15 sept. 2011) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* An implementation of TypeResolver that complete the relationships between the
|
||||
* elements of a superstructure on the base of the elements ID.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Metamodel_TypeResolverById extends PHP_UML_Metamodel_TypeResolver
|
||||
{
|
||||
public function resolve(PHP_UML_Metamodel_Package &$ns, array $default)
|
||||
{
|
||||
$this->topPackage = $ns;
|
||||
$this->defaultRepo = $default;
|
||||
|
||||
$this->resolvePackage($ns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively replaces all the "named types" by a proper "reference" to a
|
||||
* typed element. This impacts:
|
||||
* - the extended classes and implemented classes (through their
|
||||
* EMOF-"superClass" and "implements" relations)
|
||||
* - the function parameters (through their EMOF-"type" attribute)
|
||||
* - the properties in classes (through their EMOF-"type" attribute)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package &$ns Package to resolve the elements of
|
||||
*/
|
||||
private function resolvePackage(PHP_UML_Metamodel_Package &$ns)
|
||||
{
|
||||
if (!is_null($ns->nestedPackage)) {
|
||||
foreach ($ns->nestedPackage as $key => &$pkg) {
|
||||
$this->resolvePackage($pkg);
|
||||
}
|
||||
}
|
||||
if (!is_null($ns->ownedType))
|
||||
foreach ($ns->ownedType as &$elt) {
|
||||
if (isset($elt->superClass) && !is_null($elt->superClass)) {
|
||||
foreach ($elt->superClass as &$className) {
|
||||
$this->resolveType($ns, $className, $elt);
|
||||
}
|
||||
}
|
||||
if (isset($elt->implements) && !is_null($elt->implements)) {
|
||||
foreach ($elt->implements as &$className) {
|
||||
$this->resolveType($ns, $className, $elt);
|
||||
}
|
||||
}
|
||||
if (isset($elt->ownedOperation)) {
|
||||
foreach ($elt->ownedOperation as &$function) {
|
||||
foreach ($function->ownedParameter as &$parameter) {
|
||||
$this->resolveType($ns, $parameter->type, $elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($elt->ownedAttribute)) {
|
||||
foreach ($elt->ownedAttribute as &$attribute) {
|
||||
$this->resolveType($ns, $attribute->type, $elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($ns->ownedOperation)) {
|
||||
foreach ($ns->ownedOperation as &$function) {
|
||||
foreach ($function->ownedParameter as &$parameter) {
|
||||
$this->resolveType($ns, $parameter->type, $function);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($ns->ownedAttribute)) {
|
||||
foreach ($ns->ownedAttribute as &$attribute) {
|
||||
$this->resolveType($ns, $attribute->type, $attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a URI type reference by grasping a type name in the URI itself
|
||||
* (eg. href="http://schema.omg.org/spec/UML/2.1/uml.xml#Integer")
|
||||
*
|
||||
* @param string $uri URI to resolve
|
||||
*/
|
||||
private function resolveTypeByUri($uri)
|
||||
{
|
||||
if (self::isNsUri($uri)) {
|
||||
foreach ($this->defaultRepo as $itemPkg) {
|
||||
foreach ($itemPkg->ownedType as $item) {
|
||||
if (stripos($uri, $item->name) !== false) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function isNsUri($text)
|
||||
{
|
||||
return (strncasecmp($text, 'http://', 7) == 0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
147
database/php/pear/PHP/UML/Metamodel/TypeResolverByName.php
Normal file
147
database/php/pear/PHP/UML/Metamodel/TypeResolverByName.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 175 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2011-09-15 17:07:58 +0200 (jeu., 15 sept. 2011) $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* An implementation of TypeResolver that completes the relationships between the
|
||||
* elements of a superstructure by using the elements name.
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Metamodel_TypeResolverByName extends PHP_UML_Metamodel_TypeResolver
|
||||
{
|
||||
public function resolve(PHP_UML_Metamodel_Package &$ns, array $default)
|
||||
{
|
||||
$this->topPackage = $ns;
|
||||
$this->defaultRepo = $default;
|
||||
|
||||
$this->resolvePackage($ns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively replaces all the "named types" by a proper reference to a
|
||||
* typed element. This impacts:
|
||||
* - the extended classes and implemented classes (through their
|
||||
* EMOF-"superClass" and "implements" relations)
|
||||
* - the function parameters (through their EMOF-"type" attribute)
|
||||
* - the properties in classes (through their EMOF-"type" attribute)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package &$ns Package to resolve the elements of
|
||||
*/
|
||||
private function resolvePackage(PHP_UML_Metamodel_Package &$ns)
|
||||
{
|
||||
if (!is_null($ns->nestedPackage)) {
|
||||
foreach ($ns->nestedPackage as $key => &$pkg) {
|
||||
$this->resolvePackage($pkg);
|
||||
}
|
||||
}
|
||||
if (!is_null($ns->ownedType))
|
||||
foreach ($ns->ownedType as &$elt) {
|
||||
if (isset($elt->superClass) && !is_null($elt->superClass)) {
|
||||
foreach ($elt->superClass as &$className) {
|
||||
$this->resolveType($ns, $className, $elt);
|
||||
}
|
||||
}
|
||||
if (isset($elt->implements) && !is_null($elt->implements)) {
|
||||
foreach ($elt->implements as &$className) {
|
||||
$this->resolveType($ns, $className, $elt);
|
||||
}
|
||||
}
|
||||
if (isset($elt->ownedOperation)) {
|
||||
foreach ($elt->ownedOperation as &$function) {
|
||||
foreach ($function->ownedParameter as &$parameter) {
|
||||
$this->resolveType($ns, $parameter->type, $elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($elt->ownedAttribute)) {
|
||||
foreach ($elt->ownedAttribute as &$attribute) {
|
||||
$this->resolveType($ns, $attribute->type, $elt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($ns->ownedOperation)) {
|
||||
foreach ($ns->ownedOperation as &$function) {
|
||||
foreach ($function->ownedParameter as &$parameter) {
|
||||
$this->resolveType($ns, $parameter->type, $function);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($ns->ownedAttribute)) {
|
||||
foreach ($ns->ownedAttribute as &$attribute) {
|
||||
$this->resolveType($ns, $attribute->type, $attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
23
database/php/pear/PHP/UML/Metamodel/TypedElement.php
Normal file
23
database/php/pear/PHP/UML/Metamodel/TypedElement.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML (MOF-like metamodel of language PHP)
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Metamodel
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 73 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @link http://www.omg.org/mof/
|
||||
* @since $Date: 2008-12-17 01:30:18 +0100 (mer., 17 déc. 2008) $
|
||||
*
|
||||
*/
|
||||
|
||||
class PHP_UML_Metamodel_TypedElement extends PHP_UML_Metamodel_NamedElement
|
||||
{
|
||||
public $type;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user