5 * A Variable usage. It could be a first use, an in code use of an already declared var.
6 * In fact I'm not sure for the moment I will keep this
7 * @author Matthieu Casanova
11 /** The name of the variable. It couldn't be changed. */
12 private final String name;
14 /** The value. It could change. */
18 * Tell if the variable is a reference or not (given in function by &$varname,
19 * or comming from a 'global' keyword.
21 private boolean reference;
24 * Does the variable have a value or not.
25 * If we don't know if it was initialized it should be set on true.
26 * (when we have a global keyword for example)
28 private boolean initialized;
30 /** This variable indicate if it is used or not in the code. */
34 * We initialize the name and the value of the variable.
35 * @param name the name of the variable
36 * @param value the value of the variable
38 public PHPVar(String name, String value) {
41 initialized = value != null;
45 * We initialize the name of the variable. The value will be null
46 * @param name the name of the variable
48 public PHPVar(String name) {
53 * Initialize the variable name and set the initialization status.
54 * @param name the name of the variable
55 * @param initialized the initialization status (it should be true or it's unuseful)
57 public PHPVar(String name, boolean initialized) {
59 this.initialized = initialized;
63 * Give a reference to the variable.
64 * @param reference a reference
66 public void setReference(boolean reference) {
67 this.reference = reference;
68 if (reference) {// a reference variable status is unknown so is initialized for me
75 * Tell if the variable is reference.
78 public boolean isReference() {
82 public void setUsed(boolean used) {
86 public void setInitialized(boolean initialized) {
87 this.initialized = initialized;
91 * Get the name of the variable.
92 * @return a string containing the name of the variable
94 public String getName() {
99 * Tell if the variable was used.
100 * @return a boolean telling if the variable is used
102 public boolean isUsed() {
107 * Return a human readable variable (:
108 * @return a string representation of the object.
110 public String toString() {
118 return "&$" + name + "=" + value;
120 return "$" + name + "=" + value;