These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.ec-cube.co.jp/ |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Eccube\Doctrine\Query; |
||
15 | |||
16 | use Doctrine\ORM\QueryBuilder; |
||
17 | |||
18 | /** |
||
19 | * JOIN句を組み立てるクラス |
||
20 | */ |
||
21 | class JoinClause |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
22 | { |
||
23 | private $join; |
||
24 | |||
25 | private $alias; |
||
26 | |||
27 | private $conditionType; |
||
28 | |||
29 | private $condition; |
||
30 | |||
31 | private $indexBy; |
||
32 | |||
33 | private $leftJoin = false; |
||
34 | |||
35 | /** |
||
36 | * @var JoinClauseWhereCustomizer |
||
37 | */ |
||
38 | private $whereCustomizer; |
||
39 | |||
40 | /** |
||
41 | * @var JoinClauseOrderByCustomizer |
||
42 | */ |
||
43 | private $orderByCustomizer; |
||
44 | |||
45 | /** |
||
46 | * JoinClause constructor. |
||
47 | * |
||
48 | * @param boolean $leftJoin |
||
49 | * @param $join |
||
50 | * @param $alias |
||
51 | * @param $conditionType |
||
52 | * @param $condition |
||
53 | * @param $indexBy |
||
54 | */ |
||
55 | 8 | private function __construct($leftJoin, $join, $alias, $conditionType = null, $condition = null, $indexBy = null) |
|
56 | { |
||
57 | 8 | $this->leftJoin = $leftJoin; |
|
58 | 8 | $this->join = $join; |
|
59 | 8 | $this->alias = $alias; |
|
60 | 8 | $this->conditionType = $conditionType; |
|
61 | 8 | $this->condition = $condition; |
|
62 | 8 | $this->indexBy = $indexBy; |
|
63 | 8 | $this->whereCustomizer = new JoinClauseWhereCustomizer(); |
|
64 | 8 | $this->orderByCustomizer = new JoinClauseOrderByCustomizer(); |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * INNER JOIN用のファクトリメソッド。 |
||
69 | * |
||
70 | * @see QueryBuilder::innerJoin() |
||
71 | * |
||
72 | * @param $join |
||
73 | * @param $alias |
||
74 | * @param $conditionType |
||
75 | * @param $condition |
||
76 | * @param $indexBy |
||
77 | * |
||
78 | * @return JoinClause |
||
79 | */ |
||
80 | 4 | public static function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) |
|
81 | { |
||
82 | 4 | return new JoinClause(false, $join, $alias, $conditionType, $condition, $indexBy); |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * LEFT JOIN用のファクトリメソッド。 |
||
87 | * |
||
88 | * @see QueryBuilder::leftJoin() |
||
89 | * |
||
90 | * @param $join |
||
91 | * @param $alias |
||
92 | * @param $conditionType |
||
93 | * @param $condition |
||
94 | * @param $indexBy |
||
95 | * |
||
96 | * @return JoinClause |
||
97 | */ |
||
98 | 4 | public static function leftJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null) |
|
99 | { |
||
100 | 4 | return new JoinClause(true, $join, $alias, $conditionType, $condition, $indexBy); |
|
101 | } |
||
102 | |||
103 | /** |
||
104 | * WHERE句を追加します。 |
||
105 | * |
||
106 | * @param WhereClause $whereClause |
||
107 | * |
||
108 | * @return $this |
||
109 | */ |
||
110 | 1 | public function addWhere(WhereClause $whereClause) |
|
111 | { |
||
112 | 1 | $this->whereCustomizer->add($whereClause); |
|
113 | |||
114 | 1 | return $this; |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * ORDER BY句を追加します。 |
||
119 | * |
||
120 | * @param OrderByClause $orderByClause |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | 1 | public function addOrderBy(OrderByClause $orderByClause) |
|
125 | { |
||
126 | 1 | $this->orderByCustomizer->add($orderByClause); |
|
127 | |||
128 | 1 | return $this; |
|
129 | } |
||
130 | |||
131 | 8 | public function build(QueryBuilder $builder) |
|
132 | { |
||
133 | 8 | if ($this->leftJoin) { |
|
134 | 4 | $builder->leftJoin($this->join, $this->alias, $this->conditionType, $this->condition, $this->indexBy); |
|
135 | } else { |
||
136 | 4 | $builder->innerJoin($this->join, $this->alias, $this->conditionType, $this->condition, $this->indexBy); |
|
137 | } |
||
138 | 8 | $this->whereCustomizer->customize($builder, null, ''); |
|
0 ignored issues
–
show
null is of type null , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
139 | 8 | $this->orderByCustomizer->customize($builder, null, ''); |
|
0 ignored issues
–
show
null is of type null , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
140 | } |
||
141 | } |
||
142 | |||
143 | class JoinClauseWhereCustomizer extends WhereCustomizer |
||
144 | { |
||
145 | /** |
||
146 | * @var WhereClause[] |
||
147 | */ |
||
148 | private $whereClauses = []; |
||
149 | |||
150 | 1 | public function add(WhereClause $whereClause) |
|
151 | { |
||
152 | 1 | $this->whereClauses[] = $whereClause; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * @param array $params |
||
157 | * @param $queryKey |
||
158 | * |
||
159 | * @return WhereClause[] |
||
160 | */ |
||
161 | 8 | protected function createStatements($params, $queryKey) |
|
162 | { |
||
163 | 8 | return $this->whereClauses; |
|
164 | } |
||
165 | |||
166 | /** |
||
167 | * カスタマイズ対象のキーを返します。 |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getQueryKey() |
||
172 | { |
||
173 | return ''; |
||
174 | } |
||
175 | } |
||
176 | |||
177 | class JoinClauseOrderByCustomizer extends OrderByCustomizer |
||
178 | { |
||
179 | /** |
||
180 | * @var OrderByClause[] |
||
181 | */ |
||
182 | private $orderByClauses = []; |
||
183 | |||
184 | 1 | public function add(OrderByClause $orderByClause) |
|
185 | { |
||
186 | 1 | $this->orderByClauses[] = $orderByClause; |
|
187 | } |
||
188 | |||
189 | /** |
||
190 | * @param array $params |
||
191 | * @param $queryKey |
||
192 | * |
||
193 | * @return OrderByClause[] |
||
194 | */ |
||
195 | 8 | protected function createStatements($params, $queryKey) |
|
196 | { |
||
197 | 8 | return $this->orderByClauses; |
|
198 | } |
||
199 | |||
200 | /** |
||
201 | * カスタマイズ対象のキーを返します。 |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | public function getQueryKey() |
||
206 | { |
||
207 | return ''; |
||
208 | } |
||
209 | } |
||
210 |