Debian Codegraph @

util/docscripts/lib/parser2/JavaScriptOr.php

raw symbols SCIP
1 <?php
2
3 class JavaScriptOr extends JavaScriptVariable {
4 protected $ors;
5
6 public function __construct($ors) {
7 if (!is_array($ors)) {
8 throw new Exception('JavaScriptOr expects to be passed an array');
9 }
10 $this->ors = $ors;
11 }
12
13 public function __destruct() {
14 $this->mem_flush('ors');
15 }
16
17 public function types() {
18 $mapped = array();
19 foreach ($this->ors as $item) {
20 $mapped[] = $item->type();
21 }
22 return $mapped;
23 }
24
25 public function type() {
26 $types = array_diff($this->types(), array('variable'));
27 if (count($types) == 1) {
28 return array_pop($types);
29 }
30 // Assume that if one of them is a boolean, they all are
31 if (in_array('bool', $types)) {
32 return 'bool';
33 }
34
35 return 'Object';
36 }
37 }