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

SideReport_BrokenVirtualPages   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 BrokenVirtualPagesReport extends SS_Report {
8
9
	public function title() {
10
		return _t('SideReport.BROKENVIRTUALPAGES', 'VirtualPages pointing to deleted pages');
11
	}
12
13
	public function group() {
14
		return _t('SideReport.BrokenLinksGroupTitle', "Broken links reports");
15
	}
16
17
	public function sourceRecords($params = null) {
18
		$classes = ClassInfo::subclassesFor('VirtualPage');
19
		$classParams = DB::placeholders($classes);
0 ignored issues
show
Bug introduced by
It seems like $classes defined by \ClassInfo::subclassesFor('VirtualPage') on line 18 can also be of type null; however, DB::placeholders() does only seem to accept array|integer, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
20
		$classFilter = array(
21
			"\"ClassName\" IN ($classParams) AND \"HasBrokenLink\" = 1" => $classes
22
		);
23
		$stage = isset($params['OnLive']) ? 'Live' : 'Stage';
24
		return Versioned::get_by_stage('SiteTree', $stage, $classFilter);
0 ignored issues
show
Documentation introduced by
$classFilter is of type array<string|integer,null|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...
25
	}
26
	
27
	public function columns() {
28
		return array(
29
			"Title" => array(
30
				"title" => "Title", // todo: use NestedTitle(2)
31
				"link" => true,
32
			),
33
		);
34
	}
35
36
	public function getParameterFields() {
37
		return new FieldList(
38
			new CheckboxField('OnLive', _t('SideReport.ParameterLiveCheckbox', 'Check live site'))
39
		);
40
	}
41
}
42
43
/**
44
 * @deprecated 3.2..4.0
45
 */
46
class SideReport_BrokenVirtualPages extends BrokenVirtualPagesReport {
47
	public function __construct() {
48
		Deprecation::notice('4.0', 'Use BrokenVirtualPagesReport instead');
49
		parent::__construct();
50
	}
51
}
52