Completed
Pull Request — master (#60)
by
unknown
05:50
created
i18n/SemanticCompoundQueries.i18n.magic.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,70 +7,70 @@
 block discarded – undo
7 7
 
8 8
 /** English (English) */
9 9
 $magicWords['en'] = [
10
-	'compound_query' => [ 0, 'compound_query' ],
10
+	'compound_query' => [0, 'compound_query'],
11 11
 ];
12 12
 
13 13
 /** Arabic (العربية) */
14 14
 $magicWords['ar'] = [
15
-	'compound_query' => [ 0, 'استعلام_مركب' ],
15
+	'compound_query' => [0, 'استعلام_مركب'],
16 16
 ];
17 17
 
18 18
 /** Egyptian Arabic (مصرى) */
19 19
 $magicWords['arz'] = [
20
-	'compound_query' => [ 0, 'استعلام_مركب' ],
20
+	'compound_query' => [0, 'استعلام_مركب'],
21 21
 ];
22 22
 
23 23
 /** Chuvash (Чӑвашла) */
24 24
 $magicWords['cv'] = [
25
-	'compound_query' => [ 0, 'compound_query' ],
25
+	'compound_query' => [0, 'compound_query'],
26 26
 ];
27 27
 
28 28
 /** German (Deutsch) */
29 29
 $magicWords['de'] = [
30
-	'compound_query' => [ 0, 'abfrage_zusammen', 'frage_zusammen' ],
30
+	'compound_query' => [0, 'abfrage_zusammen', 'frage_zusammen'],
31 31
 ];
32 32
 
33 33
 /** Japanese (日本語) */
34 34
 $magicWords['ja'] = [
35
-	'compound_query' => [ 0, '複合クエリ', '複合クエリー' ],
35
+	'compound_query' => [0, '複合クエリ', '複合クエリー'],
36 36
 ];
37 37
 
38 38
 /** Korean (한국어) */
39 39
 $magicWords['ko'] = [
40
-	'compound_query' => [ 0, '복합_쿼리' ],
40
+	'compound_query' => [0, '복합_쿼리'],
41 41
 ];
42 42
 
43 43
 /** Macedonian (македонски) */
44 44
 $magicWords['mk'] = [
45
-	'compound_query' => [ 0, 'мешовито_барање' ],
45
+	'compound_query' => [0, 'мешовито_барање'],
46 46
 ];
47 47
 
48 48
 /** Low Saxon (Netherlands) (Nedersaksies) */
49 49
 $magicWords['nds-nl'] = [
50
-	'compound_query' => [ 0, 'samenestelden_zeukopdrachte', 'samengestelde_zoekopdracht' ],
50
+	'compound_query' => [0, 'samenestelden_zeukopdrachte', 'samengestelde_zoekopdracht'],
51 51
 ];
52 52
 
53 53
 /** Dutch (Nederlands) */
54 54
 $magicWords['nl'] = [
55
-	'compound_query' => [ 0, 'samengestelde_zoekopdracht' ],
55
+	'compound_query' => [0, 'samengestelde_zoekopdracht'],
56 56
 ];
57 57
 
58 58
 /** Brazilian Portuguese (português do Brasil) */
59 59
 $magicWords['pt-br'] = [
60
-	'compound_query' => [ 0, 'consulta_composta' ],
60
+	'compound_query' => [0, 'consulta_composta'],
61 61
 ];
62 62
 
63 63
 /** Serbian (Latin script) (srpski (latinica)‎) */
64 64
 $magicWords['sr-el'] = [
65
-	'compound_query' => [ 0, 'sastavi_upit' ],
65
+	'compound_query' => [0, 'sastavi_upit'],
66 66
 ];
67 67
 
68 68
 /** Simplified Chinese (中文(简体)‎) */
69 69
 $magicWords['zh-hans'] = [
70
-	'compound_query' => [ 0, '组合查询' ],
70
+	'compound_query' => [0, '组合查询'],
71 71
 ];
72 72
 
73 73
 /** Traditional Chinese (中文(繁體)‎) */
74 74
 $magicWords['zh-hant'] = [
75
-	'compound_query' => [ 0, '組合搜尋' ],
75
+	'compound_query' => [0, '組合搜尋'],
76 76
 ];
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
src/CompoundQueryResult.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,29 +23,29 @@
 block discarded – undo
23 23
 	 *
24 24
 	 * @param QueryResult $newResult
25 25
 	 */
26
-	public function addResult( QueryResult $newResult ) {
26
+	public function addResult(QueryResult $newResult) {
27 27
 		$existingPageNames = [];
28 28
 
29
-		while ( $row = $this->getNext() ) {
30
-			if ( $row[0] instanceof ResultArray ) {
29
+		while ($row = $this->getNext()) {
30
+			if ($row[0] instanceof ResultArray) {
31 31
 				$content = $row[0]->getContent();
32
-				$existingPageNames[] = $content[0]->getLongText( SMW_OUTPUT_WIKI );
32
+				$existingPageNames[] = $content[0]->getLongText(SMW_OUTPUT_WIKI);
33 33
 			}
34 34
 		}
35 35
 
36
-		while ( ( $row = $newResult->getNext() ) !== false ) {
37
-			if ( property_exists( $newResult, 'display_options' ) ) {
36
+		while (($row = $newResult->getNext()) !== false) {
37
+			if (property_exists($newResult, 'display_options')) {
38 38
 				$row[0]->display_options = $newResult->display_options;
39 39
 			}
40 40
 			$content = $row[0]->getContent();
41
-			$pageName = $content[0]->getLongText( SMW_OUTPUT_WIKI );
41
+			$pageName = $content[0]->getLongText(SMW_OUTPUT_WIKI);
42 42
 
43
-			if ( !in_array( $pageName, $existingPageNames ) ) {
43
+			if (!in_array($pageName, $existingPageNames)) {
44 44
 				$this->m_content[] = $row;
45 45
 			}
46 46
 		}
47 47
 
48
-		reset( $this->m_content );
48
+		reset($this->m_content);
49 49
 	}
50 50
 
51 51
 }
Please login to merge, or discard this patch.
src/Api/CompoundQuery.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 	 * @see ApiBase::execute
22 22
 	 */
23 23
 	public function execute() {
24
-		$parameterFormatter = new ApiRequestParameterFormatter( $this->extractRequestParams() );
24
+		$parameterFormatter = new ApiRequestParameterFormatter($this->extractRequestParams());
25 25
 		$parameters = $parameterFormatter->getAskApiParameters();
26 26
 
27
-		list( $queryParams, $otherParams ) = CompoundQueryProcessor::separateParams( $parameters );
28
-		list( $queryResult ) = CompoundQueryProcessor::queryAndMergeResults( $queryParams, $otherParams );
27
+		list($queryParams, $otherParams) = CompoundQueryProcessor::separateParams($parameters);
28
+		list($queryResult) = CompoundQueryProcessor::queryAndMergeResults($queryParams, $otherParams);
29 29
 
30 30
 		$outputFormat = 'json';
31
-		if ( $this->getMain()->getPrinter() instanceof \ApiFormatXml ) {
31
+		if ($this->getMain()->getPrinter() instanceof \ApiFormatXml) {
32 32
 			$outputFormat = 'xml';
33 33
 		}
34 34
 
35
-		$this->addQueryResult( $queryResult, $outputFormat );
35
+		$this->addQueryResult($queryResult, $outputFormat);
36 36
 	}
37 37
 
38 38
 	/**
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	protected function getExamples() {
84 84
 		return [
85
-			'api.php?action=compoundquery&query=' . urlencode( '[[Has city::Vienna]]; ?Has coordinates|[[Has city::Graz]]; ?Has coordinates' ),
86
-			'api.php?action=compoundquery&query=' . urlencode( '|[[Has city::Vienna]]; ?Has coordinates|[[Has city::Graz]]; ?Has coordinates' ),
85
+			'api.php?action=compoundquery&query=' . urlencode('[[Has city::Vienna]]; ?Has coordinates|[[Has city::Graz]]; ?Has coordinates'),
86
+			'api.php?action=compoundquery&query=' . urlencode('|[[Has city::Vienna]]; ?Has coordinates|[[Has city::Graz]]; ?Has coordinates'),
87 87
 		];
88 88
 	}
89 89
 
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' ) {
4
-	die( 'Not an entry point' );
3
+if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
4
+	die('Not an entry point');
5 5
 }
6 6
 
7
-if ( !is_readable( $autoloaderClassPath = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php' ) ) {
8
-	die( 'The SemanticMediaWiki test autoloader is not available' );
7
+if (!is_readable($autoloaderClassPath = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php')) {
8
+	die('The SemanticMediaWiki test autoloader is not available');
9 9
 }
10 10
 
11
-print sprintf( "\n%-20s%s\n", "Semantic Compound Queries: ", SCQ_VERSION );
11
+print sprintf("\n%-20s%s\n", "Semantic Compound Queries: ", SCQ_VERSION);
12 12
 
13 13
 $autoloader = require $autoloaderClassPath;
14
-$autoloader->addPsr4( 'SCQ\\Tests\\', __DIR__ . '/phpunit/Unit' );
15
-$autoloader->addPsr4( 'SCQ\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' );
16
-unset( $autoloader );
14
+$autoloader->addPsr4('SCQ\\Tests\\', __DIR__ . '/phpunit/Unit');
15
+$autoloader->addPsr4('SCQ\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration');
16
+unset($autoloader);
Please login to merge, or discard this patch.
tests/phpunit/Unit/CompoundQueryProcessorTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @return mixed Method return.
26 26
 	 */
27
-	public function invokeMethod( &$object, $methodName, array $parameters = [] ) {
27
+	public function invokeMethod(&$object, $methodName, array $parameters = []) {
28 28
 
29
-		$reflection = new \ReflectionClass( get_class( $object ) );
30
-		$method = $reflection->getMethod( $methodName );
31
-		$method->setAccessible( true );
29
+		$reflection = new \ReflectionClass(get_class($object));
30
+		$method = $reflection->getMethod($methodName);
31
+		$method->setAccessible(true);
32 32
 
33
-		return $method->invokeArgs( $object, $parameters );
33
+		return $method->invokeArgs($object, $parameters);
34 34
 	}
35 35
 
36 36
 	public function testSeparateParams() {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			]
58 58
 		];
59 59
 
60
-		$this->assertEquals( $expected, CompoundQueryProcessor::separateParams( $params ) );
60
+		$this->assertEquals($expected, CompoundQueryProcessor::separateParams($params));
61 61
 	}
62 62
 
63 63
 	public function testGetSubParams() {
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		];
75 75
 
76 76
 		$processor = new CompoundQueryProcessor();
77
-		$actual = $this->invokeMethod( $processor, 'getSubParams', [ $param ] );
78
-		$this->assertEquals( $expected, $actual );
77
+		$actual = $this->invokeMethod($processor, 'getSubParams', [$param]);
78
+		$this->assertEquals($expected, $actual);
79 79
 	}
80 80
 
81 81
 }
Please login to merge, or discard this patch.
tests/phpunit/Unit/Api/CompoundQueryTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function testCanConstruct() {
30 30
 
31 31
 		$instance = new CompoundQuery(
32
-			$this->apiFactory->newApiMain( [ 'query' => 'Foo' ] ),
32
+			$this->apiFactory->newApiMain(['query' => 'Foo']),
33 33
 			'compoundquery'
34 34
 		);
35 35
 
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * @dataProvider sampleQueryProvider
44 44
 	 */
45
-	public function testExecute( array $query, array $expected ) {
45
+	public function testExecute(array $query, array $expected) {
46 46
 
47
-		$results = $this->apiFactory->doApiRequest( [
47
+		$results = $this->apiFactory->doApiRequest([
48 48
 			'action' => 'compoundquery',
49
-			'query' => implode( '|', $query )
50
-		] );
49
+			'query' => implode('|', $query)
50
+		]);
51 51
 
52 52
 		$this->assertInternalType(
53 53
 			'array',
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 		);
56 56
 
57 57
 		// If their is no printrequests array we expect an error array
58
-		if ( isset( $results['query']['printrequests'] ) ) {
59
-			$this->assertEquals( $expected, $results['query']['printrequests'] );
58
+		if (isset($results['query']['printrequests'])) {
59
+			$this->assertEquals($expected, $results['query']['printrequests']);
60 60
 		} else {
61
-			$this->assertArrayHasKey( 'error', $results );
61
+			$this->assertArrayHasKey('error', $results);
62 62
 		}
63 63
 	}
64 64
 
Please login to merge, or discard this patch.
tests/phpunit/Integration/I18nJsonFileIntegrityTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @dataProvider i18nFileProvider
19 19
 	 */
20
-	public function testI18NJsonDecodeEncode( $file ) {
20
+	public function testI18NJsonDecodeEncode($file) {
21 21
 
22
-		$jsonFileReader = UtilityFactory::getInstance()->newJsonFileReader( $file );
22
+		$jsonFileReader = UtilityFactory::getInstance()->newJsonFileReader($file);
23 23
 
24 24
 		$this->assertInternalType(
25 25
 			'integer',
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 		$provider = [];
38 38
 		$location = $GLOBALS['wgMessagesDirs']['SemanticCompoundQueries'];
39 39
 
40
-		$bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location );
41
-		$bulkFileProvider->searchByFileExtension( 'json' );
40
+		$bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider($location);
41
+		$bulkFileProvider->searchByFileExtension('json');
42 42
 
43
-		foreach ( $bulkFileProvider->getFiles() as $file ) {
44
-			$provider[] = [ $file ];
43
+		foreach ($bulkFileProvider->getFiles() as $file) {
44
+			$provider[] = [$file];
45 45
 		}
46 46
 
47 47
 		return $provider;
Please login to merge, or discard this patch.
tests/phpunit/Unit/CompoundQueryResultTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	protected function setUp() : void {
22 22
 		parent::setUp();
23 23
 
24
-		$this->store = $this->getMockBuilder( '\SMW\Store' )
24
+		$this->store = $this->getMockBuilder('\SMW\Store')
25 25
 			->disableOriginalConstructor()
26 26
 			->getMockForAbstractClass();
27 27
 
28
-		$this->query = $this->getMockBuilder( '\SMWQuery' )
28
+		$this->query = $this->getMockBuilder('\SMWQuery')
29 29
 			->disableOriginalConstructor()
30 30
 			->getMock();
31 31
 	}
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 		$this->assertInstanceOf(
36 36
 			CompoundQueryResult::class,
37
-			new CompoundQueryResult( [], $this->query, [], $this->store )
37
+			new CompoundQueryResult([], $this->query, [], $this->store)
38 38
 		);
39 39
 	}
40 40
 
Please login to merge, or discard this patch.
SemanticCompoundQueries.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	public static function load() {
24 24
 
25
-		if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
25
+		if (is_readable(__DIR__ . '/vendor/autoload.php')) {
26 26
 			include_once __DIR__ . '/vendor/autoload.php';
27 27
 		}
28 28
 	}
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @since 1.1
32 32
 	 */
33
-	public static function initExtension( $credits = [] ) {
33
+	public static function initExtension($credits = []) {
34 34
 
35 35
 		// See https://phabricator.wikimedia.org/T151136
36
-		define( 'SCQ_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' );
36
+		define('SCQ_VERSION', isset($credits['version']) ? $credits['version'] : 'UNKNOWN');
37 37
 
38 38
 		// Register message files
39 39
 		$GLOBALS['wgMessagesDirs']['SemanticCompoundQueries'] = __DIR__ . '/i18n';
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public static function onExtensionFunction() {
48 48
 
49
-		if ( !defined( 'SMW_VERSION' ) ) {
49
+		if (!defined('SMW_VERSION')) {
50 50
 
51
-			if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
52
-				die( "\nThe 'Semantic Compound Queries' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" );
51
+			if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
52
+				die("\nThe 'Semantic Compound Queries' extension requires 'Semantic MediaWiki' to be installed and enabled.\n");
53 53
 			} else {
54 54
 				die(
55 55
 					'<b>Error:</b> The <a href="https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Compound_Queries">Semantic Compound Queries</a> ' .
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		$GLOBALS['wgAPIModules']['compoundquery'] = 'SCQ\Api\CompoundQuery';
64 64
 
65 65
 		// wgHooks
66
-		$GLOBALS['wgHooks']['ParserFirstCallInit'][] = function( Parser &$parser  ) {
67
-			$parser->setFunctionHook( 'compound_query', [ '\SCQ\CompoundQueryProcessor', 'doCompoundQuery' ] );
66
+		$GLOBALS['wgHooks']['ParserFirstCallInit'][] = function(Parser&$parser) {
67
+			$parser->setFunctionHook('compound_query', ['\SCQ\CompoundQueryProcessor', 'doCompoundQuery']);
68 68
 
69 69
 			// always return true, in order not to stop MW's hook processing!
70 70
 			return true;
Please login to merge, or discard this patch.