Query   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getQueryResults() 0 28 3
1
<?php
2
3
namespace ST;
4
5
class Query {
6
7
	/**
8
	 * This function returns the results of a certain query.
9
	 * Thank you Yaron Koren for advice concerning this code.
10
	 *
11
	 * @param string $query_string The query
12
	 * @param array(String) $properties_to_display Array of property names to display
0 ignored issues
show
Documentation introduced by
The doc-type array(String) could not be parsed: Expected "|" or "end of type", but got "(" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
13
	 * @param boolean $display_title Add the page title in the result
14
	 * @return \SMWQueryResult
15
	 */
16
	static function getQueryResults( $query_string, array $properties_to_display, $display_title ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
		// We use the Semantic MediaWiki Processor
18
		$params = array();
19
		$inline = true;
20
		$printouts = array();
21
22
		// add the page name to the printouts
23
		if ( $display_title ) {
24
			\SMWQueryProcessor::addThisPrintout( $printouts, $params );
25
		}
26
27
		// Push the properties to display in the printout array.
28
		foreach ( $properties_to_display as $property ) {
29
			$to_push = new \SMWPrintRequest(
30
				\SMWPrintRequest::PRINT_PROP,
31
				$property,
32
				\SMW\DataValueFactory::getInstance()->newPropertyValueByLabel( $property )
33
			);
34
			array_push( $printouts, $to_push );
35
		}
36
37
		$params = \SMWQueryProcessor::getProcessedParams( $params, $printouts );
38
39
		$query = \SMWQueryProcessor::createQuery( $query_string, $params, $inline, null, $printouts );
0 ignored issues
show
Documentation introduced by
$inline is of type boolean, but the function expects a integer.

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...
40
		$results = smwfGetStore()->getQueryResult( $query );
41
42
		return $results;
43
	}
44
}
45