Completed
Push — master ( 83a86a...2e6a75 )
by
unknown
03:25
created
WikibaseQualityExternalValidation.alias.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,6 +11,6 @@
 block discarded – undo
11 11
 
12 12
 /** English (English) */
13 13
 $specialPageAliases['en'] = array(
14
-	'CrossCheck' => array( 'CrossCheck', 'Cross Check' ),
15
-	'ExternalDbs' => array( 'ExternalDbs', 'External Dbs' ),
14
+	'CrossCheck' => array('CrossCheck', 'Cross Check'),
15
+	'ExternalDbs' => array('ExternalDbs', 'External Dbs'),
16 16
 );
17 17
\ No newline at end of file
Please login to merge, or discard this patch.
WikibaseQualityExternalValidation.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
2
+if (file_exists(__DIR__ . '/vendor/autoload.php')) {
3 3
 	require_once __DIR__ . '/vendor/autoload.php';
4 4
 }
5 5
 
6
-call_user_func( function () {
6
+call_user_func(function() {
7 7
 	// Set credits
8 8
 	$GLOBALS['wgExtensionCredits']['specialpage'][] = array(
9 9
 		'path' => __FILE__,
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	// Define API modules
32 32
 	$GLOBALS['wgAPIModules']['wbqevcrosscheck'] = array(
33 33
 		'class' => 'WikibaseQuality\ExternalValidation\Api\RunCrossCheck',
34
-		'factory' => function( ApiMain $main, $action ) {
35
-			return \WikibaseQuality\ExternalValidation\Api\RunCrossCheck::newFromGlobalState( $main, $action );
34
+		'factory' => function(ApiMain $main, $action) {
35
+			return \WikibaseQuality\ExternalValidation\Api\RunCrossCheck::newFromGlobalState($main, $action);
36 36
 		}
37 37
 	);
38 38
 
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	);
45 45
 
46 46
 	// Ids of certain Wikidata entities
47
-	if( !defined( 'INSTANCE_OF_PID' ) ) {
48
-		define( 'INSTANCE_OF_PID', 'P31' );
47
+	if (!defined('INSTANCE_OF_PID')) {
48
+		define('INSTANCE_OF_PID', 'P31');
49 49
 	}
50
-	if( !defined( 'IDENTIFIER_PROPERTY_QID' ) ) {
51
-		define( 'IDENTIFIER_PROPERTY_QID', 'Q19847637' );
50
+	if (!defined('IDENTIFIER_PROPERTY_QID')) {
51
+		define('IDENTIFIER_PROPERTY_QID', 'Q19847637');
52 52
 	}
53
-	if( !defined( 'STATED_IN_PID' ) ) {
54
-		define( 'STATED_IN_PID', 'P248' );
53
+	if (!defined('STATED_IN_PID')) {
54
+		define('STATED_IN_PID', 'P248');
55 55
 	}
56 56
 } );
Please login to merge, or discard this patch.
WikibaseQualityExternalValidationHooks.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
 	 *
8 8
 	 * @return bool
9 9
 	 */
10
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
11
-		$updater->addExtensionTable( 'wbqev_dump_information', __DIR__ . '/sql/create_wbqev_dump_information.sql' );
12
-		$updater->addExtensionTable( 'wbqev_external_data', __DIR__ . '/sql/create_wbqev_external_data.sql' );
13
-		$updater->addExtensionTable( 'wbqev_identifier_properties', __DIR__ . '/sql/create_wbqev_identifier_properties.sql' );
10
+	public static function onCreateSchema(DatabaseUpdater $updater) {
11
+		$updater->addExtensionTable('wbqev_dump_information', __DIR__ . '/sql/create_wbqev_dump_information.sql');
12
+		$updater->addExtensionTable('wbqev_external_data', __DIR__ . '/sql/create_wbqev_external_data.sql');
13
+		$updater->addExtensionTable('wbqev_identifier_properties', __DIR__ . '/sql/create_wbqev_identifier_properties.sql');
14 14
 
15 15
 		return true;
16 16
 	}
17 17
 
18
-	public static function onUnitTestsList( &$paths ) {
18
+	public static function onUnitTestsList(&$paths) {
19 19
 		$paths[] = __DIR__ . '/tests/phpunit';
20 20
 		return true;
21 21
 	}
Please login to merge, or discard this patch.
api/RunCrossCheck.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param string $prefix
64 64
 	 * @return RunCrossCheck
65 65
 	 */
66
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
66
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
67 67
 		$repo = WikibaseRepo::getDefaultInstance();
68 68
 		$externalValidationServices = ExternalValidationServices::getDefaultInstance();
69 69
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$repo->getStatementGuidValidator(),
76 76
 			$externalValidationServices->getCrossCheckInteractor(),
77 77
 			$externalValidationServices->getSerializerFactory(),
78
-			$repo->getApiHelperFactory( RequestContext::getMain() )
78
+			$repo->getApiHelperFactory(RequestContext::getMain())
79 79
 		);
80 80
 	}
81 81
 
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 	 * @param SerializerFactory $serializerFactory
90 90
 	 * @param ApiHelperFactory $apiHelperFactory
91 91
 	 */
92
-	public function __construct( ApiMain $main, $name, $prefix = '', EntityIdParser $entityIdParser,
92
+	public function __construct(ApiMain $main, $name, $prefix = '', EntityIdParser $entityIdParser,
93 93
 								 StatementGuidValidator $statementGuidValidator, CrossCheckInteractor $crossCheckInteractor,
94
-								 SerializerFactory $serializerFactory, ApiHelperFactory $apiHelperFactory ) {
95
-		parent::__construct( $main, $name, $prefix );
94
+								 SerializerFactory $serializerFactory, ApiHelperFactory $apiHelperFactory) {
95
+		parent::__construct($main, $name, $prefix);
96 96
 
97 97
 		$this->entityIdParser = $entityIdParser;
98 98
 		$this->statementGuidValidator = $statementGuidValidator;
99 99
 		$this->crossCheckInteractor = $crossCheckInteractor;
100 100
 		$this->serializerFactory = $serializerFactory;
101
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
102
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
101
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
102
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
103 103
 	}
104 104
 
105 105
 	/**
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 	public function execute() {
109 109
 		$params = $this->extractRequestParams();
110 110
 
111
-		if ( $params['entities'] && $params['claims'] ) {
111
+		if ($params['entities'] && $params['claims']) {
112 112
 			$this->errorReporter->dieError(
113 113
 				'Either provide the ids of entities or ids of claims, that should be cross-checked.',
114 114
 				'param-invalid'
115 115
 			);
116
-		} elseif ( $params['entities'] ) {
117
-			$entityIds = $this->parseEntityIds( $params['entities'] );
118
-			if ( $params['properties'] ) {
119
-				$propertyIds = $this->parseEntityIds( $params['properties'] );
120
-				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties( $entityIds, $propertyIds );
116
+		} elseif ($params['entities']) {
117
+			$entityIds = $this->parseEntityIds($params['entities']);
118
+			if ($params['properties']) {
119
+				$propertyIds = $this->parseEntityIds($params['properties']);
120
+				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIdWithProperties($entityIds, $propertyIds);
121 121
 			} else {
122
-				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds( $entityIds );
122
+				$resultLists = $this->crossCheckInteractor->crossCheckEntitiesByIds($entityIds);
123 123
 			}
124
-		} elseif ( $params['claims'] ) {
124
+		} elseif ($params['claims']) {
125 125
 			$guids = $params['claims'];
126
-			$this->assertAreValidClaimGuids( $guids );
127
-			$resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids( $guids );
126
+			$this->assertAreValidClaimGuids($guids);
127
+			$resultLists = $this->crossCheckInteractor->crossCheckStatementsByGuids($guids);
128 128
 		} else {
129 129
 			$this->errorReporter->dieError(
130 130
 				'Either provide the ids of entities or ids of claims, that should be cross-checked.',
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		}
134 134
 
135 135
 		// Print result lists
136
-		$this->writeResultOutput( $resultLists );
136
+		$this->writeResultOutput($resultLists);
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return EntityId[]
143 143
 	 */
144
-	private function parseEntityIds( array $entityIds ) {
144
+	private function parseEntityIds(array $entityIds) {
145 145
 		return array_map(
146
-			array( $this->entityIdParser, 'parse' ),
146
+			array($this->entityIdParser, 'parse'),
147 147
 			$entityIds
148 148
 		);
149 149
 	}
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	/**
152 152
 	 * @param string[] $guids
153 153
 	 */
154
-	private function assertAreValidClaimGuids( array $guids ) {
155
-		foreach ( $guids as $guid ) {
156
-			if ( $this->statementGuidValidator->validateFormat( $guid ) === false ) {
157
-				$this->errorReporter->dieError( 'Invalid claim guid.', 'invalid-guid' );
154
+	private function assertAreValidClaimGuids(array $guids) {
155
+		foreach ($guids as $guid) {
156
+			if ($this->statementGuidValidator->validateFormat($guid) === false) {
157
+				$this->errorReporter->dieError('Invalid claim guid.', 'invalid-guid');
158 158
 			}
159 159
 		}
160 160
 	}
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return array
168 168
 	 */
169
-	private function writeResultOutput( array $resultLists ) {
169
+	private function writeResultOutput(array $resultLists) {
170 170
 		$serializer = $this->serializerFactory->newCrossCheckResultListSerializer();
171 171
 
172 172
 		$output = array();
173
-		foreach ( $resultLists as $entityId => $resultList ) {
174
-			if ( $resultList ) {
175
-				$serializedResultList = $serializer->serialize( $resultList );
173
+		foreach ($resultLists as $entityId => $resultList) {
174
+			if ($resultList) {
175
+				$serializedResultList = $serializer->serialize($resultList);
176 176
 
177 177
 				$output[$entityId] = $serializedResultList;
178 178
 			} else {
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 			}
183 183
 		}
184 184
 
185
-		$this->getResult()->setIndexedTagName( $output, 'entity' );
186
-		$this->getResult()->setArrayType( $output, 'kvp', 'id' );
187
-		$this->getResult()->addValue( null, 'results', $output );
188
-		$this->resultBuilder->markSuccess( 1 );
185
+		$this->getResult()->setIndexedTagName($output, 'entity');
186
+		$this->getResult()->setArrayType($output, 'kvp', 'id');
187
+		$this->getResult()->addValue(null, 'results', $output);
188
+		$this->resultBuilder->markSuccess(1);
189 189
 	}
190 190
 
191 191
 	/**
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/DataValueComparer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return bool
20 20
 	 */
21
-	public function canCompare( DataValue $value, DataValue $comparativeValue );
21
+	public function canCompare(DataValue $value, DataValue $comparativeValue);
22 22
 
23 23
 	/**
24 24
 	 * Runs the comparison of two DataValues.
@@ -28,6 +28,6 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @return string One of the ComparisonResult::STATUS_... constants.
30 30
 	 */
31
-	public function compare( DataValue $value, DataValue $comparativeValue );
31
+	public function compare(DataValue $value, DataValue $comparativeValue);
32 32
 
33 33
 }
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/DataValueComparerFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param TermIndex $termIndex
27 27
 	 * @param StringNormalizer $stringNormalizer
28 28
 	 */
29
-	public function __construct( TermIndex $termIndex, StringNormalizer $stringNormalizer ) {
29
+	public function __construct(TermIndex $termIndex, StringNormalizer $stringNormalizer) {
30 30
 		$this->termIndex = $termIndex;
31 31
 		$this->stringNormalizer = $stringNormalizer;
32 32
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return StringComparer
69 69
 	 */
70 70
 	private function newStringComparer() {
71
-		return new StringComparer( $this->stringNormalizer );
71
+		return new StringComparer($this->stringNormalizer);
72 72
 	}
73 73
 
74 74
 	/**
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/DispatchingDataValueComparer.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * @param DataValueComparer[] $dataValueComparers
22 22
 	 */
23
-	public function __construct( array $dataValueComparers = array() ) {
24
-		$this->assertAreDataValueComparer( $dataValueComparers );
23
+	public function __construct(array $dataValueComparers = array()) {
24
+		$this->assertAreDataValueComparer($dataValueComparers);
25 25
 		$this->dataValueComparers = $dataValueComparers;
26 26
 	}
27 27
 
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @throws InvalidArgumentException
32 32
 	 */
33
-	protected function assertAreDataValueComparer( array $dataValueComparers ) {
34
-		foreach ( $dataValueComparers as $dataValueComparer ) {
35
-			if ( !is_object( $dataValueComparer ) || !( $dataValueComparer instanceof DataValueComparer ) ) {
33
+	protected function assertAreDataValueComparer(array $dataValueComparers) {
34
+		foreach ($dataValueComparers as $dataValueComparer) {
35
+			if (!is_object($dataValueComparer) || !($dataValueComparer instanceof DataValueComparer)) {
36 36
 				throw new InvalidArgumentException(
37 37
 					'All $dataValueComparers need to implement the DataValueComparer interface'
38 38
 				);
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return bool
50 50
 	 */
51
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
52
-		foreach ( $this->dataValueComparers as $dataValueComparer ) {
53
-			if ( $dataValueComparer->canCompare( $value, $comparativeValue ) ) {
51
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
52
+		foreach ($this->dataValueComparers as $dataValueComparer) {
53
+			if ($dataValueComparer->canCompare($value, $comparativeValue)) {
54 54
 				return true;
55 55
 			}
56 56
 		}
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 	 * @throws InvalidArgumentException
68 68
 	 * @return string One of the ComparisonResult::STATUS_... constants.
69 69
 	 */
70
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
71
-		foreach ( $this->dataValueComparers as $dataValueComparer ) {
72
-			if ( $dataValueComparer->canCompare( $value, $comparativeValue ) ) {
73
-				return $dataValueComparer->compare( $value, $comparativeValue );
70
+	public function compare(DataValue $value, DataValue $comparativeValue) {
71
+		foreach ($this->dataValueComparers as $dataValueComparer) {
72
+			if ($dataValueComparer->canCompare($value, $comparativeValue)) {
73
+				return $dataValueComparer->compare($value, $comparativeValue);
74 74
 			}
75 75
 		}
76 76
 
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/EntityIdValueComparer.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param TermIndex $termIndex
34 34
 	 * @param StringComparer $stringComparer
35 35
 	 */
36
-	public function __construct( TermIndex $termIndex, StringComparer $stringComparer ) {
36
+	public function __construct(TermIndex $termIndex, StringComparer $stringComparer) {
37 37
 		$this->termIndex = $termIndex;
38 38
 		$this->stringComparer = $stringComparer;
39 39
 	}
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return string|null One of the ComparisonResult::STATUS_... constants.
48 48
 	 */
49
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
50
-		Assert::parameterType( 'Wikibase\DataModel\Entity\EntityIdValue', $value, '$value' );
51
-		Assert::parameterType( 'DataValues\MonolingualTextValue', $comparativeValue, '$comparativeValue' );
49
+	public function compare(DataValue $value, DataValue $comparativeValue) {
50
+		Assert::parameterType('Wikibase\DataModel\Entity\EntityIdValue', $value, '$value');
51
+		Assert::parameterType('DataValues\MonolingualTextValue', $comparativeValue, '$comparativeValue');
52 52
 
53 53
 		/**
54 54
 		 * @var EntityIdValue $value
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 
58 58
 		$entityId = $value->getEntityId();
59 59
 		$language = $comparativeValue->getLanguageCode();
60
-		$terms = $this->getTerms( $entityId, $language );
60
+		$terms = $this->getTerms($entityId, $language);
61 61
 
62
-		if ( $terms ) {
63
-			return $this->stringComparer->compareWithArray( $comparativeValue->getText(), $terms );
62
+		if ($terms) {
63
+			return $this->stringComparer->compareWithArray($comparativeValue->getText(), $terms);
64 64
 		}
65 65
 
66 66
 		return null;
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return array
76 76
 	 */
77
-	private function getTerms( EntityId $entityId, $language ) {
77
+	private function getTerms(EntityId $entityId, $language) {
78 78
 		$terms = $this->termIndex->getTermsOfEntity(
79 79
 			$entityId,
80 80
 			array(
81 81
 				TermIndexEntry::TYPE_LABEL,
82 82
 				TermIndexEntry::TYPE_ALIAS
83 83
 			),
84
-			array( $language )
84
+			array($language)
85 85
 		);
86 86
 
87 87
 		return array_map(
88
-			function( TermIndexEntry $term ) {
88
+			function(TermIndexEntry $term) {
89 89
 				return $term->getText();
90 90
 			},
91 91
 			$terms
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @param DataValue $comparativeValue
100 100
 	 * @return bool
101 101
 	 */
102
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
102
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
103 103
 		return $value instanceof EntityIdValue && $comparativeValue instanceof MonolingualTextValue;
104 104
 	}
105 105
 
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/GlobeCoordinateValueComparer.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * @throws InvalidArgumentException
24 24
 	 * @return string One of the ComparisonResult::STATUS_... constants.
25 25
 	 */
26
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
27
-		if ( !$this->canCompare( $value, $comparativeValue ) ) {
28
-			throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' );
26
+	public function compare(DataValue $value, DataValue $comparativeValue) {
27
+		if (!$this->canCompare($value, $comparativeValue)) {
28
+			throw new InvalidArgumentException('Given values can not be compared using this comparer.');
29 29
 		}
30 30
 
31 31
 		/**
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 		$extLat = $comparativeValue->getLatitude();
40 40
 		$extLong = $comparativeValue->getLongitude();
41 41
 
42
-		$diffLat = abs( $locLat - $extLat );
43
-		$diffLong = abs( $locLong - $extLong );
44
-		if ( ( $diffLat <= $precision ) && ( $diffLong <= $precision ) ) {
42
+		$diffLat = abs($locLat - $extLat);
43
+		$diffLong = abs($locLong - $extLong);
44
+		if (($diffLat <= $precision) && ($diffLong <= $precision)) {
45 45
 			return ComparisonResult::STATUS_MATCH;
46 46
 		}
47 47
 
48 48
 		$daumen = $precision;
49
-		if ( ( $diffLat <= pi() * $daumen ) && ( $diffLong <= pi() * $daumen ) ) {
49
+		if (($diffLat <= pi() * $daumen) && ($diffLong <= pi() * $daumen)) {
50 50
 			return ComparisonResult::STATUS_PARTIAL_MATCH;
51 51
 		}
52 52
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param DataValue $comparativeValue
61 61
 	 * @return bool
62 62
 	 */
63
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
63
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
64 64
 		return $value instanceof GlobeCoordinateValue && $comparativeValue instanceof GlobeCoordinateValue;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.