Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

views/default/admin/statistics/numentities.php (1 issue)

Checks if the types of the passed arguments in a function/method call are compatible.

Bug Minor
1
<?php
2
// Get entity statistics
3
$entity_stats = get_entity_statistics();
4
5
$registered_entity_types = get_registered_entity_types();
6
7
$searchable = [];
8
$other = [];
9
10
foreach ($entity_stats as $type => $subtypes) {
11
	foreach ($subtypes as $subtype => $value) {
12
		$is_registered = false;
13
		if ($subtype == '__base__') {
14
			$is_registered = array_key_exists($type, $registered_entity_types);
0 ignored issues
show
$registered_entity_types of type false is incompatible with the type array expected by parameter $search of array_key_exists(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

14
			$is_registered = array_key_exists($type, /** @scrutinizer ignore-type */ $registered_entity_types);
Loading history...
15
			$name = elgg_echo("item:$type");
16
		} else {
17
			$is_registered = in_array($subtype, $registered_entity_types[$type]);
18
			$name = elgg_echo("item:$type:$subtype");
19
		}
20
		
21
		if ($is_registered) {
22
			$searchable[$name] = $value;
23
		} else {
24
			$other[$name] = $value;
25
		}
26
	}
27
}
28
29
arsort($searchable);
30
arsort($other);
31
32
$header = '<tr><th>' . elgg_echo('admin:statistics:numentities:type') . '</th>';
33
$header .= '<th>' . elgg_echo('admin:statistics:numentities:number') . '</th></tr>';
34
35
$rows = '';
36
37
foreach ($searchable as $name => $value) {
38
	$rows .= "<tr><td>{$name}</td><td>{$value}</td></tr>";
39
}
40
echo '<h4>' . elgg_echo('admin:statistics:numentities:searchable') . '</h4>';
41
echo "<table class='elgg-table-alt'>{$header}{$rows}</table>";
42
echo '<br />';
43
44
45
$rows = '';
46
foreach ($other as $name => $value) {
47
	$rows .= "<tr><td>{$name}</td><td>{$value}</td></tr>";
48
}
49
echo '<h4>' . elgg_echo('admin:statistics:numentities:other') . '</h4>';
50
echo "<table class='elgg-table-alt'>{$header}{$rows}</table>";
51