Completed
Push — master ( 3cf82e...be95cc )
by
unknown
20s
created
src/WikibaseServices.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,35 +20,35 @@
 block discarded – undo
20 20
 	public const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup';
21 21
 	public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache';
22 22
 
23
-	private static function getService( ?MediaWikiServices $services, $name ) {
24
-		if ( $services === null ) {
23
+	private static function getService(?MediaWikiServices $services, $name) {
24
+		if ($services === null) {
25 25
 			$services = MediaWikiServices::getInstance();
26 26
 		}
27
-		return $services->getService( $name );
27
+		return $services->getService($name);
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * @param MediaWikiServices|null $services
32 32
 	 * @return EntityLookup
33 33
 	 */
34
-	public static function getEntityLookup( MediaWikiServices $services = null ) {
35
-		return self::getService( $services, self::ENTITY_LOOKUP );
34
+	public static function getEntityLookup(MediaWikiServices $services = null) {
35
+		return self::getService($services, self::ENTITY_LOOKUP);
36 36
 	}
37 37
 
38 38
 	/**
39 39
 	 * @param MediaWikiServices|null $services
40 40
 	 * @return PropertyDataTypeLookup
41 41
 	 */
42
-	public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) {
43
-		return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP );
42
+	public static function getPropertyDataTypeLookup(MediaWikiServices $services = null) {
43
+		return self::getService($services, self::PROPERTY_DATA_TYPE_LOOKUP);
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @param MediaWikiServices|null $services
48 48
 	 * @return EntityLookup
49 49
 	 */
50
-	public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ) {
51
-		return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE );
50
+	public static function getEntityLookupWithoutCache(MediaWikiServices $services = null) {
51
+		return self::getService($services, self::ENTITY_LOOKUP_WITHOUT_CACHE);
52 52
 	}
53 53
 
54 54
 }
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 use Wikimedia\Rdbms\ILBFactory;
12 12
 
13 13
 // @codeCoverageIgnoreStart
14
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
15
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
14
+$basePath = getenv("MW_INSTALL_PATH") !== false
15
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
16 16
 
17
-require_once $basePath . "/maintenance/Maintenance.php";
17
+require_once $basePath."/maintenance/Maintenance.php";
18 18
 // @codeCoverageIgnoreEnd
19 19
 
20 20
 /**
@@ -46,57 +46,57 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public function __construct() {
48 48
 		parent::__construct();
49
-		$this->newUpdateConstraintsTableJob = static function ( $propertyIdSerialization ) {
49
+		$this->newUpdateConstraintsTableJob = static function($propertyIdSerialization) {
50 50
 			return UpdateConstraintsTableJob::newFromGlobalState(
51 51
 				Title::newMainPage(),
52
-				[ 'propertyId' => $propertyIdSerialization ]
52
+				['propertyId' => $propertyIdSerialization]
53 53
 			);
54 54
 		};
55 55
 
56
-		$this->addDescription( 'Imports property constraints from statements on properties' );
57
-		$this->requireExtension( 'WikibaseQualityConstraints' );
58
-		$this->setBatchSize( 10 );
56
+		$this->addDescription('Imports property constraints from statements on properties');
57
+		$this->requireExtension('WikibaseQualityConstraints');
58
+		$this->setBatchSize(10);
59 59
 
60 60
 		// Wikibase classes are not yet loaded, so setup services in a callback run in execute
61 61
 		// that can be overridden in tests.
62
-		$this->setupServices = function () {
62
+		$this->setupServices = function() {
63 63
 			$services = MediaWikiServices::getInstance();
64
-			$this->propertyInfoLookup = WikibaseRepo::getStore( $services )->getPropertyInfoLookup();
64
+			$this->propertyInfoLookup = WikibaseRepo::getStore($services)->getPropertyInfoLookup();
65 65
 			$this->lbFactory = $services->getDBLoadBalancerFactory();
66 66
 		};
67 67
 	}
68 68
 
69 69
 	public function execute() {
70
-		( $this->setupServices )();
71
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
72
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
70
+		($this->setupServices)();
71
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
72
+			$this->error('Constraint statements are not enabled. Aborting.');
73 73
 			return;
74 74
 		}
75 75
 
76 76
 		$propertyInfos = $this->propertyInfoLookup->getAllPropertyInfo();
77
-		$propertyIds = array_keys( $propertyInfos );
77
+		$propertyIds = array_keys($propertyInfos);
78 78
 
79
-		foreach ( array_chunk( $propertyIds, $this->getBatchSize() ) as $propertyIdsChunk ) {
80
-			foreach ( $propertyIdsChunk as $propertyIdSerialization ) {
81
-				$this->output( sprintf(
79
+		foreach (array_chunk($propertyIds, $this->getBatchSize()) as $propertyIdsChunk) {
80
+			foreach ($propertyIdsChunk as $propertyIdSerialization) {
81
+				$this->output(sprintf(
82 82
 					'Importing constraint statements for % 6s... ',
83 83
 					$propertyIdSerialization ),
84 84
 					$propertyIdSerialization
85 85
 				);
86
-				$startTime = microtime( true );
87
-				$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
86
+				$startTime = microtime(true);
87
+				$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
88 88
 				$job->run();
89
-				$endTime = microtime( true );
90
-				$millis = ( $endTime - $startTime ) * 1000;
91
-				$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
89
+				$endTime = microtime(true);
90
+				$millis = ($endTime - $startTime) * 1000;
91
+				$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
92 92
 			}
93 93
 
94
-			$this->output( 'Waiting for replication... ', 'waitForReplication' );
95
-			$startTime = microtime( true );
94
+			$this->output('Waiting for replication... ', 'waitForReplication');
95
+			$startTime = microtime(true);
96 96
 			$this->lbFactory->waitForReplication();
97
-			$endTime = microtime( true );
98
-			$millis = ( $endTime - $startTime ) * 1000;
99
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), 'waitForReplication' );
97
+			$endTime = microtime(true);
98
+			$millis = ($endTime - $startTime) * 1000;
99
+			$this->output(sprintf('done in % 6.2f ms.', $millis), 'waitForReplication');
100 100
 		}
101 101
 	}
102 102
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ValueCountCheckerHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 	 * @param PropertyId $propertyId
21 21
 	 * @return int
22 22
 	 */
23
-	public function getPropertyCount( array $snaks, PropertyId $propertyId ) {
24
-		return count( array_filter(
23
+	public function getPropertyCount(array $snaks, PropertyId $propertyId) {
24
+		return count(array_filter(
25 25
 			$snaks,
26
-			static function ( Snak $snak ) use ( $propertyId ) {
27
-				return $snak->getPropertyId()->equals( $propertyId );
26
+			static function(Snak $snak) use ($propertyId) {
27
+				return $snak->getPropertyId()->equals($propertyId);
28 28
 			}
29
-		) );
29
+		));
30 30
 	}
31 31
 
32 32
 }
Please login to merge, or discard this patch.
src/ServiceWiring-Wikibase.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@
 block discarded – undo
8 8
 use Wikibase\Repo\WikibaseRepo;
9 9
 
10 10
 return [
11
-	WikibaseServices::ENTITY_LOOKUP => static function ( MediaWikiServices $services ) {
11
+	WikibaseServices::ENTITY_LOOKUP => static function(MediaWikiServices $services) {
12 12
 		return new ExceptionIgnoringEntityLookup(
13
-			WikibaseRepo::getEntityLookup( $services )
13
+			WikibaseRepo::getEntityLookup($services)
14 14
 		);
15 15
 	},
16 16
 
17
-	WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => static function ( MediaWikiServices $services ) {
17
+	WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => static function(MediaWikiServices $services) {
18 18
 		return new ExceptionIgnoringEntityLookup(
19
-			WikibaseRepo::getStore( $services )
20
-				->getEntityLookup( Store::LOOKUP_CACHING_RETRIEVE_ONLY )
19
+			WikibaseRepo::getStore($services)
20
+				->getEntityLookup(Store::LOOKUP_CACHING_RETRIEVE_ONLY)
21 21
 		);
22 22
 	},
23 23
 
24
-	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => static function ( MediaWikiServices $services ) {
25
-		return WikibaseRepo::getPropertyDataTypeLookup( $services );
24
+	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => static function(MediaWikiServices $services) {
25
+		return WikibaseRepo::getPropertyDataTypeLookup($services);
26 26
 	},
27 27
 ];
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/PropertyScopeChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
55 55
 	}
56 56
 
57
-	public function checkConstraint( Context $context, Constraint $constraint ) {
57
+	public function checkConstraint(Context $context, Constraint $constraint) {
58 58
 		$constraintParameters = $constraint->getConstraintParameters();
59 59
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			$constraintTypeItemId
64 64
 		);
65 65
 
66
-		if ( in_array( $context->getType(), $allowedContextTypes ) ) {
66
+		if (in_array($context->getType(), $allowedContextTypes)) {
67 67
 			return new CheckResult(
68 68
 				$context->getCursor(),
69 69
 				$constraint,
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 				$constraint,
77 77
 				[],
78 78
 				CheckResult::STATUS_VIOLATION,
79
-				( new ViolationMessage( 'wbqc-violation-message-property-scope' ) )
80
-					->withEntityId( $context->getSnak()->getPropertyId() )
81
-					->withPropertyScope( $context->getType() )
82
-					->withPropertyScopeList( $allowedContextTypes )
79
+				(new ViolationMessage('wbqc-violation-message-property-scope'))
80
+					->withEntityId($context->getSnak()->getPropertyId())
81
+					->withPropertyScope($context->getType())
82
+					->withPropertyScopeList($allowedContextTypes)
83 83
 			);
84 84
 		}
85 85
 	}
86 86
 
87
-	public function checkConstraintParameters( Constraint $constraint ) {
87
+	public function checkConstraintParameters(Constraint $constraint) {
88 88
 		$constraintParameters = $constraint->getConstraintParameters();
89 89
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
90 90
 		$exceptions = [];
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				$constraintParameters,
94 94
 				$constraintTypeItemId
95 95
 			);
96
-		} catch ( ConstraintParameterException $e ) {
96
+		} catch (ConstraintParameterException $e) {
97 97
 			$exceptions[] = $e;
98 98
 		}
99 99
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/IntegerChecker.php 1 patch
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -46,23 +46,22 @@  discard block
 block discarded – undo
46 46
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
47 47
 	}
48 48
 
49
-	public function checkConstraint( Context $context, Constraint $constraint ) {
49
+	public function checkConstraint(Context $context, Constraint $constraint) {
50 50
 		$snak = $context->getSnak();
51 51
 
52
-		if ( !$snak instanceof PropertyValueSnak ) {
52
+		if (!$snak instanceof PropertyValueSnak) {
53 53
 			// nothing to check
54
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
54
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
55 55
 		}
56 56
 
57
-		$violationMessage = $this->checkSnak( $snak );
57
+		$violationMessage = $this->checkSnak($snak);
58 58
 
59 59
 		return new CheckResult(
60 60
 			$context,
61 61
 			$constraint,
62 62
 			[],
63 63
 			$violationMessage === null ?
64
-				CheckResult::STATUS_COMPLIANCE :
65
-				CheckResult::STATUS_VIOLATION,
64
+				CheckResult::STATUS_COMPLIANCE : CheckResult::STATUS_VIOLATION,
66 65
 			$violationMessage
67 66
 		);
68 67
 	}
@@ -71,23 +70,23 @@  discard block
 block discarded – undo
71 70
 	 * @param PropertyValueSnak $snak
72 71
 	 * @return ViolationMessage|null
73 72
 	 */
74
-	public function checkSnak( PropertyValueSnak $snak ) {
73
+	public function checkSnak(PropertyValueSnak $snak) {
75 74
 		$dataValue = $snak->getDataValue();
76 75
 
77
-		if ( $dataValue instanceof DecimalValue ) {
78
-			if ( !$this->isInteger( $dataValue ) ) {
79
-				return $this->getViolationMessage( 'wbqc-violation-message-integer', $snak );
76
+		if ($dataValue instanceof DecimalValue) {
77
+			if (!$this->isInteger($dataValue)) {
78
+				return $this->getViolationMessage('wbqc-violation-message-integer', $snak);
80 79
 			}
81
-		} elseif ( $dataValue instanceof UnboundedQuantityValue ) {
82
-			if ( !$this->isInteger( $dataValue->getAmount() ) ) {
83
-				return $this->getViolationMessage( 'wbqc-violation-message-integer', $snak );
80
+		} elseif ($dataValue instanceof UnboundedQuantityValue) {
81
+			if (!$this->isInteger($dataValue->getAmount())) {
82
+				return $this->getViolationMessage('wbqc-violation-message-integer', $snak);
84 83
 			} elseif (
85 84
 				$dataValue instanceof QuantityValue && (
86
-					!$this->isInteger( $dataValue->getLowerBound() ) ||
87
-					!$this->isInteger( $dataValue->getUpperBound() )
85
+					!$this->isInteger($dataValue->getLowerBound()) ||
86
+					!$this->isInteger($dataValue->getUpperBound())
88 87
 				)
89 88
 			) {
90
-				return $this->getViolationMessage( 'wbqc-violation-message-integer-bounds', $snak );
89
+				return $this->getViolationMessage('wbqc-violation-message-integer-bounds', $snak);
91 90
 			}
92 91
 		}
93 92
 
@@ -98,7 +97,7 @@  discard block
 block discarded – undo
98 97
 	 * @param DecimalValue $decimalValue
99 98
 	 * @return bool
100 99
 	 */
101
-	private function isInteger( DecimalValue $decimalValue ) {
100
+	private function isInteger(DecimalValue $decimalValue) {
102 101
 		return $decimalValue->getTrimmed()->getFractionalPart() === '';
103 102
 	}
104 103
 
@@ -107,13 +106,13 @@  discard block
 block discarded – undo
107 106
 	 * @param PropertyValueSnak $snak
108 107
 	 * @return ViolationMessage
109 108
 	 */
110
-	private function getViolationMessage( $messageKey, PropertyValueSnak $snak ) {
111
-		return ( new ViolationMessage( $messageKey ) )
112
-			->withEntityId( $snak->getPropertyId(), Role::CONSTRAINT_PROPERTY )
113
-			->withDataValue( $snak->getDataValue() );
109
+	private function getViolationMessage($messageKey, PropertyValueSnak $snak) {
110
+		return (new ViolationMessage($messageKey))
111
+			->withEntityId($snak->getPropertyId(), Role::CONSTRAINT_PROPERTY)
112
+			->withDataValue($snak->getDataValue());
114 113
 	}
115 114
 
116
-	public function checkConstraintParameters( Constraint $constraint ) {
115
+	public function checkConstraintParameters(Constraint $constraint) {
117 116
 		// no parameters
118 117
 		return [];
119 118
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ReferenceChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@
 block discarded – undo
41 41
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
42 42
 	}
43 43
 
44
-	public function checkConstraint( Context $context, Constraint $constraint ) {
45
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
46
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
44
+	public function checkConstraint(Context $context, Constraint $constraint) {
45
+		if ($context->getType() === Context::TYPE_REFERENCE) {
46
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
47 47
 		} else {
48
-			$message = new ViolationMessage( 'wbqc-violation-message-reference' );
49
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
48
+			$message = new ViolationMessage('wbqc-violation-message-reference');
49
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
50 50
 		}
51 51
 	}
52 52
 
53
-	public function checkConstraintParameters( Constraint $constraint ) {
53
+	public function checkConstraintParameters(Constraint $constraint) {
54 54
 		// no parameters
55 55
 		return [];
56 56
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/NoBoundsChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
45 45
 	}
46 46
 
47
-	public function checkConstraint( Context $context, Constraint $constraint ) {
47
+	public function checkConstraint(Context $context, Constraint $constraint) {
48 48
 		$snak = $context->getSnak();
49 49
 
50
-		if ( !$snak instanceof PropertyValueSnak ) {
50
+		if (!$snak instanceof PropertyValueSnak) {
51 51
 			// nothing to check
52
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
52
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
53 53
 		}
54 54
 
55
-		if ( $snak->getDataValue() instanceof QuantityValue ) {
56
-			$message = ( new ViolationMessage( 'wbqc-violation-message-noBounds' ) )
57
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY );
55
+		if ($snak->getDataValue() instanceof QuantityValue) {
56
+			$message = (new ViolationMessage('wbqc-violation-message-noBounds'))
57
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY);
58 58
 			return new CheckResult(
59 59
 				$context,
60 60
 				$constraint,
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 			);
65 65
 		}
66 66
 
67
-		return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
67
+		return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
68 68
 	}
69 69
 
70
-	public function checkConstraintParameters( Constraint $constraint ) {
70
+	public function checkConstraintParameters(Constraint $constraint) {
71 71
 		// no parameters
72 72
 		return [];
73 73
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/CitationNeededChecker.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @codeCoverageIgnore This method is purely declarative.
31 31
 	 */
32 32
 	public function getDefaultContextTypes() {
33
-		return [ Context::TYPE_STATEMENT ];
33
+		return [Context::TYPE_STATEMENT];
34 34
 	}
35 35
 
36 36
 	/** @codeCoverageIgnore This method is purely declarative. */
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
39 39
 	}
40 40
 
41
-	public function checkConstraint( Context $context, Constraint $constraint ) {
41
+	public function checkConstraint(Context $context, Constraint $constraint) {
42 42
 		$referenceList = $context->getSnakStatement()->getReferences();
43 43
 
44
-		if ( $referenceList->isEmpty() ) {
45
-			$message = ( new ViolationMessage( 'wbqc-violation-message-citationNeeded' ) )
46
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY );
44
+		if ($referenceList->isEmpty()) {
45
+			$message = (new ViolationMessage('wbqc-violation-message-citationNeeded'))
46
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY);
47 47
 			return new CheckResult(
48 48
 				$context,
49 49
 				$constraint,
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 			);
54 54
 		}
55 55
 
56
-		return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
56
+		return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
57 57
 	}
58 58
 
59
-	public function checkConstraintParameters( Constraint $constraint ) {
59
+	public function checkConstraintParameters(Constraint $constraint) {
60 60
 		// no parameters
61 61
 		return [];
62 62
 	}
Please login to merge, or discard this patch.