@@ -70,43 +70,43 @@ discard block |
||
70 | 70 | * @throws ConstraintParameterException |
71 | 71 | * @return CheckResult |
72 | 72 | */ |
73 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
74 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
75 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
73 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
74 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
75 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $parameters = []; |
79 | 79 | $constraintParameters = $constraint->getConstraintParameters(); |
80 | 80 | |
81 | - $properties = $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
81 | + $properties = $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
82 | 82 | $parameters['property'] = $properties; |
83 | 83 | |
84 | 84 | $message = ''; |
85 | 85 | $status = CheckResult::STATUS_COMPLIANCE; |
86 | 86 | |
87 | 87 | /** @var Snak $qualifier */ |
88 | - foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) { |
|
88 | + foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) { |
|
89 | 89 | $allowedQualifier = false; |
90 | - foreach ( $properties as $property ) { |
|
91 | - if ( $qualifier->getPropertyId()->equals( $property ) ) { |
|
90 | + foreach ($properties as $property) { |
|
91 | + if ($qualifier->getPropertyId()->equals($property)) { |
|
92 | 92 | $allowedQualifier = true; |
93 | 93 | break; |
94 | 94 | } |
95 | 95 | } |
96 | - if ( !$allowedQualifier ) { |
|
97 | - if ( empty( $properties ) || $properties === [ '' ] ) { |
|
98 | - $message = wfMessage( 'wbqc-violation-message-no-qualifiers' ); |
|
96 | + if (!$allowedQualifier) { |
|
97 | + if (empty($properties) || $properties === ['']) { |
|
98 | + $message = wfMessage('wbqc-violation-message-no-qualifiers'); |
|
99 | 99 | $message->rawParams( |
100 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ) |
|
100 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY) |
|
101 | 101 | ); |
102 | 102 | } else { |
103 | - $message = wfMessage( "wbqc-violation-message-qualifiers" ); |
|
103 | + $message = wfMessage("wbqc-violation-message-qualifiers"); |
|
104 | 104 | $message->rawParams( |
105 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
106 | - $this->constraintParameterRenderer->formatEntityId( $qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE ) |
|
105 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
106 | + $this->constraintParameterRenderer->formatEntityId($qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE) |
|
107 | 107 | ); |
108 | - $message->numParams( count( $properties ) ); |
|
109 | - $message->rawParams( $this->constraintParameterRenderer->formatPropertyIdList( $properties, Role::QUALIFIER_PREDICATE ) ); |
|
108 | + $message->numParams(count($properties)); |
|
109 | + $message->rawParams($this->constraintParameterRenderer->formatPropertyIdList($properties, Role::QUALIFIER_PREDICATE)); |
|
110 | 110 | } |
111 | 111 | $message = $message->escaped(); |
112 | 112 | $status = CheckResult::STATUS_VIOLATION; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
117 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
118 | 118 | } |
119 | 119 | |
120 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
120 | + public function checkConstraintParameters(Constraint $constraint) { |
|
121 | 121 | $constraintParameters = $constraint->getConstraintParameters(); |
122 | 122 | $exceptions = []; |
123 | 123 | try { |
124 | - $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
125 | - } catch ( ConstraintParameterException $e ) { |
|
124 | + $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
125 | + } catch (ConstraintParameterException $e) { |
|
126 | 126 | $exceptions[] = $e; |
127 | 127 | } |
128 | 128 | return $exceptions; |
@@ -35,29 +35,29 @@ |
||
35 | 35 | * |
36 | 36 | * @return CheckResult |
37 | 37 | */ |
38 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
39 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
40 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
38 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
39 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
40 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $propertyId = $context->getSnak()->getPropertyId(); |
44 | 44 | |
45 | 45 | $parameters = []; |
46 | 46 | |
47 | - $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount( $context->getEntity()->getStatements() ); |
|
47 | + $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount($context->getEntity()->getStatements()); |
|
48 | 48 | |
49 | - if ( $propertyCountArray[$propertyId->getSerialization()] <= 1 ) { |
|
50 | - $message = wfMessage( "wbqc-violation-message-multi-value" )->escaped(); |
|
49 | + if ($propertyCountArray[$propertyId->getSerialization()] <= 1) { |
|
50 | + $message = wfMessage("wbqc-violation-message-multi-value")->escaped(); |
|
51 | 51 | $status = CheckResult::STATUS_VIOLATION; |
52 | 52 | } else { |
53 | 53 | $message = ''; |
54 | 54 | $status = CheckResult::STATUS_COMPLIANCE; |
55 | 55 | } |
56 | 56 | |
57 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
57 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
58 | 58 | } |
59 | 59 | |
60 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
60 | + public function checkConstraintParameters(Constraint $constraint) { |
|
61 | 61 | // no parameters |
62 | 62 | return []; |
63 | 63 | } |
@@ -35,29 +35,29 @@ |
||
35 | 35 | * |
36 | 36 | * @return CheckResult |
37 | 37 | */ |
38 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
39 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
40 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
38 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
39 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
40 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $propertyId = $context->getSnak()->getPropertyId(); |
44 | 44 | |
45 | 45 | $parameters = []; |
46 | 46 | |
47 | - $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount( $context->getEntity()->getStatements() ); |
|
47 | + $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount($context->getEntity()->getStatements()); |
|
48 | 48 | |
49 | - if ( $propertyCountArray[$propertyId->getSerialization()] > 1 ) { |
|
50 | - $message = wfMessage( "wbqc-violation-message-single-value" )->escaped(); |
|
49 | + if ($propertyCountArray[$propertyId->getSerialization()] > 1) { |
|
50 | + $message = wfMessage("wbqc-violation-message-single-value")->escaped(); |
|
51 | 51 | $status = CheckResult::STATUS_VIOLATION; |
52 | 52 | } else { |
53 | 53 | $message = ''; |
54 | 54 | $status = CheckResult::STATUS_COMPLIANCE; |
55 | 55 | } |
56 | 56 | |
57 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
57 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
58 | 58 | } |
59 | 59 | |
60 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
60 | + public function checkConstraintParameters(Constraint $constraint) { |
|
61 | 61 | // no parameters |
62 | 62 | return []; |
63 | 63 | } |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | * @throws ConstraintParameterException |
93 | 93 | * @return CheckResult |
94 | 94 | */ |
95 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
96 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
97 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
95 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
96 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
97 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $parameters = []; |
101 | 101 | $constraintParameters = $constraint->getConstraintParameters(); |
102 | 102 | |
103 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
104 | - $parameters['property'] = [ $propertyId ]; |
|
103 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
104 | + $parameters['property'] = [$propertyId]; |
|
105 | 105 | |
106 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
106 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
107 | 107 | $parameters['items'] = $items; |
108 | 108 | |
109 | 109 | /* |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | * a) a property only |
112 | 112 | * b) a property and a number of items (each combination of property and item forming an individual claim) |
113 | 113 | */ |
114 | - if ( $items === [] ) { |
|
114 | + if ($items === []) { |
|
115 | 115 | $offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
116 | 116 | $context->getEntity()->getStatements(), |
117 | 117 | $propertyId |
118 | 118 | ); |
119 | - if ( $offendingStatement !== null ) { |
|
120 | - $message = wfMessage( "wbqc-violation-message-conflicts-with-property" ) |
|
119 | + if ($offendingStatement !== null) { |
|
120 | + $message = wfMessage("wbqc-violation-message-conflicts-with-property") |
|
121 | 121 | ->rawParams( |
122 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
123 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
122 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
123 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
124 | 124 | ) |
125 | 125 | ->escaped(); |
126 | 126 | $status = CheckResult::STATUS_VIOLATION; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | $propertyId, |
135 | 135 | $items |
136 | 136 | ); |
137 | - if ( $offendingStatement !== null ) { |
|
138 | - $offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() ); |
|
139 | - $message = wfMessage( "wbqc-violation-message-conflicts-with-claim" ) |
|
137 | + if ($offendingStatement !== null) { |
|
138 | + $offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak()); |
|
139 | + $message = wfMessage("wbqc-violation-message-conflicts-with-claim") |
|
140 | 140 | ->rawParams( |
141 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
142 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
143 | - $this->constraintParameterRenderer->formatItemIdSnakValue( $offendingValue, Role::OBJECT ) |
|
141 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
142 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
143 | + $this->constraintParameterRenderer->formatItemIdSnakValue($offendingValue, Role::OBJECT) |
|
144 | 144 | ) |
145 | 145 | ->escaped(); |
146 | 146 | $status = CheckResult::STATUS_VIOLATION; |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
153 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
154 | 154 | } |
155 | 155 | |
156 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
156 | + public function checkConstraintParameters(Constraint $constraint) { |
|
157 | 157 | $constraintParameters = $constraint->getConstraintParameters(); |
158 | 158 | $exceptions = []; |
159 | 159 | try { |
160 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
161 | - } catch ( ConstraintParameterException $e ) { |
|
160 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
161 | + } catch (ConstraintParameterException $e) { |
|
162 | 162 | $exceptions[] = $e; |
163 | 163 | } |
164 | 164 | try { |
165 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
166 | - } catch ( ConstraintParameterException $e ) { |
|
165 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
166 | + } catch (ConstraintParameterException $e) { |
|
167 | 167 | $exceptions[] = $e; |
168 | 168 | } |
169 | 169 | return $exceptions; |
@@ -91,18 +91,18 @@ discard block |
||
91 | 91 | * @throws ConstraintParameterException |
92 | 92 | * @return CheckResult |
93 | 93 | */ |
94 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
95 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
96 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
94 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
95 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
96 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $parameters = []; |
100 | 100 | $constraintParameters = $constraint->getConstraintParameters(); |
101 | 101 | |
102 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
103 | - $parameters['property'] = [ $propertyId ]; |
|
102 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
103 | + $parameters['property'] = [$propertyId]; |
|
104 | 104 | |
105 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
105 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
106 | 106 | $parameters['items'] = $items; |
107 | 107 | |
108 | 108 | /* |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * a) a property only |
111 | 111 | * b) a property and a number of items (each combination of property and item forming an individual claim) |
112 | 112 | */ |
113 | - if ( $items === [] ) { |
|
113 | + if ($items === []) { |
|
114 | 114 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
115 | 115 | $context->getEntity()->getStatements(), |
116 | 116 | $propertyId |
@@ -123,35 +123,35 @@ discard block |
||
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
126 | - if ( $requiredStatement !== null ) { |
|
126 | + if ($requiredStatement !== null) { |
|
127 | 127 | $status = CheckResult::STATUS_COMPLIANCE; |
128 | 128 | $message = ''; |
129 | 129 | } else { |
130 | 130 | $status = CheckResult::STATUS_VIOLATION; |
131 | - $message = wfMessage( 'wbqc-violation-message-item' ); |
|
131 | + $message = wfMessage('wbqc-violation-message-item'); |
|
132 | 132 | $message->rawParams( |
133 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
134 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
133 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
134 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
135 | 135 | ); |
136 | - $message->numParams( count( $items ) ); |
|
137 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
136 | + $message->numParams(count($items)); |
|
137 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
138 | 138 | $message = $message->escaped(); |
139 | 139 | } |
140 | 140 | |
141 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
141 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
142 | 142 | } |
143 | 143 | |
144 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
144 | + public function checkConstraintParameters(Constraint $constraint) { |
|
145 | 145 | $constraintParameters = $constraint->getConstraintParameters(); |
146 | 146 | $exceptions = []; |
147 | 147 | try { |
148 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
149 | - } catch ( ConstraintParameterException $e ) { |
|
148 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
149 | + } catch (ConstraintParameterException $e) { |
|
150 | 150 | $exceptions[] = $e; |
151 | 151 | } |
152 | 152 | try { |
153 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
154 | - } catch ( ConstraintParameterException $e ) { |
|
153 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
154 | + } catch (ConstraintParameterException $e) { |
|
155 | 155 | $exceptions[] = $e; |
156 | 156 | } |
157 | 157 | return $exceptions; |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | * @throws ConstraintParameterException |
96 | 96 | * @return CheckResult |
97 | 97 | */ |
98 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
99 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
100 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
98 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
99 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
100 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $parameters = []; |
104 | 104 | $constraintParameters = $constraint->getConstraintParameters(); |
105 | 105 | |
106 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
107 | - $parameters['property'] = [ $propertyId ]; |
|
106 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
107 | + $parameters['property'] = [$propertyId]; |
|
108 | 108 | |
109 | 109 | $snak = $context->getSnak(); |
110 | 110 | |
111 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
111 | + if (!$snak instanceof PropertyValueSnak) { |
|
112 | 112 | // nothing to check |
113 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
113 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $dataValue = $snak->getDataValue(); |
@@ -119,22 +119,22 @@ discard block |
||
119 | 119 | * error handling: |
120 | 120 | * type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid' |
121 | 121 | */ |
122 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
123 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
122 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
123 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
124 | 124 | ->rawParams( |
125 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
125 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
126 | 126 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
127 | 127 | ) |
128 | 128 | ->escaped(); |
129 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
129 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
130 | 130 | } |
131 | 131 | /** @var EntityIdValue $dataValue */ |
132 | 132 | |
133 | 133 | $targetEntityId = $dataValue->getEntityId(); |
134 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
135 | - if ( $targetEntity === null ) { |
|
136 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
137 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
134 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
135 | + if ($targetEntity === null) { |
|
136 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
137 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -142,31 +142,31 @@ discard block |
||
142 | 142 | $propertyId, |
143 | 143 | $context->getEntity()->getId() |
144 | 144 | ); |
145 | - if ( $inverseStatement !== null ) { |
|
145 | + if ($inverseStatement !== null) { |
|
146 | 146 | $message = ''; |
147 | 147 | $status = CheckResult::STATUS_COMPLIANCE; |
148 | 148 | } else { |
149 | - $message = wfMessage( 'wbqc-violation-message-inverse' ) |
|
149 | + $message = wfMessage('wbqc-violation-message-inverse') |
|
150 | 150 | ->rawParams( |
151 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
152 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
153 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
151 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
152 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
153 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
154 | 154 | ) |
155 | 155 | ->escaped(); |
156 | 156 | $status = CheckResult::STATUS_VIOLATION; |
157 | 157 | } |
158 | 158 | |
159 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
160 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
161 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
159 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
160 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
161 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
162 | 162 | } |
163 | 163 | |
164 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
164 | + public function checkConstraintParameters(Constraint $constraint) { |
|
165 | 165 | $constraintParameters = $constraint->getConstraintParameters(); |
166 | 166 | $exceptions = []; |
167 | 167 | try { |
168 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
169 | - } catch ( ConstraintParameterException $e ) { |
|
168 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
169 | + } catch (ConstraintParameterException $e) { |
|
170 | 170 | $exceptions[] = $e; |
171 | 171 | } |
172 | 172 | return $exceptions; |
@@ -70,43 +70,43 @@ |
||
70 | 70 | * @throws ConstraintParameterException |
71 | 71 | * @return CheckResult |
72 | 72 | */ |
73 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
74 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
75 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
73 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
74 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
75 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $parameters = []; |
79 | 79 | $constraintParameters = $constraint->getConstraintParameters(); |
80 | 80 | |
81 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
82 | - $parameters['property'] = [ $propertyId ]; |
|
81 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
82 | + $parameters['property'] = [$propertyId]; |
|
83 | 83 | |
84 | - $message = wfMessage( "wbqc-violation-message-mandatory-qualifier" ) |
|
84 | + $message = wfMessage("wbqc-violation-message-mandatory-qualifier") |
|
85 | 85 | ->rawParams( |
86 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
87 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE ) |
|
86 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
87 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE) |
|
88 | 88 | ) |
89 | 89 | ->escaped(); |
90 | 90 | $status = CheckResult::STATUS_VIOLATION; |
91 | 91 | |
92 | 92 | /** @var Snak $qualifier */ |
93 | - foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) { |
|
94 | - if ( $propertyId->equals( $qualifier->getPropertyId() ) ) { |
|
93 | + foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) { |
|
94 | + if ($propertyId->equals($qualifier->getPropertyId())) { |
|
95 | 95 | $message = ''; |
96 | 96 | $status = CheckResult::STATUS_COMPLIANCE; |
97 | 97 | break; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
101 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
102 | 102 | } |
103 | 103 | |
104 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
104 | + public function checkConstraintParameters(Constraint $constraint) { |
|
105 | 105 | $constraintParameters = $constraint->getConstraintParameters(); |
106 | 106 | $exceptions = []; |
107 | 107 | try { |
108 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
109 | - } catch ( ConstraintParameterException $e ) { |
|
108 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
109 | + } catch (ConstraintParameterException $e) { |
|
110 | 110 | $exceptions[] = $e; |
111 | 111 | } |
112 | 112 | return $exceptions; |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
34 | - $updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' ); |
|
33 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
34 | + $updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql'); |
|
35 | 35 | return true; |
36 | 36 | } |
37 | 37 | |
38 | - public static function onWikibaseChange( Change $change ) { |
|
38 | + public static function onWikibaseChange(Change $change) { |
|
39 | 39 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
40 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
41 | - self::isConstraintStatementsChange( $config, $change ) |
|
40 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
41 | + self::isConstraintStatementsChange($config, $change) |
|
42 | 42 | ) { |
43 | 43 | /** @var EntityChange $change */ |
44 | 44 | $title = Title::newMainPage(); |
45 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
45 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
46 | 46 | JobQueueGroup::singleton()->push( |
47 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
47 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
48 | 48 | ); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
53 | - if ( !( $change instanceof EntityChange ) || |
|
52 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
53 | + if (!($change instanceof EntityChange) || |
|
54 | 54 | $change->getAction() !== EntityChange::UPDATE || |
55 | - !( $change->getEntityId() instanceof PropertyId ) |
|
55 | + !($change->getEntityId() instanceof PropertyId) |
|
56 | 56 | ) { |
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $info = $change->getInfo(); |
61 | 61 | |
62 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
62 | + if (!array_key_exists('compactDiff', $info)) { |
|
63 | 63 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
64 | 64 | // so we only know that the change *might* affect the constraint statements |
65 | 65 | return true; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | /** @var EntityDiffChangedAspects $aspects */ |
69 | 69 | $aspects = $info['compactDiff']; |
70 | 70 | |
71 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
72 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
71 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
72 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
73 | 73 | } |
74 | 74 | |
75 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
75 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
76 | 76 | $repo = WikibaseRepo::getDefaultInstance(); |
77 | 77 | |
78 | 78 | $entityContentFactory = $repo->getEntityContentFactory(); |
79 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
80 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
79 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
80 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
81 | 81 | $resultsCache = ResultsCache::getDefaultInstance(); |
82 | - $resultsCache->delete( $entityId ); |
|
82 | + $resultsCache->delete($entityId); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | * @param int $timestamp UTC timestamp (seconds since the Epoch) |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - public static function isGadgetEnabledForUserName( $userName, $timestamp ) { |
|
91 | + public static function isGadgetEnabledForUserName($userName, $timestamp) { |
|
92 | 92 | $initial = $userName[0]; |
93 | 93 | |
94 | - if ( $initial === 'Z' ) { |
|
94 | + if ($initial === 'Z') { |
|
95 | 95 | $firstWeek = 0; |
96 | - } elseif ( $initial >= 'W' && $initial < 'Z' ) { |
|
96 | + } elseif ($initial >= 'W' && $initial < 'Z') { |
|
97 | 97 | $firstWeek = 1; |
98 | - } elseif ( $initial >= 'T' && $initial < 'W' ) { |
|
98 | + } elseif ($initial >= 'T' && $initial < 'W') { |
|
99 | 99 | $firstWeek = 2; |
100 | - } elseif ( $initial >= 'N' && $initial < 'T' ) { |
|
100 | + } elseif ($initial >= 'N' && $initial < 'T') { |
|
101 | 101 | $firstWeek = 3; |
102 | - } elseif ( $initial >= 'E' && $initial < 'N' ) { |
|
102 | + } elseif ($initial >= 'E' && $initial < 'N') { |
|
103 | 103 | $firstWeek = 4; |
104 | 104 | } else { |
105 | 105 | $firstWeek = 5; |
@@ -117,24 +117,24 @@ discard block |
||
117 | 117 | return $timestamp >= $threshold; |
118 | 118 | } |
119 | 119 | |
120 | - public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) { |
|
120 | + public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) { |
|
121 | 121 | $repo = WikibaseRepo::getDefaultInstance(); |
122 | 122 | |
123 | 123 | $lookup = $repo->getEntityNamespaceLookup(); |
124 | 124 | $title = $out->getTitle(); |
125 | - if ( $title === null ) { |
|
125 | + if ($title === null) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
129 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
132 | + if (!$out->getUser()->isLoggedIn()) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | - if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) { |
|
137 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
136 | + if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) { |
|
137 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param ItemId $itemId |
45 | 45 | * @return self |
46 | 46 | */ |
47 | - public static function fromItemId( ItemId $itemId ) { |
|
47 | + public static function fromItemId(ItemId $itemId) { |
|
48 | 48 | $ret = new self; |
49 | 49 | $ret->itemId = $itemId; |
50 | 50 | return $ret; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * @throws InvalidArgumentException |
81 | 81 | * @return self |
82 | 82 | */ |
83 | - public static function fromSnak( Snak $snak ) { |
|
84 | - switch ( true ) { |
|
83 | + public static function fromSnak(Snak $snak) { |
|
84 | + switch (true) { |
|
85 | 85 | case $snak instanceof PropertyValueSnak: |
86 | 86 | $dataValue = $snak->getDataValue(); |
87 | - if ( $dataValue instanceof EntityIdValue |
|
87 | + if ($dataValue instanceof EntityIdValue |
|
88 | 88 | && $dataValue->getEntityId() instanceof ItemId |
89 | 89 | ) { |
90 | - return self::fromItemId( $dataValue->getEntityId() ); |
|
90 | + return self::fromItemId($dataValue->getEntityId()); |
|
91 | 91 | } |
92 | 92 | break; |
93 | 93 | case $snak instanceof PropertySomeValueSnak: |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | return self::noValue(); |
97 | 97 | } |
98 | 98 | |
99 | - throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' ); |
|
99 | + throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @return ItemId |
134 | 134 | */ |
135 | 135 | public function getItemId() { |
136 | - if ( ! $this->isValue() ) { |
|
137 | - throw new DomainException( 'This value does not contain an item ID.' ); |
|
136 | + if (!$this->isValue()) { |
|
137 | + throw new DomainException('This value does not contain an item ID.'); |
|
138 | 138 | } |
139 | 139 | return $this->itemId; |
140 | 140 | } |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * @param Snak $snak |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - public function matchesSnak( Snak $snak ) { |
|
150 | - switch ( true ) { |
|
149 | + public function matchesSnak(Snak $snak) { |
|
150 | + switch (true) { |
|
151 | 151 | case $snak instanceof PropertyValueSnak: |
152 | 152 | return $this->isValue() && |
153 | 153 | $snak->getDataValue() instanceof EntityIdValue && |
154 | 154 | $snak->getDataValue()->getEntityId() instanceof ItemId && |
155 | - $snak->getDataValue()->getEntityId()->equals( $this->getItemId() ); |
|
155 | + $snak->getDataValue()->getEntityId()->equals($this->getItemId()); |
|
156 | 156 | case $snak instanceof PropertySomeValueSnak: |
157 | 157 | return $this->isSomeValue(); |
158 | 158 | case $snak instanceof PropertyNoValueSnak: |