These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Elgg Entity export. |
||
4 | * Displays an entity using the current view. |
||
5 | * |
||
6 | * @package Elgg |
||
7 | * @subpackage Core |
||
8 | * @deprecated 1.9 |
||
9 | */ |
||
10 | |||
11 | $entity = $vars['entity']; |
||
12 | if (!$entity) { |
||
13 | throw new InvalidParameterException("No entity found, it either doesn't exist or you don't have access to it."); |
||
14 | } |
||
15 | $options = [ |
||
16 | 'guid' => $entity->guid, |
||
17 | 'limit' => 0 |
||
18 | ]; |
||
19 | $metadata = elgg_get_metadata($options); |
||
20 | $annotations = elgg_get_annotations($options); |
||
21 | $relationships = get_entity_relationships($entity->guid); |
||
22 | |||
23 | $exportable_values = $entity->getExportableValues(); |
||
24 | ?> |
||
25 | <div> |
||
26 | <?php // do not change localization string since this is deprecated view ?> |
||
27 | <h2><?php echo elgg_echo('Entity'); ?></h2> |
||
28 | <?php |
||
29 | foreach ($entity as $k => $v) { |
||
30 | if ((in_array($k, $exportable_values)) || (elgg_is_admin_logged_in())) { |
||
31 | ?> |
||
32 | <p class="margin-none"><b><?php echo $k; ?>: </b><?php echo strip_tags($v); ?></p> |
||
33 | <?php |
||
34 | } |
||
35 | } |
||
36 | ?> |
||
37 | </div> |
||
38 | |||
39 | <?php if ($metadata) { ?> |
||
40 | <div id="metadata" class="mtm"> |
||
41 | <h2><?php echo elgg_echo('metadata'); ?></h2> |
||
42 | <?php |
||
43 | foreach ($metadata as $m) { |
||
0 ignored issues
–
show
|
|||
44 | ?> |
||
45 | <p class="margin-none"><b><?php echo $m->name; ?>: </b><?php echo $m->value; ?></p> |
||
46 | <?php |
||
47 | } |
||
48 | ?> |
||
49 | |||
50 | </div> |
||
51 | <?php } ?> |
||
52 | |||
53 | <?php if ($annotations) { ?> |
||
54 | <div id="annotations" class="mtm"> |
||
55 | <h2><?php echo elgg_echo('annotations'); ?></h2> |
||
56 | <?php |
||
57 | foreach ($annotations as $a) { |
||
0 ignored issues
–
show
The expression
$annotations of type array<integer,object<ElggExtender>>|integer is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
Loading history...
|
|||
58 | ?> |
||
59 | <table> |
||
60 | <p class="margin-none"><b><?php echo $a->name; ?>: </b><?php echo $a->value; ?></p> |
||
61 | </table> |
||
62 | <?php |
||
63 | } |
||
64 | ?> |
||
65 | </div> |
||
66 | <?php } ?> |
||
67 | |||
68 | <?php if ($relationships) { ?> |
||
69 | <div id="relationship" class="mtm"> |
||
70 | <h2><?php echo elgg_echo('relationships'); ?></h2> |
||
71 | <?php |
||
72 | foreach ($relationships as $r) { |
||
73 | ?> |
||
74 | <table> |
||
75 | <p class="margin-none"><b><?php echo $r->relationship; ?>: </b><?php echo $r->guid_two; ?></p> |
||
76 | </table> |
||
77 | <?php |
||
78 | } |
||
79 | ?> |
||
80 | </div> |
||
81 | <?php } |
||
82 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.