Completed
Push — master ( 3de400...759c86 )
by
unknown
01:51
created
includes/UpdateExternalData/CsvImportSettings.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@
 block discarded – undo
43 43
 	 * @param int $batchSize
44 44
 	 * @param bool $quiet
45 45
 	 */
46
-	public function __construct( $externalValuesFilePath, $dumpInformationFilePath, $batchSize, $quiet = false ) {
47
-		Assert::parameterType( 'string', $externalValuesFilePath, '$externalValuesFilePath' );
48
-		Assert::parameterType( 'string', $dumpInformationFilePath, '$dumpInformationFilePath' );
49
-		Assert::parameterType( 'integer', $batchSize, '$batchSize' );
50
-		Assert::parameterType( 'boolean', $quiet, '$quiet' );
46
+	public function __construct($externalValuesFilePath, $dumpInformationFilePath, $batchSize, $quiet = false) {
47
+		Assert::parameterType('string', $externalValuesFilePath, '$externalValuesFilePath');
48
+		Assert::parameterType('string', $dumpInformationFilePath, '$dumpInformationFilePath');
49
+		Assert::parameterType('integer', $batchSize, '$batchSize');
50
+		Assert::parameterType('boolean', $quiet, '$quiet');
51 51
 
52 52
 		$this->externalValuesFilePath = $externalValuesFilePath;
53 53
 		$this->dumpInformationFilePath = $dumpInformationFilePath;
Please login to merge, or discard this patch.
WikibaseQualityExternalValidationHooks.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 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 ) {
19
-		$paths[] = __DIR__ . '/tests/phpunit';
18
+	public static function onUnitTestsList(&$paths) {
19
+		$paths[] = __DIR__.'/tests/phpunit';
20 20
 		return true;
21 21
 	}
22 22
 
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/TimeValueComparer.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 * @throws InvalidArgumentException
31 31
 	 * @return string One of the ComparisonResult::STATUS_... constants.
32 32
 	 */
33
-	public function compare( DataValue $value, DataValue $comparativeValue ) {
34
-		if ( !$this->canCompare( $value, $comparativeValue ) ) {
35
-			throw new InvalidArgumentException( 'Given values can not be compared using this comparer.' );
33
+	public function compare(DataValue $value, DataValue $comparativeValue) {
34
+		if (!$this->canCompare($value, $comparativeValue)) {
35
+			throw new InvalidArgumentException('Given values can not be compared using this comparer.');
36 36
 		}
37 37
 
38 38
 		/**
@@ -42,38 +42,38 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$result = ComparisonResult::STATUS_MISMATCH;
44 44
 
45
-		if ( !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches )
46
-			|| !preg_match( '/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches )
45
+		if (!preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $value->getTime(), $localMatches)
46
+			|| !preg_match('/^([-+]?)(\d*)((\d{4}\b).*)/', $comparativeValue->getTime(), $externalMatches)
47 47
 		) {
48 48
 			return ComparisonResult::STATUS_MISMATCH;
49 49
 		}
50
-		list( , $localSign, $localYearHigh, $localMwTime, $localYearLow ) = $localMatches;
51
-		list( , $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow ) = $externalMatches;
52
-		if ( $localSign !== $externalSign && ( $localYearHigh . $localYearLow !== '0000'
53
-				|| $externalYearHigh . $externalYearLow !== '0000' )
50
+		list(, $localSign, $localYearHigh, $localMwTime, $localYearLow) = $localMatches;
51
+		list(, $externalSign, $externalYearHigh, $externalMwTime, $externalYearLow) = $externalMatches;
52
+		if ($localSign !== $externalSign && ($localYearHigh.$localYearLow !== '0000'
53
+				|| $externalYearHigh.$externalYearLow !== '0000')
54 54
 		) {
55 55
 			return ComparisonResult::STATUS_MISMATCH;
56 56
 		}
57 57
 
58 58
 		try {
59
-			$localTimestamp = new MWTimestamp( $localMwTime );
60
-			$externalTimestamp = new MWTimestamp( $externalMwTime );
61
-			$diff = $localTimestamp->diff( $externalTimestamp );
62
-			$diff->y += abs( $localYearHigh - $externalYearHigh ) * 10000;
59
+			$localTimestamp = new MWTimestamp($localMwTime);
60
+			$externalTimestamp = new MWTimestamp($externalMwTime);
61
+			$diff = $localTimestamp->diff($externalTimestamp);
62
+			$diff->y += abs($localYearHigh - $externalYearHigh) * 10000;
63 63
 
64
-			if ( $value->getPrecision() === $comparativeValue->getPrecision()
65
-				&& $this->resultOfDiffWithPrecision( $diff, $value->getPrecision() )
64
+			if ($value->getPrecision() === $comparativeValue->getPrecision()
65
+				&& $this->resultOfDiffWithPrecision($diff, $value->getPrecision())
66 66
 			) {
67 67
 				$result = ComparisonResult::STATUS_MATCH;
68 68
 			} elseif (
69 69
 				$this->resultOfDiffWithPrecision(
70 70
 					$diff,
71
-					min( $value->getPrecision(), $comparativeValue->getPrecision() )
71
+					min($value->getPrecision(), $comparativeValue->getPrecision())
72 72
 				)
73 73
 			) {
74 74
 				$result = ComparisonResult::STATUS_PARTIAL_MATCH;
75 75
 			}
76
-		} catch ( TimestampException $ex ) {
76
+		} catch (TimestampException $ex) {
77 77
 		}
78 78
 
79 79
 		return $result;
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return bool
89 89
 	 */
90
-	private function resultOfDiffWithPrecision( DateInterval $diff, $precision ) {
90
+	private function resultOfDiffWithPrecision(DateInterval $diff, $precision) {
91 91
 		$result = true;
92 92
 
93
-		switch ( $precision ) {
93
+		switch ($precision) {
94 94
 			case TimeValue::PRECISION_SECOND:
95 95
 				$result = $diff->s === 0;
96 96
 				// Fall through with no break/return. This is critical for this algorithm.
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return ValueParser
136 136
 	 */
137
-	protected function getExternalValueParser( DumpMetaInformation $dumpMetaInformation ) {
137
+	protected function getExternalValueParser(DumpMetaInformation $dumpMetaInformation) {
138 138
 		$parserOptions = new ParserOptions();
139
-		$parserOptions->setOption( ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode() );
140
-		$timeParserFactory = new TimeParserFactory( $parserOptions );
139
+		$parserOptions->setOption(ValueParser::OPT_LANG, $dumpMetaInformation->getLanguageCode());
140
+		$timeParserFactory = new TimeParserFactory($parserOptions);
141 141
 
142 142
 		return $timeParserFactory->getTimeParser();
143 143
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return bool
152 152
 	 */
153
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
153
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
154 154
 		return $value instanceof TimeValue && $comparativeValue instanceof TimeValue;
155 155
 	}
156 156
 
Please login to merge, or discard this patch.
includes/DumpMetaInformation/DumpMetaInformationLookup.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @return DumpMetaInformation[]
21 21
 	 * @throws \InvalidArgumentException
22 22
 	 */
23
-	public function getWithIds( array $dumpIds );
23
+	public function getWithIds(array $dumpIds);
24 24
 
25 25
 	/**
26 26
 	 * Gets DumpMetaInformation for specific identifier properties from database
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return DumpMetaInformation[]
32 32
 	 */
33
-	public function getWithIdentifierProperties( array $identifierPropertyIds );
33
+	public function getWithIdentifierProperties(array $identifierPropertyIds);
34 34
 
35 35
 	/**
36 36
 	 * Gets all DumpMetaInformation from database
Please login to merge, or discard this patch.
maintenance/UpdateExternalData.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 use WikibaseQuality\ExternalValidation\UpdateExternalData\CsvImportSettings;
8 8
 use WikibaseQuality\ExternalValidation\UpdateExternalData\ExternalDataImporter;
9 9
 
10
-$basePath = getenv( 'MW_INSTALL_PATH' ) !== false
11
-	? getenv( 'MW_INSTALL_PATH' )
12
-	: __DIR__ . '/../../..';
13
-require_once $basePath . '/maintenance/Maintenance.php';
10
+$basePath = getenv('MW_INSTALL_PATH') !== false
11
+	? getenv('MW_INSTALL_PATH')
12
+	: __DIR__.'/../../..';
13
+require_once $basePath.'/maintenance/Maintenance.php';
14 14
 
15 15
 /**
16 16
  * Maintenance script that evokes updates of wbqev_external_data, wbqev_dump_information, wbqev_identifier_properties
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 	public function __construct() {
26 26
 		parent::__construct();
27 27
 
28
-		$this->addDescription( 'Imports external entities from given CSV files into the local '
29
-			. 'database. CSV files can be generated using the DumpConverter.' );
30
-		$this->addOption( 'external-values-file', 'CSV file containing external values for import.', true, true );
31
-		$this->addOption( 'dump-information-file', 'CSV file containing dump meta information for import.', true, true );
32
-		$this->setBatchSize( 1000 );
28
+		$this->addDescription('Imports external entities from given CSV files into the local '
29
+			. 'database. CSV files can be generated using the DumpConverter.');
30
+		$this->addOption('external-values-file', 'CSV file containing external values for import.', true, true);
31
+		$this->addOption('dump-information-file', 'CSV file containing dump meta information for import.', true, true);
32
+		$this->setBatchSize(1000);
33 33
 	}
34 34
 
35 35
 	public function execute() {
36 36
 		$context = new CsvImportSettings(
37
-			$this->getOption( 'external-values-file' ),
38
-			$this->getOption( 'dump-information-file' ),
37
+			$this->getOption('external-values-file'),
38
+			$this->getOption('dump-information-file'),
39 39
 			$this->mBatchSize,
40 40
 			$this->isQuiet()
41 41
 		);
Please login to merge, or discard this patch.
includes/CrossCheck/Comparer/QuantityValueComparer.php 1 patch
Spacing   +6 added lines, -6 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
 		/**
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 		 * @var QuantityValue $comparativeValue
34 34
 		 */
35 35
 
36
-		if ( $comparativeValue->getLowerBound()->compare( $value->getUpperBound() ) <= 0 &&
37
-			$comparativeValue->getUpperBound()->compare( $value->getLowerBound() ) >= 0
36
+		if ($comparativeValue->getLowerBound()->compare($value->getUpperBound()) <= 0 &&
37
+			$comparativeValue->getUpperBound()->compare($value->getLowerBound()) >= 0
38 38
 		) {
39 39
 			return ComparisonResult::STATUS_MATCH;
40 40
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return bool
52 52
 	 */
53
-	public function canCompare( DataValue $value, DataValue $comparativeValue ) {
53
+	public function canCompare(DataValue $value, DataValue $comparativeValue) {
54 54
 		return $value instanceof QuantityValue && $comparativeValue instanceof QuantityValue;
55 55
 	}
56 56
 
Please login to merge, or discard this patch.
includes/CrossCheck/ReferenceChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 		$externalId,
41 41
 		DumpMetaInformation $dumpMetaInformation
42 42
 	) {
43
-		Assert::parameterType( 'string', $externalId, '$externalId' );
43
+		Assert::parameterType('string', $externalId, '$externalId');
44 44
 
45
-		if ( count( $statement->getReferences() ) === 0 ) {
45
+		if (count($statement->getReferences()) === 0) {
46 46
 			$status = ReferenceResult::STATUS_REFERENCES_MISSING;
47 47
 		} else {
48 48
 			$status = ReferenceResult::STATUS_REFERENCES_STATED;
49 49
 		}
50 50
 
51
-		$externalReference = $this->buildReference( $identifierPropertyId, $externalId, $dumpMetaInformation );
52
-		return new ReferenceResult( $status, $externalReference );
51
+		$externalReference = $this->buildReference($identifierPropertyId, $externalId, $dumpMetaInformation);
52
+		return new ReferenceResult($status, $externalReference);
53 53
 	}
54 54
 
55 55
 	/**
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
 	 * @param DumpMetaInformation $dumpMetaInformation
61 61
 	 * @return Reference
62 62
 	 */
63
-	private function buildReference( PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation ) {
63
+	private function buildReference(PropertyId $identifierPropertyId, $externalId, DumpMetaInformation $dumpMetaInformation) {
64 64
 		global $wgWBQEVStatedInPID;
65 65
 
66 66
 		$sourceItemId = $dumpMetaInformation->getSourceItemId();
67 67
 		$statedInAuthoritySnak = new PropertyValueSnak(
68
-			new PropertyId( $wgWBQEVStatedInPID ),
69
-			new EntityIdValue( $sourceItemId )
68
+			new PropertyId($wgWBQEVStatedInPID),
69
+			new EntityIdValue($sourceItemId)
70 70
 		);
71 71
 		$authorityWithExternalIdSnak = new PropertyValueSnak(
72 72
 			$identifierPropertyId,
73
-			new StringValue( $externalId )
73
+			new StringValue($externalId)
74 74
 		);
75 75
 
76 76
 		return new Reference(
Please login to merge, or discard this patch.
includes/CrossCheck/ValueParser/ComparativeValueParser.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		ValueParserFactory $comparativeValueParserFactory,
39 39
 		$languageCode
40 40
 	) {
41
-		Assert::parameterType( 'string', $languageCode, '$languageCode' );
41
+		Assert::parameterType('string', $languageCode, '$languageCode');
42 42
 
43 43
 		$this->comparativeValueParserFactory = $comparativeValueParserFactory;
44 44
 		$this->languageCode = $languageCode;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return DataValue
54 54
 	 */
55
-	public function parse( $value, $propertyType ) {
56
-		Assert::parameterType( 'string', $value, '$value' );
57
-		Assert::parameterType( 'string', $propertyType, '$propertyType' );
55
+	public function parse($value, $propertyType) {
56
+		Assert::parameterType('string', $value, '$value');
57
+		Assert::parameterType('string', $propertyType, '$propertyType');
58 58
 
59
-		return $this->getValueParser( $propertyType )->parse( $value );
59
+		return $this->getValueParser($propertyType)->parse($value);
60 60
 	}
61 61
 
62 62
 	/**
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return ValueParser
66 66
 	 */
67
-	private function getValueParser( $type ) {
68
-		if ( !array_key_exists( $type, $this->valueParsers ) ) {
67
+	private function getValueParser($type) {
68
+		if (!array_key_exists($type, $this->valueParsers)) {
69 69
 			$parserOptions = $this->getParserOptions();
70 70
 			$this->valueParsers[$type] = $this->comparativeValueParserFactory->newParser(
71 71
 				$type,
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	private function getParserOptions() {
83 83
 		$options = new ParserOptions();
84
-		$options->setOption( 'valuelang', $this->languageCode );
85
-		$options->setOption( ValueParser::OPT_LANG, $this->languageCode );
84
+		$options->setOption('valuelang', $this->languageCode);
85
+		$options->setOption(ValueParser::OPT_LANG, $this->languageCode);
86 86
 
87 87
 		return $options;
88 88
 	}
Please login to merge, or discard this patch.
WikibaseQualityExternalValidation.alias.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,6 +10,6 @@
 block discarded – undo
10 10
 
11 11
 /** English (English) */
12 12
 $specialPageAliases['en'] = [
13
-	'CrossCheck' => [ 'CrossCheck', 'Cross Check' ],
14
-	'ExternalDatabases' => [ 'ExternalDatabases', 'ExternalDbs', 'External Dbs' ],
13
+	'CrossCheck' => ['CrossCheck', 'Cross Check'],
14
+	'ExternalDatabases' => ['ExternalDatabases', 'ExternalDbs', 'External Dbs'],
15 15
 ];
Please login to merge, or discard this patch.