@@ -23,29 +23,29 @@ |
||
| 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 | } |
@@ -21,18 +21,18 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -24,13 +24,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -7,75 +7,75 @@ |
||
| 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 (Cyrillic script) (српски (ћирилица)) */ |
| 64 | 64 | $magicWords['sr-ec'] = [ |
| 65 | - 'compound_query' => [ 0, 'састави_упит' ], |
|
| 65 | + 'compound_query' => [0, 'састави_упит'], |
|
| 66 | 66 | ]; |
| 67 | 67 | |
| 68 | 68 | /** Serbian (Latin script) (srpski (latinica)) */ |
| 69 | 69 | $magicWords['sr-el'] = [ |
| 70 | - 'compound_query' => [ 0, 'sastavi_upit' ], |
|
| 70 | + 'compound_query' => [0, 'sastavi_upit'], |
|
| 71 | 71 | ]; |
| 72 | 72 | |
| 73 | 73 | /** Simplified Chinese (中文(简体)) */ |
| 74 | 74 | $magicWords['zh-hans'] = [ |
| 75 | - 'compound_query' => [ 0, '组合查询' ], |
|
| 75 | + 'compound_query' => [0, '组合查询'], |
|
| 76 | 76 | ]; |
| 77 | 77 | |
| 78 | 78 | /** Traditional Chinese (中文(繁體)) */ |
| 79 | 79 | $magicWords['zh-hant'] = [ |
| 80 | - 'compound_query' => [ 0, '組合搜尋' ], |
|
| 80 | + 'compound_query' => [0, '組合搜尋'], |
|
| 81 | 81 | ]; |
@@ -1,11 +1,11 @@ |
||
| 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); |
|
@@ -17,9 +17,9 @@ discard block |
||
| 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->assertIsInt( |
| 25 | 25 | $jsonFileReader->getModificationTime() |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | $provider = []; |
| 36 | 36 | $location = $GLOBALS['wgMessagesDirs']['SemanticCompoundQueries']; |
| 37 | 37 | |
| 38 | - $bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location ); |
|
| 39 | - $bulkFileProvider->searchByFileExtension( 'json' ); |
|
| 38 | + $bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider($location); |
|
| 39 | + $bulkFileProvider->searchByFileExtension('json'); |
|
| 40 | 40 | |
| 41 | - foreach ( $bulkFileProvider->getFiles() as $file ) { |
|
| 42 | - $provider[] = [ $file ]; |
|
| 41 | + foreach ($bulkFileProvider->getFiles() as $file) { |
|
| 42 | + $provider[] = [$file]; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | return $provider; |
@@ -29,7 +29,7 @@ discard block |
||
| 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,22 +42,22 @@ discard block |
||
| 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->assertIsArray( |
| 53 | 53 | $results |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | // If their is no printrequests array we expect an error array |
| 57 | - if ( isset( $results['query']['printrequests'] ) ) { |
|
| 58 | - $this->assertEquals( $expected, $results['query']['printrequests'] ); |
|
| 57 | + if (isset($results['query']['printrequests'])) { |
|
| 58 | + $this->assertEquals($expected, $results['query']['printrequests']); |
|
| 59 | 59 | } else { |
| 60 | - $this->assertArrayHasKey( 'error', $results ); |
|
| 60 | + $this->assertArrayHasKey('error', $results); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public static function load() { |
| 26 | 26 | |
| 27 | - if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 27 | + if (is_readable(__DIR__ . '/vendor/autoload.php')) { |
|
| 28 | 28 | include_once __DIR__ . '/vendor/autoload.php'; |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @since 1.1 |
| 34 | 34 | */ |
| 35 | - public static function initExtension( $credits = [] ) { |
|
| 35 | + public static function initExtension($credits = []) { |
|
| 36 | 36 | |
| 37 | 37 | // See https://phabricator.wikimedia.org/T151136 |
| 38 | - define( 'SCQ_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' ); |
|
| 38 | + define('SCQ_VERSION', isset($credits['version']) ? $credits['version'] : 'UNKNOWN'); |
|
| 39 | 39 | |
| 40 | 40 | // Register message files |
| 41 | 41 | $GLOBALS['wgMessagesDirs']['SemanticCompoundQueries'] = __DIR__ . '/i18n'; |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public static function onExtensionFunction() { |
| 50 | 50 | |
| 51 | - if ( !defined( 'SMW_VERSION' ) ) { |
|
| 51 | + if (!defined('SMW_VERSION')) { |
|
| 52 | 52 | |
| 53 | - if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { |
|
| 54 | - die( "\nThe 'Semantic Compound Queries' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" ); |
|
| 53 | + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
|
| 54 | + die("\nThe 'Semantic Compound Queries' extension requires 'Semantic MediaWiki' to be installed and enabled.\n"); |
|
| 55 | 55 | } else { |
| 56 | 56 | die( |
| 57 | 57 | '<b>Error:</b> The <a href="https://www.semantic-mediawiki.org/wiki/Extension:Semantic_Compound_Queries">Semantic Compound Queries</a> ' . |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | // wgHooks |
| 68 | 68 | $hookContainer = MediaWikiServices::getInstance()->getHookContainer(); |
| 69 | - $hookContainer->register( 'ParserFirstCallInit', function( Parser &$parser ) { |
|
| 70 | - $parser->setFunctionHook( 'compound_query', [ '\SCQ\CompoundQueryProcessor', 'doCompoundQuery' ] ); |
|
| 69 | + $hookContainer->register('ParserFirstCallInit', function(Parser&$parser) { |
|
| 70 | + $parser->setFunctionHook('compound_query', ['\SCQ\CompoundQueryProcessor', 'doCompoundQuery']); |
|
| 71 | 71 | |
| 72 | 72 | // always return true, in order not to stop MW's hook processing! |
| 73 | 73 | return true; |