Completed
Push — master ( 17f68d...894ce2 )
by
unknown
02:20
created
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
-			function ( Snak $snak ) use ( $propertyId ) {
27
-				return $snak->getPropertyId()->equals( $propertyId );
26
+			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/Api/ResultsCache.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	private $cache;
20 20
 
21 21
 	public static function getDefaultInstance() {
22
-		return new self( MediaWikiServices::getInstance()->getMainWANObjectCache() );
22
+		return new self(MediaWikiServices::getInstance()->getMainWANObjectCache());
23 23
 	}
24 24
 
25
-	public function __construct( WANObjectCache $cache ) {
25
+	public function __construct(WANObjectCache $cache) {
26 26
 		$this->cache = $cache;
27 27
 	}
28 28
 
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @param string|null $languageCode defaults to user language
32 32
 	 * @return string cache key
33 33
 	 */
34
-	public function makeKey( EntityId $entityId, $languageCode = null ) {
34
+	public function makeKey(EntityId $entityId, $languageCode = null) {
35 35
 		global $wgLang, $wgContLang;
36
-		if ( $languageCode === null ) {
36
+		if ($languageCode === null) {
37 37
 			$languageCode = $wgLang->getCode();
38 38
 		}
39
-		if ( !Language::isKnownLanguageTag( $languageCode ) && $languageCode !== 'qqx' ) {
39
+		if (!Language::isKnownLanguageTag($languageCode) && $languageCode !== 'qqx') {
40 40
 			$languageCode = $wgContLang->getCode();
41 41
 		}
42 42
 		return $this->cache->makeKey(
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 * @param float &$asOf
56 56
 	 * @return mixed
57 57
 	 */
58
-	public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null ) {
59
-		return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $asOf );
58
+	public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null) {
59
+		return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $asOf);
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
 	 * @param array $opts
67 67
 	 * @return bool
68 68
 	 */
69
-	public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) {
70
-		return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts );
69
+	public function set(EntityId $key, $value, $ttl = 0, array $opts = []) {
70
+		return $this->cache->set($this->makeKey($key), $value, $ttl, $opts);
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * @param EntityId $key
75 75
 	 * @return bool
76 76
 	 */
77
-	public function delete( EntityId $key ) {
77
+	public function delete(EntityId $key) {
78 78
 		$ok = true;
79
-		$languageCodes = array_keys( Language::fetchLanguageNames( null, 'all' ) );
79
+		$languageCodes = array_keys(Language::fetchLanguageNames(null, 'all'));
80 80
 		$languageCodes[] = 'qqx';
81
-		foreach ( $languageCodes as $languageCode ) {
82
-			$ok = $this->cache->delete( $this->makeKey( $key, $languageCode ) ) && $ok;
81
+		foreach ($languageCodes as $languageCode) {
82
+			$ok = $this->cache->delete($this->makeKey($key, $languageCode)) && $ok;
83 83
 		}
84 84
 		return $ok;
85 85
 	}
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 use Wikibase\Repo\WikibaseRepo;
10 10
 
11 11
 // @codeCoverageIgnoreStart
12
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
13
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
12
+$basePath = getenv("MW_INSTALL_PATH") !== false
13
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
14 14
 
15
-require_once $basePath . "/maintenance/Maintenance.php";
15
+require_once $basePath."/maintenance/Maintenance.php";
16 16
 // @codeCoverageIgnoreEnd
17 17
 
18 18
 /**
@@ -38,31 +38,31 @@  discard block
 block discarded – undo
38 38
 		parent::__construct();
39 39
 		$repo = WikibaseRepo::getDefaultInstance();
40 40
 		$this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup();
41
-		$this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) {
41
+		$this->newUpdateConstraintsTableJob = function($propertyIdSerialization) {
42 42
 			return UpdateConstraintsTableJob::newFromGlobalState(
43 43
 				Title::newMainPage(),
44
-				[ 'propertyId' => $propertyIdSerialization ]
44
+				['propertyId' => $propertyIdSerialization]
45 45
 			);
46 46
 		};
47 47
 
48
-		$this->addDescription( 'Imports property constraints from statements on properties' );
49
-		$this->requireExtension( 'WikibaseQualityConstraints' );
48
+		$this->addDescription('Imports property constraints from statements on properties');
49
+		$this->requireExtension('WikibaseQualityConstraints');
50 50
 	}
51 51
 
52 52
 	public function execute() {
53
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
54
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
53
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
54
+			$this->error('Constraint statements are not enabled. Aborting.');
55 55
 			return;
56 56
 		}
57 57
 
58
-		foreach ( $this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
59
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
60
-			$startTime = microtime( true );
61
-			$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
58
+		foreach ($this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
59
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
60
+			$startTime = microtime(true);
61
+			$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
62 62
 			$job->run();
63
-			$endTime = microtime( true );
64
-			$millis = ( $endTime - $startTime ) * 1000;
65
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
63
+			$endTime = microtime(true);
64
+			$millis = ($endTime - $startTime) * 1000;
65
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
66 66
 		}
67 67
 	}
68 68
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
84 84
 	 * @return CheckResult
85 85
 	 */
86
-	public function checkConstraint( Context $context, Constraint $constraint ) {
87
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
88
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
86
+	public function checkConstraint(Context $context, Constraint $constraint) {
87
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
88
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
89 89
 		}
90
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
91
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
90
+		if ($context->getType() === Context::TYPE_REFERENCE) {
91
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
92 92
 		}
93 93
 
94 94
 		$parameters = [];
95 95
 		$constraintParameters = $constraint->getConstraintParameters();
96 96
 
97
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
98 98
 		$parameters['class'] = array_map(
99
-			function( $id ) {
100
-				return new ItemId( $id );
99
+			function($id) {
100
+				return new ItemId($id);
101 101
 			},
102 102
 			$classes
103 103
 		);
104 104
 
105
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
105
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
106 106
 		$relationIds = [];
107
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
108
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
107
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
108
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
109 109
 		}
110
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
111
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
110
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
111
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
112 112
 		}
113
-		$parameters['relation'] = [ $relation ];
113
+		$parameters['relation'] = [$relation];
114 114
 
115 115
 		$result = $this->typeCheckerHelper->hasClassInRelation(
116 116
 			$context->getEntity()->getStatements(),
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			$classes
119 119
 		);
120 120
 
121
-		if ( $result->getBool() ) {
121
+		if ($result->getBool()) {
122 122
 			$message = null;
123 123
 			$status = CheckResult::STATUS_COMPLIANCE;
124 124
 		} else {
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
 			$status = CheckResult::STATUS_VIOLATION;
133 133
 		}
134 134
 
135
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
136
-			->withMetadata( $result->getMetadata() );
135
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
136
+			->withMetadata($result->getMetadata());
137 137
 	}
138 138
 
139
-	public function checkConstraintParameters( Constraint $constraint ) {
139
+	public function checkConstraintParameters(Constraint $constraint) {
140 140
 		$constraintParameters = $constraint->getConstraintParameters();
141 141
 		$exceptions = [];
142 142
 		try {
143
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
144
-		} catch ( ConstraintParameterException $e ) {
143
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
144
+		} catch (ConstraintParameterException $e) {
145 145
 			$exceptions[] = $e;
146 146
 		}
147 147
 		try {
148
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
149
-		} catch ( ConstraintParameterException $e ) {
148
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
149
+		} catch (ConstraintParameterException $e) {
150 150
 			$exceptions[] = $e;
151 151
 		}
152 152
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/QualifierChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,16 +47,16 @@
 block discarded – undo
47 47
 	 *
48 48
 	 * @return CheckResult
49 49
 	 */
50
-	public function checkConstraint( Context $context, Constraint $constraint ) {
51
-		if ( $context->getType() === Context::TYPE_QUALIFIER ) {
52
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
50
+	public function checkConstraint(Context $context, Constraint $constraint) {
51
+		if ($context->getType() === Context::TYPE_QUALIFIER) {
52
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
53 53
 		} else {
54
-			$message = new ViolationMessage( 'wbqc-violation-message-qualifier' );
55
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
54
+			$message = new ViolationMessage('wbqc-violation-message-qualifier');
55
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
56 56
 		}
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.
src/ConstraintCheck/Checker/MultiValueChecker.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return CheckResult
57 57
 	 */
58
-	public function checkConstraint( Context $context, Constraint $constraint ) {
59
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
60
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
58
+	public function checkConstraint(Context $context, Constraint $constraint) {
59
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
60
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
61 61
 		}
62 62
 
63 63
 		$propertyId = $context->getSnak()->getPropertyId();
@@ -69,18 +69,18 @@  discard block
 block discarded – undo
69 69
 			$propertyId
70 70
 		);
71 71
 
72
-		if ( $propertyCount <= 1 ) {
73
-			$message = new ViolationMessage( 'wbqc-violation-message-multi-value' );
72
+		if ($propertyCount <= 1) {
73
+			$message = new ViolationMessage('wbqc-violation-message-multi-value');
74 74
 			$status = CheckResult::STATUS_VIOLATION;
75 75
 		} else {
76 76
 			$message = null;
77 77
 			$status = CheckResult::STATUS_COMPLIANCE;
78 78
 		}
79 79
 
80
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
80
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
81 81
 	}
82 82
 
83
-	public function checkConstraintParameters( Constraint $constraint ) {
83
+	public function checkConstraintParameters(Constraint $constraint) {
84 84
 		// no parameters
85 85
 		return [];
86 86
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueOnlyChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@
 block discarded – undo
36 36
 		];
37 37
 	}
38 38
 
39
-	public function checkConstraint( Context $context, Constraint $constraint ) {
40
-		if ( $context->getType() === Context::TYPE_STATEMENT ) {
41
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
39
+	public function checkConstraint(Context $context, Constraint $constraint) {
40
+		if ($context->getType() === Context::TYPE_STATEMENT) {
41
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
42 42
 		} else {
43
-			$message = new ViolationMessage( 'wbqc-violation-message-valueOnly' );
44
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
43
+			$message = new ViolationMessage('wbqc-violation-message-valueOnly');
44
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
45 45
 		}
46 46
 	}
47 47
 
48
-	public function checkConstraintParameters( Constraint $constraint ) {
48
+	public function checkConstraintParameters(Constraint $constraint) {
49 49
 		// no parameters
50 50
 		return [];
51 51
 	}
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
@@ -36,16 +36,16 @@
 block discarded – undo
36 36
 		];
37 37
 	}
38 38
 
39
-	public function checkConstraint( Context $context, Constraint $constraint ) {
40
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
41
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
39
+	public function checkConstraint(Context $context, Constraint $constraint) {
40
+		if ($context->getType() === Context::TYPE_REFERENCE) {
41
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
42 42
 		} else {
43
-			$message = new ViolationMessage( 'wbqc-violation-message-reference' );
44
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
43
+			$message = new ViolationMessage('wbqc-violation-message-reference');
44
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
45 45
 		}
46 46
 	}
47 47
 
48
-	public function checkConstraintParameters( Constraint $constraint ) {
48
+	public function checkConstraintParameters(Constraint $constraint) {
49 49
 		// no parameters
50 50
 		return [];
51 51
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SingleValueChecker.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return CheckResult
57 57
 	 */
58
-	public function checkConstraint( Context $context, Constraint $constraint ) {
59
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
60
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
58
+	public function checkConstraint(Context $context, Constraint $constraint) {
59
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
60
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
61 61
 		}
62 62
 
63 63
 		$propertyId = $context->getSnak()->getPropertyId();
@@ -69,18 +69,18 @@  discard block
 block discarded – undo
69 69
 			$propertyId
70 70
 		);
71 71
 
72
-		if ( $propertyCount > 1 ) {
73
-			$message = new ViolationMessage( 'wbqc-violation-message-single-value' );
72
+		if ($propertyCount > 1) {
73
+			$message = new ViolationMessage('wbqc-violation-message-single-value');
74 74
 			$status = CheckResult::STATUS_VIOLATION;
75 75
 		} else {
76 76
 			$message = null;
77 77
 			$status = CheckResult::STATUS_COMPLIANCE;
78 78
 		}
79 79
 
80
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
80
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
81 81
 	}
82 82
 
83
-	public function checkConstraintParameters( Constraint $constraint ) {
83
+	public function checkConstraintParameters(Constraint $constraint) {
84 84
 		// no parameters
85 85
 		return [];
86 86
 	}
Please login to merge, or discard this patch.