1 | <?php |
||
36 | class ResultSetMapping |
||
37 | { |
||
38 | /** |
||
39 | * Whether the result is mixed (contains scalar values together with field values). |
||
40 | * |
||
41 | * @ignore |
||
42 | * @var boolean |
||
43 | */ |
||
44 | public $isMixed = false; |
||
45 | |||
46 | /** |
||
47 | * Whether the result is a select statement. |
||
48 | * |
||
49 | * @ignore |
||
50 | * @var boolean |
||
51 | */ |
||
52 | public $isSelect = true; |
||
53 | |||
54 | /** |
||
55 | * Maps alias names to class names. |
||
56 | * |
||
57 | * @ignore |
||
58 | * @var array |
||
59 | */ |
||
60 | public $aliasMap = []; |
||
61 | |||
62 | /** |
||
63 | * Maps alias names to related association field names. |
||
64 | * |
||
65 | * @ignore |
||
66 | * @var array |
||
67 | */ |
||
68 | public $relationMap = []; |
||
69 | |||
70 | /** |
||
71 | * Maps alias names to parent alias names. |
||
72 | * |
||
73 | * @ignore |
||
74 | * @var array |
||
75 | */ |
||
76 | public $parentAliasMap = []; |
||
77 | |||
78 | /** |
||
79 | * Maps column names in the result set to field names for each class. |
||
80 | * |
||
81 | * @ignore |
||
82 | * @var array |
||
83 | */ |
||
84 | public $fieldMappings = []; |
||
85 | |||
86 | /** |
||
87 | * Maps column names in the result set to the alias/field name to use in the mapped result. |
||
88 | * |
||
89 | * @ignore |
||
90 | * @var array |
||
91 | */ |
||
92 | public $scalarMappings = []; |
||
93 | |||
94 | /** |
||
95 | * Maps column names in the result set to the alias/field type to use in the mapped result. |
||
96 | * |
||
97 | * @ignore |
||
98 | * @var array |
||
99 | */ |
||
100 | public $typeMappings = []; |
||
101 | |||
102 | /** |
||
103 | * Maps entities in the result set to the alias name to use in the mapped result. |
||
104 | * |
||
105 | * @ignore |
||
106 | * @var array |
||
107 | */ |
||
108 | public $entityMappings = []; |
||
109 | |||
110 | /** |
||
111 | * Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names. |
||
112 | * |
||
113 | * @ignore |
||
114 | * @var array |
||
115 | */ |
||
116 | public $metaMappings = []; |
||
117 | |||
118 | /** |
||
119 | * Maps column names in the result set to the alias they belong to. |
||
120 | * |
||
121 | * @ignore |
||
122 | * @var array |
||
123 | */ |
||
124 | public $columnOwnerMap = []; |
||
125 | |||
126 | /** |
||
127 | * List of columns in the result set that are used as discriminator columns. |
||
128 | * |
||
129 | * @ignore |
||
130 | * @var array |
||
131 | */ |
||
132 | public $discriminatorColumns = []; |
||
133 | |||
134 | /** |
||
135 | * Maps alias names to field names that should be used for indexing. |
||
136 | * |
||
137 | * @ignore |
||
138 | * @var array |
||
139 | */ |
||
140 | public $indexByMap = []; |
||
141 | |||
142 | /** |
||
143 | * Map from column names to class names that declare the field the column is mapped to. |
||
144 | * |
||
145 | * @ignore |
||
146 | * @var array |
||
147 | */ |
||
148 | public $declaringClasses = []; |
||
149 | |||
150 | /** |
||
151 | * This is necessary to hydrate derivate foreign keys correctly. |
||
152 | * |
||
153 | * @var array |
||
154 | */ |
||
155 | public $isIdentifierColumn = []; |
||
156 | |||
157 | /** |
||
158 | * Maps column names in the result set to field names for each new object expression. |
||
159 | * |
||
160 | * @var array |
||
161 | */ |
||
162 | public $newObjectMappings = []; |
||
163 | |||
164 | /** |
||
165 | * Maps last argument for new objects in order to initiate object construction |
||
166 | * |
||
167 | * @var array |
||
168 | */ |
||
169 | public $nestedNewObjectArguments = []; |
||
170 | |||
171 | /** |
||
172 | * Maps metadata parameter names to the metadata attribute. |
||
173 | * |
||
174 | * @var array |
||
175 | */ |
||
176 | public $metadataParameterMapping = []; |
||
177 | |||
178 | /** |
||
179 | * Contains query parameter names to be resolved as discriminator values |
||
180 | * |
||
181 | * @var array |
||
182 | */ |
||
183 | public $discriminatorParameters = []; |
||
184 | |||
185 | /** |
||
186 | * Adds an entity result to this ResultSetMapping. |
||
187 | * |
||
188 | * @param string $class The class name of the entity. |
||
189 | * @param string $alias The alias for the class. The alias must be unique among all entity |
||
190 | * results or joined entity results within this ResultSetMapping. |
||
191 | * @param string|null $resultAlias The result alias with which the entity result should be |
||
192 | * placed in the result structure. |
||
193 | * |
||
194 | * @return ResultSetMapping This ResultSetMapping instance. |
||
195 | * |
||
196 | * @todo Rename: addRootEntity |
||
197 | */ |
||
198 | 1137 | public function addEntityResult($class, $alias, $resultAlias = null) |
|
209 | |||
210 | /** |
||
211 | * Sets a discriminator column for an entity result or joined entity result. |
||
212 | * The discriminator column will be used to determine the concrete class name to |
||
213 | * instantiate. |
||
214 | * |
||
215 | * @param string $alias The alias of the entity result or joined entity result the discriminator |
||
216 | * column should be used for. |
||
217 | * @param string $discrColumn The name of the discriminator column in the SQL result set. |
||
218 | * |
||
219 | * @return ResultSetMapping This ResultSetMapping instance. |
||
220 | * |
||
221 | * @todo Rename: addDiscriminatorColumn |
||
222 | */ |
||
223 | 177 | public function setDiscriminatorColumn($alias, $discrColumn) |
|
230 | |||
231 | /** |
||
232 | * Sets a field to use for indexing an entity result or joined entity result. |
||
233 | * |
||
234 | * @param string $alias The alias of an entity result or joined entity result. |
||
235 | * @param string $fieldName The name of the field to use for indexing. |
||
236 | * |
||
237 | * @return ResultSetMapping This ResultSetMapping instance. |
||
238 | */ |
||
239 | 43 | public function addIndexBy($alias, $fieldName) |
|
266 | |||
267 | /** |
||
268 | * Sets to index by a scalar result column name. |
||
269 | * |
||
270 | * @param string $resultColumnName |
||
271 | * |
||
272 | * @return ResultSetMapping This ResultSetMapping instance. |
||
273 | */ |
||
274 | 3 | public function addIndexByScalar($resultColumnName) |
|
280 | |||
281 | /** |
||
282 | * Sets a column to use for indexing an entity or joined entity result by the given alias name. |
||
283 | * |
||
284 | * @param string $alias |
||
285 | * @param string $resultColumnName |
||
286 | * |
||
287 | * @return ResultSetMapping This ResultSetMapping instance. |
||
288 | */ |
||
289 | 43 | public function addIndexByColumn($alias, $resultColumnName) |
|
295 | |||
296 | /** |
||
297 | * Checks whether an entity result or joined entity result with a given alias has |
||
298 | * a field set for indexing. |
||
299 | * |
||
300 | * @param string $alias |
||
301 | * |
||
302 | * @return boolean |
||
303 | * |
||
304 | * @todo Rename: isIndexed($alias) |
||
305 | */ |
||
306 | 2 | public function hasIndexBy($alias) |
|
310 | |||
311 | /** |
||
312 | * Checks whether the column with the given name is mapped as a field result |
||
313 | * as part of an entity result or joined entity result. |
||
314 | * |
||
315 | * @param string $columnName The name of the column in the SQL result set. |
||
316 | * |
||
317 | * @return boolean |
||
318 | * |
||
319 | * @todo Rename: isField |
||
320 | */ |
||
321 | 1 | public function isFieldResult($columnName) |
|
325 | |||
326 | /** |
||
327 | * Adds a field to the result that belongs to an entity or joined entity. |
||
328 | * |
||
329 | * @param string $alias The alias of the root entity or joined entity to which the field belongs. |
||
330 | * @param string $columnName The name of the column in the SQL result set. |
||
331 | * @param string $fieldName The name of the field on the declaring class. |
||
332 | * @param string|null $declaringClass The name of the class that declares/owns the specified field. |
||
333 | * When $alias refers to a superclass in a mapped hierarchy but |
||
334 | * the field $fieldName is defined on a subclass, specify that here. |
||
335 | * If not specified, the field is assumed to belong to the class |
||
336 | * designated by $alias. |
||
337 | * |
||
338 | * @return ResultSetMapping This ResultSetMapping instance. |
||
339 | * |
||
340 | * @todo Rename: addField |
||
341 | */ |
||
342 | 1122 | public function addFieldResult($alias, $columnName, $fieldName, $declaringClass = null) |
|
357 | |||
358 | /** |
||
359 | * Adds a joined entity result. |
||
360 | * |
||
361 | * @param string $class The class name of the joined entity. |
||
362 | * @param string $alias The unique alias to use for the joined entity. |
||
363 | * @param string $parentAlias The alias of the entity result that is the parent of this joined result. |
||
364 | * @param string $relation The association field that connects the parent entity result |
||
365 | * with the joined entity result. |
||
366 | * |
||
367 | * @return ResultSetMapping This ResultSetMapping instance. |
||
368 | * |
||
369 | * @todo Rename: addJoinedEntity |
||
370 | */ |
||
371 | 387 | public function addJoinedEntityResult($class, $alias, $parentAlias, $relation) |
|
379 | |||
380 | /** |
||
381 | * Adds a scalar result mapping. |
||
382 | * |
||
383 | * @param string $columnName The name of the column in the SQL result set. |
||
384 | * @param string $alias The result alias with which the scalar result should be placed in the result structure. |
||
385 | * @param string $type The column type |
||
386 | * |
||
387 | * @return ResultSetMapping This ResultSetMapping instance. |
||
388 | * |
||
389 | * @todo Rename: addScalar |
||
390 | */ |
||
391 | 331 | public function addScalarResult($columnName, $alias, $type = 'string') |
|
402 | |||
403 | /** |
||
404 | * Adds a metadata parameter mappings. |
||
405 | * |
||
406 | * @param mixed $parameter The parameter name in the SQL result set. |
||
407 | * @param string $attribute The metadata attribute. |
||
408 | */ |
||
409 | public function addMetadataParameterMapping($parameter, $attribute) |
||
413 | |||
414 | /** |
||
415 | * Checks whether a column with a given name is mapped as a scalar result. |
||
416 | * |
||
417 | * @param string $columnName The name of the column in the SQL result set. |
||
418 | * |
||
419 | * @return boolean |
||
420 | * |
||
421 | * @todo Rename: isScalar |
||
422 | */ |
||
423 | 2 | public function isScalarResult($columnName) |
|
427 | |||
428 | /** |
||
429 | * Gets the name of the class of an entity result or joined entity result, |
||
430 | * identified by the given unique alias. |
||
431 | * |
||
432 | * @param string $alias |
||
433 | * |
||
434 | * @return string |
||
435 | */ |
||
436 | 5 | public function getClassName($alias) |
|
440 | |||
441 | /** |
||
442 | * Gets the field alias for a column that is mapped as a scalar value. |
||
443 | * |
||
444 | * @param string $columnName The name of the column in the SQL result set. |
||
445 | * |
||
446 | * @return string |
||
447 | */ |
||
448 | 2 | public function getScalarAlias($columnName) |
|
452 | |||
453 | /** |
||
454 | * Gets the name of the class that owns a field mapping for the specified column. |
||
455 | * |
||
456 | * @param string $columnName |
||
457 | * |
||
458 | * @return string |
||
459 | */ |
||
460 | 4 | public function getDeclaringClass($columnName) |
|
464 | |||
465 | /** |
||
466 | * @param string $alias |
||
467 | * |
||
468 | * @return string |
||
469 | */ |
||
470 | public function getRelation($alias) |
||
474 | |||
475 | /** |
||
476 | * @param string $alias |
||
477 | * |
||
478 | * @return boolean |
||
479 | */ |
||
480 | 1 | public function isRelation($alias) |
|
484 | |||
485 | /** |
||
486 | * Gets the alias of the class that owns a field mapping for the specified column. |
||
487 | * |
||
488 | * @param string $columnName |
||
489 | * |
||
490 | * @return string |
||
491 | */ |
||
492 | 4 | public function getEntityAlias($columnName) |
|
496 | |||
497 | /** |
||
498 | * Gets the parent alias of the given alias. |
||
499 | * |
||
500 | * @param string $alias |
||
501 | * |
||
502 | * @return string |
||
503 | */ |
||
504 | public function getParentAlias($alias) |
||
508 | |||
509 | /** |
||
510 | * Checks whether the given alias has a parent alias. |
||
511 | * |
||
512 | * @param string $alias |
||
513 | * |
||
514 | * @return boolean |
||
515 | */ |
||
516 | 1 | public function hasParentAlias($alias) |
|
520 | |||
521 | /** |
||
522 | * Gets the field name for a column name. |
||
523 | * |
||
524 | * @param string $columnName |
||
525 | * |
||
526 | * @return string |
||
527 | */ |
||
528 | 1 | public function getFieldName($columnName) |
|
532 | |||
533 | /** |
||
534 | * @return array |
||
535 | */ |
||
536 | public function getAliasMap() |
||
540 | |||
541 | /** |
||
542 | * Gets the number of different entities that appear in the mapped result. |
||
543 | * |
||
544 | * @return integer |
||
545 | */ |
||
546 | public function getEntityResultCount() |
||
550 | |||
551 | /** |
||
552 | * Checks whether this ResultSetMapping defines a mixed result. |
||
553 | * |
||
554 | * Mixed results can only occur in object and array (graph) hydration. In such a |
||
555 | * case a mixed result means that scalar values are mixed with objects/array in |
||
556 | * the result. |
||
557 | * |
||
558 | * @return boolean |
||
559 | */ |
||
560 | 1 | public function isMixedResult() |
|
564 | |||
565 | /** |
||
566 | * Adds a meta column (foreign key or discriminator column) to the result set. |
||
567 | * |
||
568 | * @param string $alias The result alias with which the meta result should be placed in the result structure. |
||
569 | * @param string $columnName The name of the column in the SQL result set. |
||
570 | * @param string $fieldName The name of the field on the declaring class. |
||
571 | * @param bool $isIdentifierColumn |
||
572 | * @param string $type The column type |
||
573 | * |
||
574 | * @return ResultSetMapping This ResultSetMapping instance. |
||
575 | * |
||
576 | * @todo Make all methods of this class require all parameters and not infer anything |
||
577 | */ |
||
578 | 760 | public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false, $type = null) |
|
593 | |||
594 | 2 | public function addNewObjectAsArgument($alias, $objOwner, $objOwnerIdx) |
|
612 | } |
||
613 | |||
614 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.