|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* An implementation of dicto (scg.unibe.ch/dicto) in and for PHP. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) 2016, 2015 Richard Klees <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This software is licensed under The MIT License. You should have received |
|
8
|
|
|
* a copy of the license along with the code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Lechimp\Dicto\Indexer; |
|
12
|
|
|
|
|
13
|
|
|
use Lechimp\Dicto\Analysis\Variable; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Duplicate inserts, return handles from both interfaces and analyses them |
|
17
|
|
|
* on usage. |
|
18
|
|
|
*/ |
|
19
|
|
|
class InsertTwice implements Insert { |
|
20
|
|
|
/** |
|
21
|
|
|
* @var Insert |
|
22
|
|
|
*/ |
|
23
|
|
|
public $insert1; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var Insert |
|
27
|
|
|
*/ |
|
28
|
|
|
public $insert2; |
|
29
|
|
|
|
|
30
|
3 |
|
public function __construct(Insert $insert1, Insert $insert2) { |
|
31
|
3 |
|
$this->insert1 = $insert1; |
|
32
|
3 |
|
$this->insert2 = $insert2; |
|
33
|
3 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return Insert |
|
37
|
|
|
*/ |
|
38
|
2 |
|
public function first() { |
|
39
|
2 |
|
return $this->insert1; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return Insert |
|
44
|
|
|
*/ |
|
45
|
2 |
|
public function second() { |
|
46
|
2 |
|
return $this->insert2; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @inheritdocs |
|
53
|
|
|
*/ |
|
54
|
1 |
|
public function _file($path, $source) { |
|
55
|
1 |
|
$id1 = $this->insert1->_file($path, $source); |
|
56
|
1 |
|
$id2 = $this->insert2->_file($path, $source); |
|
57
|
1 |
|
return [$id1, $id2]; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @inheritdocs |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function _namespace($name) { |
|
64
|
1 |
|
$id1 = $this->insert1->_namespace($name); |
|
65
|
1 |
|
$id2 = $this->insert2->_namespace($name); |
|
66
|
1 |
|
return [$id1, $id2]; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @inheritdocs |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function _class($name, $file, $start_line, $end_line, $namespace = null) { |
|
73
|
1 |
|
$id1 = $this->insert1->_class($name, $file[0], $start_line, $end_line, $namespace[0]); |
|
74
|
1 |
|
$id2 = $this->insert2->_class($name, $file[1], $start_line, $end_line, $namespace[1]); |
|
75
|
1 |
|
return [$id1, $id2]; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @inheritdocs |
|
80
|
|
|
*/ |
|
81
|
|
|
public function _interface($name, $file, $start_line, $end_line, $namespace = null) { |
|
82
|
|
|
$id1 = $this->insert1->_interface($name, $file[0], $start_line, $end_line, $namespace[0]); |
|
83
|
|
|
$id2 = $this->insert2->_interface($name, $file[1], $start_line, $end_line, $namespace[1]); |
|
84
|
|
|
return [$id1, $id2]; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @inheritdocs |
|
89
|
|
|
*/ |
|
90
|
|
|
public function _trait($name, $file, $start_line, $end_line, $namespace = null) { |
|
91
|
|
|
$id1 = $this->insert1->_trait($name, $file[0], $start_line, $end_line, $namespace[0]); |
|
92
|
|
|
$id2 = $this->insert2->_trait($name, $file[1], $start_line, $end_line, $namespace[1]); |
|
93
|
|
|
return [$id1, $id2]; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @inheritdocs |
|
98
|
|
|
*/ |
|
99
|
1 |
|
public function _method($name, $class, $file, $start_line, $end_line) { |
|
100
|
1 |
|
$id1 = $this->insert1->_method($name, $class[0], $file[0], $start_line, $end_line); |
|
101
|
1 |
|
$id2 = $this->insert2->_method($name, $class[1], $file[1], $start_line, $end_line); |
|
102
|
1 |
|
return [$id1, $id2]; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @inheritdocs |
|
107
|
|
|
*/ |
|
108
|
1 |
|
public function _function($name, $file, $start_line, $end_line, $namespace = null) { |
|
109
|
1 |
|
$id1 = $this->insert1->_function($name, $file[0], $start_line, $end_line, $namespace[0]); |
|
110
|
1 |
|
$id2 = $this->insert2->_function($name, $file[1], $start_line, $end_line, $namespace[1]); |
|
111
|
1 |
|
return [$id1, $id2]; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @inheritdocs |
|
116
|
|
|
*/ |
|
117
|
1 |
|
public function _global($name) { |
|
118
|
1 |
|
$id1 = $this->insert1->_global($name); |
|
119
|
1 |
|
$id2 = $this->insert2->_global($name); |
|
120
|
1 |
|
return [$id1, $id2]; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @inheritdocs |
|
125
|
|
|
*/ |
|
126
|
1 |
|
public function _language_construct($name) { |
|
127
|
1 |
|
$id1 = $this->insert1->_language_construct($name); |
|
128
|
1 |
|
$id2 = $this->insert2->_language_construct($name); |
|
129
|
1 |
|
return [$id1, $id2]; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @inheritdocs |
|
134
|
|
|
*/ |
|
135
|
1 |
|
public function _method_reference($name, $file, $line, $column) { |
|
136
|
1 |
|
$id1 = $this->insert1->_method_reference($name, $file[0], $line, $column); |
|
137
|
1 |
|
$id2 = $this->insert2->_method_reference($name, $file[1], $line, $column); |
|
138
|
1 |
|
return [$id1, $id2]; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @inheritdocs |
|
143
|
|
|
*/ |
|
144
|
1 |
|
public function _function_reference($name, $file, $line, $column) { |
|
145
|
1 |
|
$id1 = $this->insert1->_function_reference($name, $file[0], $line, $column); |
|
146
|
1 |
|
$id2 = $this->insert2->_function_reference($name, $file[1], $line, $column); |
|
147
|
1 |
|
return [$id1, $id2]; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @inheritdocs |
|
152
|
|
|
*/ |
|
153
|
1 |
|
public function _relation($left_entity, $relation, $right_entity, $file, $line) { |
|
154
|
1 |
|
$id1 = $this->insert1->_relation($left_entity[0], $relation, $right_entity[0], $file[0], $line); |
|
|
|
|
|
|
155
|
1 |
|
$id2 = $this->insert2->_relation($left_entity[1], $relation, $right_entity[1], $file[1], $line); |
|
|
|
|
|
|
156
|
1 |
|
return [$id1, $id2]; |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.