Completed
Push — master ( 41d4aa...7dfe14 )
by Damian
02:52
created

SideReport_BrokenFiles   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 6
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * @package cms
5
 * @subpackage reports
6
 */
7
class BrokenFilesReport extends SS_Report {
8
9
	public function title() {
10
		return _t('SideReport.BROKENFILES',"Pages with broken files");
11
	}
12
13
	public function group() {
14
		return _t('SideReport.BrokenLinksGroupTitle', "Broken links reports");
15
	}
16
17
	public function sourceRecords($params = null) {
18
		// Get class names for page types that are not virtual pages or redirector pages
19
		$classes = array_diff(
20
			ClassInfo::subclassesFor('SiteTree'),
21
			ClassInfo::subclassesFor('VirtualPage'),
22
			ClassInfo::subclassesFor('RedirectorPage')
23
		);
24
		$classParams = DB::placeholders($classes);
25
		$classFilter = array(
26
			"\"ClassName\" IN ($classParams) AND \"HasBrokenFile\" = 1" => $classes
27
		);
28
		
29
		$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
30
		return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
0 ignored issues
show
Documentation introduced by
$classFilter is of type array<string|integer,array>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
	}
32
33
	public function columns() {
34
		return array(
35
			"Title" => array(
36
				"title" => "Title", // todo: use NestedTitle(2)
37
				"link" => true,
38
			),
39
		);
40
	}
41
42
	public function getParameterFields() {
43
		return new FieldList(
44
			new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
45
		);
46
	}
47
}
48
49
/**
50
 * @deprecated 3.2..4.0
51
 */
52
class SideReport_BrokenFiles extends BrokenFilesReport {
53
	public function __construct() {
54
		Deprecation::notice('4.0', 'Use BrokenFilesReport instead');
55
		parent::__construct();
56
	}
57
}
58