994404f3e2bc66e326c63c9f673f7ada9f96c27c
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / PHPVarDeclaration.java
1 package net.sourceforge.phpdt.internal.compiler.parser;
2
3 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
4
5 import org.eclipse.jface.resource.ImageDescriptor;
6 import test.PHPVar;
7
8 /**
9  * A php variable declaration strongly inspired by the PHPFunctionDeclaration of Khartlage (:.
10  * @author khartlage, Matthieu Casanova
11  */
12 public class PHPVarDeclaration extends PHPSegment {
13
14   /** A PHPVar. */
15   private final PHPVar variable;
16     /**
17      * Create a php variable declaration.
18      * @param parent the parent object (it should be a php class)
19      * @param name the name of the variable
20      * @param index where the variable is in the file
21      * @param value the value
22      */
23     public PHPVarDeclaration(Object parent, String name, int index, String value) {
24       super(parent, name, index);
25       variable = new PHPVar(name,value);
26     }
27
28   /**
29    * Create a php variable declaration.
30    * @param parent the parent object (it should be a php class)
31    * @param name the name of the variable
32    * @param index where the variable is in the file
33    */
34   public PHPVarDeclaration(Object parent, String name, int index) {
35       this(parent, name, index,null);
36   }
37
38     /**
39      * Get the image of a variable.
40      * @return the image that represents a php variable
41      */
42     public ImageDescriptor getImage() {
43         return PHPUiImages.DESC_VAR;
44     }
45
46   /**
47    * Get the PHPVar.
48    * @return a phpvar object
49    */
50   public PHPVar getVariable() {
51     return variable;
52   }
53
54   public String toString() {
55     return variable.toString();
56   }
57 }