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