Debian Codegraph @

util/docscripts/lib/parser2/JavaScriptAssignment.php

raw symbols SCIP
1 <?php
2
3 require_once('JavaScriptVariable.php');
4
5 class JavaScriptAssignment extends JavaScriptVariable {
6 protected $value;
7 protected $resolved_value;
8
9 public function __construct($variable, $value) {
10 parent::__construct($variable);
11 $this->value = $value;
12 }
13
14 public function __destruct() {
15 $this->mem_flush('value', 'resolved_value');
16 }
17
18 public function name() {
19 return parent::value();
20 }
21
22 public function names() {
23 return parent::values();
24 }
25
26 public function value() {
27 if (!isset($this->resolved_value)) {
28 $value = $this->value;
29 if (is_array($value) && count($value) == 1) {
30 $value = $value[0];
31 }
32 $this->resolved_value = $value->convert();
33 }
34 return $this->resolved_value;
35 }
36
37 public function types() {
38 $value = $this->value();
39 if (is_array($value)) {
40 $mapped = array();
41 foreach ($value as $item) {
42 $mapped[] = $item->type();
43 }
44 return $mapped;
45 }
46 return array($value->type());
47 }
48
49 public function type() {
50 $types = array_diff($this->types(), array('variable'));
51 if (count($types) == 1) {
52 return array_pop($types);
53 }
54 return '';
55 }
56 }