package test;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
/**
* A Variable usage. It could be a first use, an in code use of an already declared var.
/** The value. It could change. */
private String value;
- private String prefix;
+ /**
+ * Tell if the variable is a reference or not (given in function by &$varname,
+ * or comming from a 'global' keyword.
+ */
+ private boolean reference;
/**
* Does the variable have a value or not.
}
/**
- * Give a prefix to the variable.
- * @param prefix a prefix
+ * Give a reference to the variable.
+ * @param reference a reference
+ */
+ public void setReference(boolean reference) {
+ this.reference = reference;
+ if (reference) {// a reference variable status is unknown so is initialized for me
+ //example : global
+ initialized = true;
+ }
+ }
+
+ /**
+ * Tell if the variable is reference.
+ * @return a boolean
*/
- public void setPrefix(String prefix) {
- this.prefix = prefix;
+ public boolean isReference() {
+ return reference;
}
public void setUsed(boolean used) {
- PHPeclipsePlugin.log(1,name + " is used");
this.used = used;
}
+ public void setInitialized(boolean initialized) {
+ this.initialized = initialized;
+ }
+
+ /**
+ * Get the name of the variable.
+ * @return a string containing the name of the variable
+ */
public String getName() {
return name;
}
+ /**
+ * Tell if the variable was used.
+ * @return a boolean telling if the variable is used
+ */
public boolean isUsed() {
return used;
}
*/
public String toString() {
if (value == null) {
- if (prefix != null) {
- return prefix + "$" + name;
+ if (reference) {
+ return "&$" + name;
}
return "$" + name;
}
- if (prefix != null) {
- return prefix + "$" + name + "=" + value;
+ if (reference) {
+ return "&$" + name + "=" + value;
}
return "$" + name + "=" + value;
}