| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SCQ\Api; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use SMW\MediaWiki\Api\Query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SMW\MediaWiki\Api\ApiRequestParameterFormatter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SCQ\CompoundQueryProcessor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use ApiBase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * API module to query SMW by providing multiple queries in the ask language. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @license GNU GPL v2+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @author Peter Grassberger < [email protected] > | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | class CompoundQuery extends Query { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | 	 * @see ApiBase::execute | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	public function execute() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		$parameterFormatter = new ApiRequestParameterFormatter( $this->extractRequestParams() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		$parameters = $parameterFormatter->getAskApiParameters(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		list( $queryParams, $otherParams ) = CompoundQueryProcessor::separateParams( $parameters ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		list( $queryResult ) = CompoundQueryProcessor::queryAndMergeResults( $queryParams, $otherParams ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 		$outputFormat = 'json'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		if ( $this->getMain()->getPrinter() instanceof \ApiFormatXml ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 			$outputFormat = 'xml'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		$this->addQueryResult( $queryResult, $outputFormat ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 36 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 	 * @codeCoverageIgnore | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  | 	 * @see ApiBase::getAllowedParams | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  | 	 * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	public function getAllowedParams() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			'query' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 				ApiBase::PARAM_TYPE => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 				ApiBase::PARAM_REQUIRED => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 51 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  | 	 * @codeCoverageIgnore | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 	 * @see ApiBase::getParamDescription | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  | 	 * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	public function getParamDescription() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 			'query' => 'The multiple queries string in ask-language' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 63 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  | 	 * @codeCoverageIgnore | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  | 	 * @see ApiBase::getDescription | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 	 * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	public function getDescription() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 			'API module to query SMW by providing a multiple queries in the ask language.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 75 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  | 	 * @codeCoverageIgnore | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  | 	 * @see ApiBase::getExamples | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  | 	 * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	protected function getExamples() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 88 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  | 	 * @codeCoverageIgnore | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  | 	 * @see ApiBase::getVersion | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  | 	 * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	public function getVersion() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		return __CLASS__ . '-' . SCQ_VERSION; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 98 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 100 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 101 |  |  |  | 
            
                        
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.