1 | <?php |
||
15 | abstract class Variable extends Def\Definition { |
||
16 | // TODO: Use these in Graph/IndexDB. |
||
17 | const CLASS_TYPE = "class"; |
||
18 | const FILE_TYPE = "file"; |
||
19 | const GLOBAL_TYPE = "global"; |
||
20 | const FUNCTION_TYPE = "function"; |
||
21 | const METHOD_TYPE = "method"; |
||
22 | const LANGUAGE_CONSTRUCT_TYPE = "language construct"; |
||
23 | |||
24 | static public function is_type($t) { |
||
35 | |||
36 | /** |
||
37 | * @var string|null |
||
38 | */ |
||
39 | private $name; |
||
40 | |||
41 | 90 | public function __construct($name = null) { |
|
45 | |||
46 | /** |
||
47 | * @return string|null |
||
48 | */ |
||
49 | 183 | public function name() { |
|
52 | |||
53 | /** |
||
54 | * @param string $name |
||
55 | * @return self |
||
56 | */ |
||
57 | 32 | public function withName($name) { |
|
63 | |||
64 | /** |
||
65 | * Get the meaning of the variable. |
||
66 | * |
||
67 | * In opposite to name, this gives insight in the structure of this variable. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | abstract public function meaning(); |
||
72 | |||
73 | /** |
||
74 | * Compile the variable to a condition on a graph node. |
||
75 | * |
||
76 | * TODO: Maybe negate can go away. |
||
77 | * |
||
78 | * @param bool $negate |
||
79 | * @return \Closure Node -> bool |
||
80 | */ |
||
81 | abstract public function compile($negate = false); |
||
82 | } |
||
83 | |||
84 |