LmuPHP

General information

Florent Delgoulet - 2003
Last update: 2003-07-25
Status: 1.0 stable version (available at https://sourceforge.net/projects/lmuphp/) -> 2003-07-25

Outlines

Requirements
Requirements elicitation
Analysis & Design
Planned enchancements
Examples for version 1.0


Requirements

Purpose

To generate UML diagrams from input files with a defined syntax.
To generate the corresponding PHP class files with comments.

Basic workflow

At one hand, a user creates a .lmu syntax file, in which he defines basically and quickly his different classes and their main characteristics (it corresponds simply to the skeleton of the classes): he can for instance write it using vi on a UNIX platform or NotePad on a Windows platform.
Then he launches the class generation, which will lead to the creation and display of a UML diagram (simplifications but agreement with the latest UML specifications) and possibly to the generation of corresponding .php files with comments that can be parsed by tools such as Doxygen.

.: Top :.


Requirements elicitation

UML diagram

Each class will be represented by a colored box.
Each box will be made of 3 separated parts (see example on the right side):
  • class name and parent class name
  • attributes (order: public, protected, private; then alphabetical order for each kind)
  • methods (alphabetical order, only name, parity (number of parameters) and return type will be displayed (not the full parameters))
The following conventions will be taken:
+ will represent a public attribute or method,
# will represent a protected attribute or method,
- will represent a private attribute or method.
Associations between classes will be symbolized by a straight line with possibly an association name on it.
The cardinalities will be displayed at each side of the association. When an association is in fact an aggregation link, then a white diamond will be displayed, while a black diamond will be displayed in the case of a composition (very strong aggregation) link.
Children classes will be connected to their parent classes (generalization) by straight arrows.
MyClass: MyAncesterClass
+ myPublicAttribute
# myProtectedAttribute
- myPrivateAttribute
+ myPublicMethod1(): string /2
# myProtectedMethod2(): int /0



Scope and limits

The user will not be able to modify directly the UML diagram displayed: he will have to come back to his .lmu file, update it and launch the class generation again.
The user is supposed to use strictly the syntax defined below for the .lmu files.
None of the classes or the associations defined should have the same name as another entity (class or association) in the .lmu file.



Syntax expected in the input files (.lmu)


root                     ::= ( class | association | comment )+

class ::= "$" class_name ( ":" class_parentclass )? "{" ( "+" public_attribute | "#" protected_attribute | "-" private_attribute )* ( "+" public_method | "#" protected_method | "-" private_method )* "}" class_name ::= string class_parentclass ::= string public_attribute ::= attribute protected_attribute ::= attribute private_attribute ::= attribute attribute ::= attribute_name ( ":" attribute_type )? attribute_name ::= string attribute_type ::= possible_types public_method ::= method protected_method ::= method private_method ::= method method ::= "@" method_name "(" ( method_parameters )? ")" ( ":" method_return_type )? method_name ::= string method_parameters ::= method_parameter ( "," method_parameter )* method_parameter ::= parameter_name ( ":" method_parameter_type )? parameter_name ::= string method_parameter_type ::= possible_types method_return_type ::= possible_types
association ::= "& {" class_name1 ( "(" | ")" )? "-" class_name2 ( "#" cardinality ){0, 2} ( "~" association_name )? "}" class_name1 ::= string class_name2 ::= string association_name ::= string
comment ::= "/*" string "*/"
string ::= [ a-zA-Z0-9_ ]+ possible_types ::= ( "int" | "string" | ... )+ cardinality ::= ( "0..1" | "0..*" | "1" | "1..*" )+

Notes:


Examples:

  $ myClass:myAncestor {
    + myPublicAttribute1
    + myPublicAttribute2: int
    -@ myPrivateMethod1 (myParam1: string, myParam2): string
  }
	
  & { 
    myClassCompany - myClassPerson #0..* #1 ~ employs
  }	


Environment

As suggested above, the "program" should be runned either on a UNIX or a Windows platform.
The technology chosen for the implementation is PHP.

.: Top :.


Analysis & Design

Preliminary Note: The classes displayed below do NOT follow the display rules defined above: the methods should be sorted first by type and then alphabetically. The sorting is here different in order to make it easier for the reader to understand the entire process.

Program architecture

To each class identified above will correspond a .class.php file.

.: Top :.


Planned enhancements

Although this first step in the project is far from being completed, I have thought of a couple of possible enhancements for future iterations in the development of the program: .: Top :.


Examples - version 1.0

Here is an example of a UML diagram obtained thanks to LmuPHP 1.0
	 	$ myClass {
			+ myAttr: string
		}
		$ myClass1: myClass {
			# myAttr1: int
			- myAttr2
		}
		$ myClass2: myClass {
		  +@ myMethod1(myParam1: string, myParam2)
			-@ myMethod2(): string
		}
		$ myClass3 {
			+ myAttr: string
			#@ myMethod3()
		}
		$ myClass4 {
			- myAttr4
			-@ myMethod4()
		}
		$ myClass5 {
			- myAttr5: array
		}
		& {
			myClass3 (- myClass2 #0..* #0..1 ~isMadeOf
		}
		& {
			myClass3 - myClass3 #0..* #0..1 ~uses
		}
		& {
			myClass2 )- myClass4 #0..* #0..1 ~has
		}
	 
.: Top :.