This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | * expression-types.php. |
||
5 | * |
||
6 | * |
||
7 | * Copyright (c) 2010-2013, Justin Swanhart |
||
8 | * with contributions by André Rothe <[email protected], [email protected]> |
||
9 | * and David Négrier <[email protected]> |
||
10 | * |
||
11 | * All rights reserved. |
||
12 | * |
||
13 | * Redistribution and use in source and binary forms, with or without modification, |
||
14 | * are permitted provided that the following conditions are met: |
||
15 | * |
||
16 | * * Redistributions of source code must retain the above copyright notice, |
||
17 | * this list of conditions and the following disclaimer. |
||
18 | * * Redistributions in binary form must reproduce the above copyright notice, |
||
19 | * this list of conditions and the following disclaimer in the documentation |
||
20 | * and/or other materials provided with the distribution. |
||
21 | * |
||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
||
23 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
||
25 | * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
||
27 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
||
28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||
30 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
||
31 | * DAMAGE. |
||
32 | */ |
||
33 | namespace SQLParser\Node; |
||
34 | |||
35 | use Doctrine\DBAL\Connection; |
||
36 | use Mouf\MoufManager; |
||
37 | use SQLParser\Node\Traverser\VisitorInterface; |
||
38 | |||
39 | /** |
||
40 | * This class represents an column in an SQL expression. |
||
41 | * |
||
42 | * @author David Négrier <[email protected]> |
||
43 | */ |
||
44 | class ColRef implements NodeInterface |
||
45 | { |
||
46 | private $table; |
||
47 | |||
48 | /** |
||
49 | * Returns the table name. |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | public function getTable() |
||
54 | { |
||
55 | return $this->table; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Sets the table name. |
||
60 | * |
||
61 | * @Important |
||
62 | * |
||
63 | * @param string $table |
||
64 | */ |
||
65 | public function setTable($table) |
||
66 | { |
||
67 | $this->table = $table; |
||
68 | } |
||
69 | |||
70 | private $column; |
||
71 | |||
72 | /** |
||
73 | * Returns the column name. |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | public function getColumn() |
||
78 | { |
||
79 | return $this->column; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Sets the column name. |
||
84 | * |
||
85 | * @Important |
||
86 | * |
||
87 | * @param string $column |
||
88 | */ |
||
89 | public function setColumn($column) |
||
90 | { |
||
91 | $this->column = $column; |
||
92 | } |
||
93 | |||
94 | private $alias; |
||
95 | |||
96 | /** |
||
97 | * Returns the alias. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getAlias() |
||
102 | { |
||
103 | return $this->alias; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Sets the alias. |
||
108 | * |
||
109 | * @Important |
||
110 | * |
||
111 | * @param string $alias |
||
112 | */ |
||
113 | public function setAlias($alias) |
||
114 | { |
||
115 | $this->alias = $alias; |
||
116 | } |
||
117 | |||
118 | private $direction; |
||
119 | |||
120 | /** |
||
121 | * Returns the direction. |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getDirection() |
||
126 | { |
||
127 | return $this->direction; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Sets the direction. |
||
132 | * |
||
133 | * @Important |
||
134 | * |
||
135 | * @param string $direction |
||
136 | */ |
||
137 | public function setDirection($direction) |
||
138 | { |
||
139 | $this->direction = $direction; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Returns a Mouf instance descriptor describing this object. |
||
144 | * |
||
145 | * @param MoufManager $moufManager |
||
146 | * |
||
147 | * @return MoufInstanceDescriptor |
||
148 | */ |
||
149 | View Code Duplication | public function toInstanceDescriptor(MoufManager $moufManager) |
|
0 ignored issues
–
show
|
|||
150 | { |
||
151 | $instanceDescriptor = $moufManager->createInstance(get_called_class()); |
||
152 | $instanceDescriptor->getProperty('table')->setValue($this->table); |
||
153 | $instanceDescriptor->getProperty('column')->setValue($this->column); |
||
154 | $instanceDescriptor->getProperty('alias')->setValue($this->alias); |
||
155 | $instanceDescriptor->getProperty('direction')->setValue($this->direction); |
||
156 | |||
157 | return $instanceDescriptor; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * Renders the object as a SQL string. |
||
162 | * |
||
163 | * @param Connection $dbConnection |
||
164 | * @param array $parameters |
||
165 | * @param number $indent |
||
166 | * @param int $conditionsMode |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function toSql(array $parameters = array(), Connection $dbConnection = null, $indent = 0, $conditionsMode = self::CONDITION_APPLY) |
||
171 | { |
||
172 | $sql = ''; |
||
173 | if ($this->table) { |
||
174 | $sql .= NodeFactory::escapeDBItem($this->table, $dbConnection).'.'; |
||
175 | } |
||
176 | if ($this->column != '*') { |
||
177 | $sql .= NodeFactory::escapeDBItem($this->column, $dbConnection); |
||
178 | } else { |
||
179 | $sql .= '*'; |
||
180 | } |
||
181 | if ($this->alias) { |
||
182 | $sql .= ' AS '.$this->alias; |
||
183 | } |
||
184 | if ($this->direction) { |
||
185 | $sql .= ' '.$this->direction; |
||
186 | } |
||
187 | |||
188 | return $sql; |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Walks the tree of nodes, calling the visitor passed in parameter. |
||
193 | * |
||
194 | * @param VisitorInterface $visitor |
||
195 | */ |
||
196 | View Code Duplication | public function walk(VisitorInterface $visitor) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
197 | { |
||
198 | $node = $this; |
||
199 | $result = $visitor->enterNode($node); |
||
200 | if ($result instanceof NodeInterface) { |
||
201 | $node = $result; |
||
202 | } |
||
203 | |||
204 | return $visitor->leaveNode($node); |
||
205 | } |
||
206 | } |
||
207 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.