3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
6 * A Variable usage. It could be a first use, an in code use of an already declared var.
7 * In fact I'm not sure for the moment I will keep this
8 * @author Matthieu Casanova
12 /** The name of the variable. It couldn't be changed. */
13 private final String name;
15 /** The value. It could change. */
19 * Tell if the variable is a reference or not (given in function by &$varname,
20 * or comming from a 'global' keyword.
22 private boolean reference;
25 * Does the variable have a value or not.
26 * If we don't know if it was initialized it should be set on true.
27 * (when we have a global keyword for example)
29 private boolean initialized;
31 /** This variable indicate if it is used or not in the code. */
35 * We initialize the name and the value of the variable.
36 * @param name the name of the variable
37 * @param value the value of the variable
39 public PHPVar(String name, String value) {
42 initialized = value != null;
46 * We initialize the name of the variable. The value will be null
47 * @param name the name of the variable
49 public PHPVar(String name) {
54 * Initialize the variable name and set the initialization status.
55 * @param name the name of the variable
56 * @param initialized the initialization status (it should be true or it's unuseful)
58 public PHPVar(String name, boolean initialized) {
60 this.initialized = initialized;
64 * Give a reference to the variable.
65 * @param reference a reference
67 public void setReference(boolean reference) {
68 this.reference = reference;
69 if (reference) {// a reference variable status is unknown so is initialized for me
76 * Tell if the variable is reference.
79 public boolean isReference() {
83 public void setUsed(boolean used) {
87 public void setInitialized(boolean initialized) {
88 this.initialized = initialized;
92 * Get the name of the variable.
93 * @return a string containing the name of the variable
95 public String getName() {
100 * Tell if the variable was used.
101 * @return a boolean telling if the variable is used
103 public boolean isUsed() {
108 * Return a human readable variable (:
109 * @return a string representation of the object.
111 public String toString() {
119 return "&$" + name + "=" + value;
121 return "$" + name + "=" + value;