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

mod/file/views/default/resources/file/view.php (2 issues)

calls to methods that only exist in a sub-type.

Bug Major
1
<?php
2
/**
3
 * View a file
4
 *
5
 * @package ElggFile
6
 */
7
8
$guid = elgg_extract('guid', $vars);
9
10
elgg_entity_gatekeeper($guid, 'object', 'file');
11
12
$file = get_entity($guid);
13
14
$owner = elgg_get_page_owner_entity();
15
16
elgg_group_gatekeeper();
17
18
elgg_push_breadcrumb(elgg_echo('file'), 'file/all');
19
20
$crumbs_title = $owner->getDisplayName();
21
if ($owner instanceof ElggGroup) {
22
	elgg_push_breadcrumb($crumbs_title, "file/group/$owner->guid/all");
23
} else {
24
	elgg_push_breadcrumb($crumbs_title, "file/owner/$owner->username");
25
}
26
27
$title = $file->getDisplayName();
28
29
$content = elgg_view_entity($file, [
30
	'full_view' => true,
31
	'show_responses' => true,
32
]);
33
34
if ($file->canDownload()) {
1 ignored issue
show
The method canDownload() does not exist on ElggEntity. It seems like you code against a sub-type of ElggEntity such as ElggFile. ( Ignorable by Annotation )

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

34
if ($file->/** @scrutinizer ignore-call */ canDownload()) {
Loading history...
35
	elgg_register_menu_item('title', [
36
		'name' => 'download',
37
		'text' => elgg_echo('download'),
38
		'href' => $file->getDownloadURL(),
1 ignored issue
show
The method getDownloadURL() does not exist on ElggEntity. It seems like you code against a sub-type of ElggEntity such as ElggFile. ( Ignorable by Annotation )

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

38
		'href' => $file->/** @scrutinizer ignore-call */ getDownloadURL(),
Loading history...
39
		'link_class' => 'elgg-button elgg-button-action',
40
	]);
41
}
42
43
$body = elgg_view_layout('content', [
44
	'content' => $content,
45
	'title' => $title,
46
	'filter' => '',
47
]);
48
49
echo elgg_view_page($title, $body);
50