X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPVar.java b/net.sourceforge.phpeclipse/src/test/PHPVar.java index aa2123c..497000d 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPVar.java +++ b/net.sourceforge.phpeclipse/src/test/PHPVar.java @@ -1,6 +1,5 @@ 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. @@ -15,7 +14,11 @@ public class PHPVar { /** 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. @@ -57,22 +60,45 @@ public class PHPVar { } /** - * 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; } @@ -83,13 +109,13 @@ public class PHPVar { */ 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; }