Completed
Push — master ( c83719...6a6753 )
by
unknown
02:45
created
src/ConstraintCheck/Helper/DummySparqlHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
 		// no parent::__construct() call
23 23
 	}
24 24
 
25
-	public function hasType( $id, array $classes, $withInstance ) {
26
-		throw new LogicException( 'methods of this class should never be called' );
25
+	public function hasType($id, array $classes, $withInstance) {
26
+		throw new LogicException('methods of this class should never be called');
27 27
 	}
28 28
 
29 29
 	public function findEntitiesWithSameStatement(
30 30
 		Statement $statement,
31 31
 		$ignoreDeprecatedStatements
32 32
 	) {
33
-		throw new LogicException( 'methods of this class should never be called' );
33
+		throw new LogicException('methods of this class should never be called');
34 34
 	}
35 35
 
36 36
 	public function findEntitiesWithSameQualifierOrReference(
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 		$type,
40 40
 		$ignoreDeprecatedStatements
41 41
 	) {
42
-		throw new LogicException( 'methods of this class should never be called' );
42
+		throw new LogicException('methods of this class should never be called');
43 43
 	}
44 44
 
45
-	public function matchesRegularExpression( $text, $regex ) {
46
-		throw new LogicException( 'methods of this class should never be called' );
45
+	public function matchesRegularExpression($text, $regex) {
46
+		throw new LogicException('methods of this class should never be called');
47 47
 	}
48 48
 
49
-	public function runQuery( $query ) {
50
-		throw new LogicException( 'methods of this class should never be called' );
49
+	public function runQuery($query) {
50
+		throw new LogicException('methods of this class should never be called');
51 51
 	}
52 52
 
53 53
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/UniqueValueChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
65 65
 	 * @return CheckResult
66 66
 	 */
67
-	public function checkConstraint( Context $context, Constraint $constraint ) {
68
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
69
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
67
+	public function checkConstraint(Context $context, Constraint $constraint) {
68
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
69
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
70 70
 		}
71 71
 
72 72
 		$parameters = [];
73 73
 
74
-		if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
75
-			if ( $context->getType() === 'statement' ) {
74
+		if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
75
+			if ($context->getType() === 'statement') {
76 76
 				$result = $this->sparqlHelper->findEntitiesWithSameStatement(
77 77
 					$context->getSnakStatement(),
78 78
 					true // ignore deprecated statements
79 79
 				);
80 80
 			} else {
81
-				if ( $context->getSnak()->getType() !== 'value' ) {
82
-					return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
81
+				if ($context->getSnak()->getType() !== 'value') {
82
+					return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
83 83
 				}
84 84
 				$result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference(
85 85
 					$context->getEntity()->getId(),
@@ -92,27 +92,27 @@  discard block
 block discarded – undo
92 92
 			$otherEntities = $result->getArray();
93 93
 			$metadata = $result->getMetadata();
94 94
 
95
-			if ( $otherEntities === [] ) {
95
+			if ($otherEntities === []) {
96 96
 				$status = CheckResult::STATUS_COMPLIANCE;
97 97
 				$message = null;
98 98
 			} else {
99
-				$otherEntities = array_values( array_filter( $otherEntities ) ); // remove nulls
99
+				$otherEntities = array_values(array_filter($otherEntities)); // remove nulls
100 100
 				$status = CheckResult::STATUS_VIOLATION;
101
-				$message = ( new ViolationMessage( 'wbqc-violation-message-unique-value' ) )
102
-					->withEntityIdList( $otherEntities, Role::SUBJECT );
101
+				$message = (new ViolationMessage('wbqc-violation-message-unique-value'))
102
+					->withEntityIdList($otherEntities, Role::SUBJECT);
103 103
 			}
104 104
 		} else {
105 105
 			$status = CheckResult::STATUS_TODO;
106
-			$message = ( new ViolationMessage( 'wbqc-violation-message-not-yet-implemented' ) )
107
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM );
106
+			$message = (new ViolationMessage('wbqc-violation-message-not-yet-implemented'))
107
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM);
108 108
 			$metadata = Metadata::blank();
109 109
 		}
110 110
 
111
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
112
-			->withMetadata( $metadata );
111
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
112
+			->withMetadata($metadata);
113 113
 	}
114 114
 
115
-	public function checkConstraintParameters( Constraint $constraint ) {
115
+	public function checkConstraintParameters(Constraint $constraint) {
116 116
 		// no parameters
117 117
 		return [];
118 118
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/FormatChecker.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	 * @throws ConstraintParameterException
86 86
 	 * @return CheckResult
87 87
 	 */
88
-	public function checkConstraint( Context $context, Constraint $constraint ) {
88
+	public function checkConstraint(Context $context, Constraint $constraint) {
89 89
 		$parameters = [];
90 90
 		$constraintParameters = $constraint->getConstraintParameters();
91 91
 
92
-		$format = $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
93
-		$parameters['pattern'] = [ $format ];
92
+		$format = $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId());
93
+		$parameters['pattern'] = [$format];
94 94
 
95 95
 		$syntaxClarifications = $this->constraintParameterParser->parseSyntaxClarificationParameter(
96 96
 			$constraintParameters
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
 		$snak = $context->getSnak();
100 100
 
101
-		if ( !$snak instanceof PropertyValueSnak ) {
101
+		if (!$snak instanceof PropertyValueSnak) {
102 102
 			// nothing to check
103
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
103
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
104 104
 		}
105 105
 
106 106
 		$dataValue = $snak->getDataValue();
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * error handling:
110 110
 		 *   type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext'
111 111
 		 */
112
-		switch ( $dataValue->getType() ) {
112
+		switch ($dataValue->getType()) {
113 113
 			case 'string':
114 114
 				$text = $dataValue->getValue();
115 115
 				break;
@@ -118,49 +118,49 @@  discard block
 block discarded – undo
118 118
 				$text = $dataValue->getText();
119 119
 				break;
120 120
 			default:
121
-				$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) )
122
-					->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
123
-					->withDataValueType( 'string' )
124
-					->withDataValueType( 'monolingualtext' );
125
-				return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
121
+				$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2'))
122
+					->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
123
+					->withDataValueType('string')
124
+					->withDataValueType('monolingualtext');
125
+				return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
126 126
 		}
127 127
 
128 128
 		if (
129
-			!( $this->sparqlHelper instanceof DummySparqlHelper ) &&
130
-			$this->config->get( 'WBQualityConstraintsCheckFormatConstraint' )
129
+			!($this->sparqlHelper instanceof DummySparqlHelper) &&
130
+			$this->config->get('WBQualityConstraintsCheckFormatConstraint')
131 131
 		) {
132
-			if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) {
132
+			if ($this->sparqlHelper->matchesRegularExpression($text, $format)) {
133 133
 				$message = null;
134 134
 				$status = CheckResult::STATUS_COMPLIANCE;
135 135
 			} else {
136
-				$message = ( new ViolationMessage( 'wbqc-violation-message-format-clarification' ) )
137
-					->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
138
-					->withDataValue( new StringValue( $text ), Role::OBJECT )
139
-					->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE )
140
-					->withMultilingualText( $syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE );
136
+				$message = (new ViolationMessage('wbqc-violation-message-format-clarification'))
137
+					->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
138
+					->withDataValue(new StringValue($text), Role::OBJECT)
139
+					->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE)
140
+					->withMultilingualText($syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE);
141 141
 				$status = CheckResult::STATUS_VIOLATION;
142 142
 			}
143 143
 		} else {
144
-			$message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) )
145
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM );
144
+			$message = (new ViolationMessage('wbqc-violation-message-security-reason'))
145
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM);
146 146
 			$status = CheckResult::STATUS_TODO;
147 147
 		}
148
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
148
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
149 149
 	}
150 150
 
151
-	public function checkConstraintParameters( Constraint $constraint ) {
151
+	public function checkConstraintParameters(Constraint $constraint) {
152 152
 		$constraintParameters = $constraint->getConstraintParameters();
153 153
 		$exceptions = [];
154 154
 		try {
155
-			$this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
156
-		} catch ( ConstraintParameterException $e ) {
155
+			$this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId());
156
+		} catch (ConstraintParameterException $e) {
157 157
 			$exceptions[] = $e;
158 158
 		}
159 159
 		try {
160 160
 			$this->constraintParameterParser->parseSyntaxClarificationParameter(
161 161
 				$constraintParameters
162 162
 			);
163
-		} catch ( ConstraintParameterException $e ) {
163
+		} catch (ConstraintParameterException $e) {
164 164
 			$exceptions[] = $e;
165 165
 		}
166 166
 		return $exceptions;
Please login to merge, or discard this patch.