--- /dev/null
+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.
+ * In fact I'm not sure for the moment I will keep this
+ * @author Matthieu Casanova
+ */
+public class PHPVar {
+
+ /** The name of the variable. It couldn't be changed. */
+ private final String name;
+
+ /** The value. It could change. */
+ private String value;
+
+ private String prefix;
+
+ /**
+ * Does the variable have a value or not.
+ * If we don't know if it was initialized it should be set on true.
+ * (when we have a global keyword for example)
+ */
+ private boolean initialized;
+
+ /** This variable indicate if it is used or not in the code. */
+ private boolean used;
+
+ /**
+ * We initialize the name and the value of the variable.
+ * @param name the name of the variable
+ * @param value the value of the variable
+ */
+ public PHPVar(String name, String value) {
+ this.name = name;
+ this.value = value;
+ initialized = value != null;
+ }
+
+ /**
+ * We initialize the name of the variable. The value will be null
+ * @param name the name of the variable
+ */
+ public PHPVar(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Initialize the variable name and set the initialization status.
+ * @param name the name of the variable
+ * @param initialized the initialization status (it should be true or it's unuseful)
+ */
+ public PHPVar(String name, boolean initialized) {
+ this(name);
+ this.initialized = initialized;
+ }
+
+ /**
+ * Give a prefix to the variable.
+ * @param prefix a prefix
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public void setUsed(boolean used) {
+ PHPeclipsePlugin.log(1,name + " is used");
+ this.used = used;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isUsed() {
+ return used;
+ }
+
+ /**
+ * Return a human readable variable (:
+ * @return a string representation of the object.
+ */
+ public String toString() {
+ if (value == null) {
+ if (prefix != null) {
+ return prefix + "$" + name;
+ }
+ return "$" + name;
+ }
+ if (prefix != null) {
+ return prefix + "$" + name + "=" + value;
+ }
+ return "$" + name + "=" + value;
+ }
+}