@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param int $maxAge The maximum age of the cached value (in seconds). |
30 | 30 | * @return self Indication that a value is possibly outdated by up to this many seconds. |
31 | 31 | */ |
32 | - public static function ofMaximumAgeInSeconds( $maxAge ) { |
|
33 | - Assert::parameterType( 'integer', $maxAge, '$maxAge' ); |
|
34 | - Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' ); |
|
32 | + public static function ofMaximumAgeInSeconds($maxAge) { |
|
33 | + Assert::parameterType('integer', $maxAge, '$maxAge'); |
|
34 | + Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0'); |
|
35 | 35 | $ret = new self; |
36 | 36 | $ret->maxAge = $maxAge; |
37 | 37 | return $ret; |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @param array|null $array As returned by toArray. |
43 | 43 | * @return self |
44 | 44 | */ |
45 | - public static function ofArray( array $array = null ) { |
|
45 | + public static function ofArray(array $array = null) { |
|
46 | 46 | $ret = new self; |
47 | - if ( $array !== null ) { |
|
47 | + if ($array !== null) { |
|
48 | 48 | $ret->maxAge = $array['maximumAgeInSeconds']; |
49 | 49 | } |
50 | 50 | return $ret; |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * @param self[] $metadatas |
55 | 55 | * @return self |
56 | 56 | */ |
57 | - public static function merge( array $metadatas ) { |
|
58 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
57 | + public static function merge(array $metadatas) { |
|
58 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
59 | 59 | $ret = new self; |
60 | - foreach ( $metadatas as $metadata ) { |
|
61 | - $ret->maxAge = max( $ret->maxAge, $metadata->maxAge ); |
|
60 | + foreach ($metadatas as $metadata) { |
|
61 | + $ret->maxAge = max($ret->maxAge, $metadata->maxAge); |
|
62 | 62 | } |
63 | 63 | return $ret; |
64 | 64 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * For a fresh value, returns 0. |
77 | 77 | */ |
78 | 78 | public function getMaximumAgeInSeconds() { |
79 | - if ( is_int( $this->maxAge ) ) { |
|
79 | + if (is_int($this->maxAge)) { |
|
80 | 80 | return $this->maxAge; |
81 | 81 | } else { |
82 | 82 | return 0; |
@@ -91,8 +91,7 @@ discard block |
||
91 | 91 | return $this->isCached() ? |
92 | 92 | [ |
93 | 93 | 'maximumAgeInSeconds' => $this->maxAge, |
94 | - ] : |
|
95 | - null; |
|
94 | + ] : null; |
|
96 | 95 | } |
97 | 96 | |
98 | 97 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * @throws ConstraintParameterException |
69 | 69 | * @return CheckResult |
70 | 70 | */ |
71 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
72 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
73 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
71 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
72 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
73 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $parameters = []; |
@@ -78,42 +78,42 @@ discard block |
||
78 | 78 | |
79 | 79 | $snak = $context->getSnak(); |
80 | 80 | |
81 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
81 | + if (!$snak instanceof PropertyValueSnak) { |
|
82 | 82 | // nothing to check |
83 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
83 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $dataValue = $snak->getDataValue(); |
87 | 87 | |
88 | - list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter( |
|
88 | + list($min, $max) = $this->constraintParameterParser->parseRangeParameter( |
|
89 | 89 | $constraintParameters, |
90 | 90 | $constraint->getConstraintTypeItemId(), |
91 | 91 | $dataValue->getType() |
92 | 92 | ); |
93 | 93 | $parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date'; |
94 | - if ( $min !== null ) { |
|
95 | - $parameters['minimum_' . $parameterKey] = [ $min ]; |
|
94 | + if ($min !== null) { |
|
95 | + $parameters['minimum_'.$parameterKey] = [$min]; |
|
96 | 96 | } |
97 | - if ( $max !== null ) { |
|
98 | - $parameters['maximum_' . $parameterKey] = [ $max ]; |
|
97 | + if ($max !== null) { |
|
98 | + $parameters['maximum_'.$parameterKey] = [$max]; |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 || |
|
102 | - $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0 |
|
101 | + if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 || |
|
102 | + $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0 |
|
103 | 103 | ) { |
104 | 104 | // at least one of $min, $max is set at this point, otherwise there could be no violation |
105 | 105 | $type = $dataValue->getType(); |
106 | - $openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen'; |
|
107 | - $message = wfMessage( "wbqc-violation-message-range-$type-$openness" ); |
|
106 | + $openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen'; |
|
107 | + $message = wfMessage("wbqc-violation-message-range-$type-$openness"); |
|
108 | 108 | $message->rawParams( |
109 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ), |
|
110 | - $this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT ) |
|
109 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE), |
|
110 | + $this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT) |
|
111 | 111 | ); |
112 | - if ( $min !== null ) { |
|
113 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) ); |
|
112 | + if ($min !== null) { |
|
113 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT)); |
|
114 | 114 | } |
115 | - if ( $max !== null ) { |
|
116 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) ); |
|
115 | + if ($max !== null) { |
|
116 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT)); |
|
117 | 117 | } |
118 | 118 | $message = $message->escaped(); |
119 | 119 | $status = CheckResult::STATUS_VIOLATION; |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | $status = CheckResult::STATUS_COMPLIANCE; |
123 | 123 | } |
124 | 124 | |
125 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
125 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
126 | 126 | } |
127 | 127 | |
128 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
128 | + public function checkConstraintParameters(Constraint $constraint) { |
|
129 | 129 | $constraintParameters = $constraint->getConstraintParameters(); |
130 | 130 | $exceptions = []; |
131 | 131 | try { |
132 | 132 | // we don’t have a data value here, so get the type from the property instead |
133 | 133 | // (the distinction between data type and data value type is irrelevant for 'quantity' and 'time') |
134 | - $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() ); |
|
134 | + $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId()); |
|
135 | 135 | $this->constraintParameterParser->parseRangeParameter( |
136 | 136 | $constraintParameters, |
137 | 137 | $constraint->getConstraintTypeItemId(), |
138 | 138 | $type |
139 | 139 | ); |
140 | - } catch ( ConstraintParameterException $e ) { |
|
140 | + } catch (ConstraintParameterException $e) { |
|
141 | 141 | $exceptions[] = $e; |
142 | 142 | } |
143 | 143 | return $exceptions; |
@@ -49,43 +49,43 @@ |
||
49 | 49 | * @throws ConstraintParameterException |
50 | 50 | * @return CheckResult |
51 | 51 | */ |
52 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
53 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
54 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
52 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
53 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
54 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $parameters = []; |
58 | 58 | $constraintParameters = $constraint->getConstraintParameters(); |
59 | 59 | |
60 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
60 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
61 | 61 | $parameters['item'] = $items; |
62 | 62 | |
63 | 63 | $snak = $context->getSnak(); |
64 | 64 | |
65 | - $message = wfMessage( 'wbqc-violation-message-one-of' ); |
|
66 | - $message->rawParams( $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) ); |
|
67 | - $message->numParams( count( $items ) ); |
|
68 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
65 | + $message = wfMessage('wbqc-violation-message-one-of'); |
|
66 | + $message->rawParams($this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)); |
|
67 | + $message->numParams(count($items)); |
|
68 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
69 | 69 | $message = $message->escaped(); |
70 | 70 | $status = CheckResult::STATUS_VIOLATION; |
71 | 71 | |
72 | - foreach ( $items as $item ) { |
|
73 | - if ( $item->matchesSnak( $snak ) ) { |
|
72 | + foreach ($items as $item) { |
|
73 | + if ($item->matchesSnak($snak)) { |
|
74 | 74 | $message = ''; |
75 | 75 | $status = CheckResult::STATUS_COMPLIANCE; |
76 | 76 | break; |
77 | 77 | } |
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 | $constraintParameters = $constraint->getConstraintParameters(); |
85 | 85 | $exceptions = []; |
86 | 86 | try { |
87 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
88 | - } catch ( ConstraintParameterException $e ) { |
|
87 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
88 | + } catch (ConstraintParameterException $e) { |
|
89 | 89 | $exceptions[] = $e; |
90 | 90 | } |
91 | 91 | return $exceptions; |
@@ -71,25 +71,25 @@ discard block |
||
71 | 71 | * @throws ConstraintParameterException |
72 | 72 | * @return CheckResult |
73 | 73 | */ |
74 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
75 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
76 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
74 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
75 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
76 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $parameters = []; |
80 | 80 | $constraintParameters = $constraint->getConstraintParameters(); |
81 | 81 | |
82 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
83 | - $parameters['property'] = [ $propertyId ]; |
|
82 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
83 | + $parameters['property'] = [$propertyId]; |
|
84 | 84 | |
85 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
85 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
86 | 86 | $parameters['items'] = $items; |
87 | 87 | |
88 | 88 | $snak = $context->getSnak(); |
89 | 89 | |
90 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
90 | + if (!$snak instanceof PropertyValueSnak) { |
|
91 | 91 | // nothing to check |
92 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
92 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $dataValue = $snak->getDataValue(); |
@@ -98,22 +98,22 @@ discard block |
||
98 | 98 | * error handling: |
99 | 99 | * type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid' |
100 | 100 | */ |
101 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
102 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
101 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
102 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
103 | 103 | ->rawParams( |
104 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
104 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
105 | 105 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
106 | 106 | ) |
107 | 107 | ->escaped(); |
108 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
108 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
109 | 109 | } |
110 | 110 | /** @var EntityIdValue $dataValue */ |
111 | 111 | |
112 | 112 | $targetEntityId = $dataValue->getEntityId(); |
113 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
114 | - if ( $targetEntity === null ) { |
|
115 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
116 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
113 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
114 | + if ($targetEntity === null) { |
|
115 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
116 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /* |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * a) a property only |
122 | 122 | * b) a property and a number of items (each combination forming an individual claim) |
123 | 123 | */ |
124 | - if ( $items === [] ) { |
|
124 | + if ($items === []) { |
|
125 | 125 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
126 | 126 | $targetEntity->getStatements(), |
127 | 127 | $propertyId |
@@ -134,37 +134,37 @@ discard block |
||
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
137 | - if ( $requiredStatement !== null ) { |
|
137 | + if ($requiredStatement !== null) { |
|
138 | 138 | $status = CheckResult::STATUS_COMPLIANCE; |
139 | 139 | $message = ''; |
140 | 140 | } else { |
141 | 141 | $status = CheckResult::STATUS_VIOLATION; |
142 | - $message = wfMessage( 'wbqc-violation-message-target-required-claim' ); |
|
142 | + $message = wfMessage('wbqc-violation-message-target-required-claim'); |
|
143 | 143 | $message->rawParams( |
144 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
145 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
144 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
145 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
146 | 146 | ); |
147 | - $message->numParams( count( $items ) ); |
|
148 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
147 | + $message->numParams(count($items)); |
|
148 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
149 | 149 | $message = $message->escaped(); |
150 | 150 | } |
151 | 151 | |
152 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
153 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
154 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
152 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
153 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
154 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
155 | 155 | } |
156 | 156 | |
157 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
157 | + public function checkConstraintParameters(Constraint $constraint) { |
|
158 | 158 | $constraintParameters = $constraint->getConstraintParameters(); |
159 | 159 | $exceptions = []; |
160 | 160 | try { |
161 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
162 | - } catch ( ConstraintParameterException $e ) { |
|
161 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
162 | + } catch (ConstraintParameterException $e) { |
|
163 | 163 | $exceptions[] = $e; |
164 | 164 | } |
165 | 165 | try { |
166 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
167 | - } catch ( ConstraintParameterException $e ) { |
|
166 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
167 | + } catch (ConstraintParameterException $e) { |
|
168 | 168 | $exceptions[] = $e; |
169 | 169 | } |
170 | 170 | return $exceptions; |
@@ -71,26 +71,26 @@ discard block |
||
71 | 71 | * @throws ConstraintParameterException |
72 | 72 | * @return CheckResult |
73 | 73 | */ |
74 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
74 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
75 | 75 | $parameters = []; |
76 | 76 | $constraintParameters = $constraint->getConstraintParameters(); |
77 | 77 | |
78 | - $format = $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
79 | - $parameters['pattern'] = [ $format ]; |
|
78 | + $format = $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
79 | + $parameters['pattern'] = [$format]; |
|
80 | 80 | |
81 | 81 | $syntaxClarification = $this->constraintParameterParser->parseSyntaxClarificationParameter( |
82 | 82 | $constraintParameters, |
83 | 83 | WikibaseRepo::getDefaultInstance()->getUserLanguage() // TODO make this part of the Context? |
84 | 84 | ); |
85 | - if ( $syntaxClarification !== null ) { |
|
86 | - $parameters['clarification'] = [ $syntaxClarification ]; |
|
85 | + if ($syntaxClarification !== null) { |
|
86 | + $parameters['clarification'] = [$syntaxClarification]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $snak = $context->getSnak(); |
90 | 90 | |
91 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
91 | + if (!$snak instanceof PropertyValueSnak) { |
|
92 | 92 | // nothing to check |
93 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
93 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $dataValue = $snak->getDataValue(); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * error handling: |
100 | 100 | * type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext' |
101 | 101 | */ |
102 | - switch ( $dataValue->getType() ) { |
|
102 | + switch ($dataValue->getType()) { |
|
103 | 103 | case 'string': |
104 | 104 | $text = $dataValue->getValue(); |
105 | 105 | break; |
@@ -108,60 +108,59 @@ discard block |
||
108 | 108 | $text = $dataValue->getText(); |
109 | 109 | break; |
110 | 110 | default: |
111 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
111 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
112 | 112 | ->rawParams( |
113 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
114 | - wfMessage( 'datatypes-type-string' )->escaped(), |
|
115 | - wfMessage( 'datatypes-type-monolingualtext' )->escaped() |
|
113 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
114 | + wfMessage('datatypes-type-string')->escaped(), |
|
115 | + wfMessage('datatypes-type-monolingualtext')->escaped() |
|
116 | 116 | ) |
117 | 117 | ->escaped(); |
118 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
118 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( $this->sparqlHelper !== null && $this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) { |
|
122 | - if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) { |
|
121 | + if ($this->sparqlHelper !== null && $this->config->get('WBQualityConstraintsCheckFormatConstraint')) { |
|
122 | + if ($this->sparqlHelper->matchesRegularExpression($text, $format)) { |
|
123 | 123 | $message = ''; |
124 | 124 | $status = CheckResult::STATUS_COMPLIANCE; |
125 | 125 | } else { |
126 | 126 | $message = wfMessage( |
127 | 127 | $syntaxClarification !== null ? |
128 | - 'wbqc-violation-message-format-clarification' : |
|
129 | - 'wbqc-violation-message-format' |
|
128 | + 'wbqc-violation-message-format-clarification' : 'wbqc-violation-message-format' |
|
130 | 129 | )->rawParams( |
131 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
132 | - $this->constraintParameterRenderer->formatDataValue( new StringValue( $text ), Role::OBJECT ), |
|
133 | - $this->constraintParameterRenderer->formatByRole( Role::CONSTRAINT_PARAMETER_VALUE, |
|
134 | - '<code><nowiki>' . htmlspecialchars( $format ) . '</nowiki></code>' ) |
|
130 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
131 | + $this->constraintParameterRenderer->formatDataValue(new StringValue($text), Role::OBJECT), |
|
132 | + $this->constraintParameterRenderer->formatByRole(Role::CONSTRAINT_PARAMETER_VALUE, |
|
133 | + '<code><nowiki>'.htmlspecialchars($format).'</nowiki></code>') |
|
135 | 134 | ); |
136 | - if ( $syntaxClarification !== null ) { |
|
137 | - $message->params( $syntaxClarification ); |
|
135 | + if ($syntaxClarification !== null) { |
|
136 | + $message->params($syntaxClarification); |
|
138 | 137 | } |
139 | 138 | $message = $message->escaped(); |
140 | 139 | $status = CheckResult::STATUS_VIOLATION; |
141 | 140 | } |
142 | 141 | } else { |
143 | - $message = wfMessage( "wbqc-violation-message-security-reason" ) |
|
144 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) ) |
|
142 | + $message = wfMessage("wbqc-violation-message-security-reason") |
|
143 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM)) |
|
145 | 144 | ->escaped(); |
146 | 145 | $status = CheckResult::STATUS_TODO; |
147 | 146 | } |
148 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
147 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
149 | 148 | } |
150 | 149 | |
151 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
150 | + public function checkConstraintParameters(Constraint $constraint) { |
|
152 | 151 | $constraintParameters = $constraint->getConstraintParameters(); |
153 | 152 | $exceptions = []; |
154 | 153 | try { |
155 | - $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
156 | - } catch ( ConstraintParameterException $e ) { |
|
154 | + $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
155 | + } catch (ConstraintParameterException $e) { |
|
157 | 156 | $exceptions[] = $e; |
158 | 157 | } |
159 | 158 | try { |
160 | 159 | $this->constraintParameterParser->parseSyntaxClarificationParameter( |
161 | 160 | $constraintParameters, |
162 | - Language::factory( 'en' ) // errors are reported independent of language requested |
|
161 | + Language::factory('en') // errors are reported independent of language requested |
|
163 | 162 | ); |
164 | - } catch ( ConstraintParameterException $e ) { |
|
163 | + } catch (ConstraintParameterException $e) { |
|
165 | 164 | $exceptions[] = $e; |
166 | 165 | } |
167 | 166 | return $exceptions; |
@@ -50,22 +50,22 @@ discard block |
||
50 | 50 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
51 | 51 | * @return CheckResult |
52 | 52 | */ |
53 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
54 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
55 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
53 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
54 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
55 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $parameters = []; |
59 | 59 | |
60 | - if ( $this->sparqlHelper !== null ) { |
|
61 | - if ( $context->getType() === 'statement' ) { |
|
60 | + if ($this->sparqlHelper !== null) { |
|
61 | + if ($context->getType() === 'statement') { |
|
62 | 62 | $result = $this->sparqlHelper->findEntitiesWithSameStatement( |
63 | 63 | $context->getSnakStatement(), |
64 | 64 | true // ignore deprecated statements |
65 | 65 | ); |
66 | 66 | } else { |
67 | - if ( $context->getSnak()->getType() !== 'value' ) { |
|
68 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
67 | + if ($context->getSnak()->getType() !== 'value') { |
|
68 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
69 | 69 | } |
70 | 70 | $result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference( |
71 | 71 | $context->getEntity()->getId(), |
@@ -78,29 +78,29 @@ discard block |
||
78 | 78 | $otherEntities = $result->getArray(); |
79 | 79 | $metadata = $result->getMetadata(); |
80 | 80 | |
81 | - if ( $otherEntities === [] ) { |
|
81 | + if ($otherEntities === []) { |
|
82 | 82 | $status = CheckResult::STATUS_COMPLIANCE; |
83 | 83 | $message = ''; |
84 | 84 | } else { |
85 | 85 | $status = CheckResult::STATUS_VIOLATION; |
86 | - $message = wfMessage( 'wbqc-violation-message-unique-value' ) |
|
87 | - ->numParams( count( $otherEntities ) ) |
|
88 | - ->rawParams( $this->constraintParameterRenderer->formatEntityIdList( $otherEntities, Role::SUBJECT ) ) |
|
86 | + $message = wfMessage('wbqc-violation-message-unique-value') |
|
87 | + ->numParams(count($otherEntities)) |
|
88 | + ->rawParams($this->constraintParameterRenderer->formatEntityIdList($otherEntities, Role::SUBJECT)) |
|
89 | 89 | ->escaped(); |
90 | 90 | } |
91 | 91 | } else { |
92 | 92 | $status = CheckResult::STATUS_TODO; |
93 | - $message = wfMessage( "wbqc-violation-message-not-yet-implemented" ) |
|
94 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) ) |
|
93 | + $message = wfMessage("wbqc-violation-message-not-yet-implemented") |
|
94 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM)) |
|
95 | 95 | ->escaped(); |
96 | 96 | $metadata = Metadata::blank(); |
97 | 97 | } |
98 | 98 | |
99 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
100 | - ->withMetadata( $metadata ); |
|
99 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
100 | + ->withMetadata($metadata); |
|
101 | 101 | } |
102 | 102 | |
103 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
103 | + public function checkConstraintParameters(Constraint $constraint) { |
|
104 | 104 | // no parameters |
105 | 105 | return []; |
106 | 106 | } |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string HTML |
66 | 66 | */ |
67 | - public function formatValue( $value ) { |
|
68 | - if ( is_string( $value ) ) { |
|
67 | + public function formatValue($value) { |
|
68 | + if (is_string($value)) { |
|
69 | 69 | // Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as |
70 | 70 | // strings |
71 | - return htmlspecialchars( $value ); |
|
72 | - } elseif ( $value instanceof EntityId ) { |
|
71 | + return htmlspecialchars($value); |
|
72 | + } elseif ($value instanceof EntityId) { |
|
73 | 73 | // Cases like 'Conflicts with' 'property', to which we can link |
74 | - return $this->formatEntityId( $value ); |
|
75 | - } elseif ( $value instanceof ItemIdSnakValue ) { |
|
74 | + return $this->formatEntityId($value); |
|
75 | + } elseif ($value instanceof ItemIdSnakValue) { |
|
76 | 76 | // Cases like EntityId but can also be somevalue or novalue |
77 | - return $this->formatItemIdSnakValue( $value ); |
|
77 | + return $this->formatItemIdSnakValue($value); |
|
78 | 78 | } else { |
79 | 79 | // Cases where we format a DataValue |
80 | - return $this->formatDataValue( $value ); |
|
80 | + return $this->formatDataValue($value); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -88,23 +88,23 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string HTML |
90 | 90 | */ |
91 | - public function formatParameters( $parameters ) { |
|
92 | - if ( $parameters === null || count( $parameters ) == 0 ) { |
|
91 | + public function formatParameters($parameters) { |
|
92 | + if ($parameters === null || count($parameters) == 0) { |
|
93 | 93 | return null; |
94 | 94 | } |
95 | 95 | |
96 | - $valueFormatter = function ( $value ) { |
|
97 | - return $this->formatValue( $value ); |
|
96 | + $valueFormatter = function($value) { |
|
97 | + return $this->formatValue($value); |
|
98 | 98 | }; |
99 | 99 | |
100 | 100 | $formattedParameters = []; |
101 | - foreach ( $parameters as $parameterName => $parameterValue ) { |
|
102 | - $formattedParameterValues = implode( ', ', |
|
103 | - $this->limitArrayLength( array_map( $valueFormatter, $parameterValue ) ) ); |
|
104 | - $formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues ); |
|
101 | + foreach ($parameters as $parameterName => $parameterValue) { |
|
102 | + $formattedParameterValues = implode(', ', |
|
103 | + $this->limitArrayLength(array_map($valueFormatter, $parameterValue))); |
|
104 | + $formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues); |
|
105 | 105 | } |
106 | 106 | |
107 | - return implode( '; ', $formattedParameters ); |
|
107 | + return implode('; ', $formattedParameters); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - private function limitArrayLength( array $array ) { |
|
118 | - if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) { |
|
119 | - $array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH ); |
|
120 | - array_push( $array, '...' ); |
|
117 | + private function limitArrayLength(array $array) { |
|
118 | + if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) { |
|
119 | + $array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH); |
|
120 | + array_push($array, '...'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return $array; |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | * @param string $value HTML |
131 | 131 | * @return string HTML |
132 | 132 | */ |
133 | - public static function formatByRole( $role, $value ) { |
|
134 | - if ( $role === null ) { |
|
133 | + public static function formatByRole($role, $value) { |
|
134 | + if ($role === null) { |
|
135 | 135 | return $value; |
136 | 136 | } |
137 | 137 | |
138 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' |
|
138 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">' |
|
139 | 139 | . $value |
140 | 140 | . '</span>'; |
141 | 141 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param string|null $role one of the Role constants or null |
146 | 146 | * @return string HTML |
147 | 147 | */ |
148 | - public function formatDataValue( DataValue $value, $role = null ) { |
|
149 | - return self::formatByRole( $role, |
|
150 | - $this->dataValueFormatter->format( $value ) ); |
|
148 | + public function formatDataValue(DataValue $value, $role = null) { |
|
149 | + return self::formatByRole($role, |
|
150 | + $this->dataValueFormatter->format($value)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * @param string|null $role one of the Role constants or null |
156 | 156 | * @return string HTML |
157 | 157 | */ |
158 | - public function formatEntityId( EntityId $entityId, $role = null ) { |
|
159 | - return self::formatByRole( $role, |
|
160 | - $this->entityIdLabelFormatter->formatEntityId( $entityId ) ); |
|
158 | + public function formatEntityId(EntityId $entityId, $role = null) { |
|
159 | + return self::formatByRole($role, |
|
160 | + $this->entityIdLabelFormatter->formatEntityId($entityId)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | * @param string|null $role one of the Role constants or null |
170 | 170 | * @return string HTML |
171 | 171 | */ |
172 | - public function formatPropertyId( $propertyId, $role = null ) { |
|
173 | - if ( $propertyId instanceof PropertyId ) { |
|
174 | - return $this->formatEntityId( $propertyId, $role ); |
|
175 | - } elseif ( is_string( $propertyId ) ) { |
|
172 | + public function formatPropertyId($propertyId, $role = null) { |
|
173 | + if ($propertyId instanceof PropertyId) { |
|
174 | + return $this->formatEntityId($propertyId, $role); |
|
175 | + } elseif (is_string($propertyId)) { |
|
176 | 176 | try { |
177 | - return $this->formatEntityId( new PropertyId( $propertyId ), $role ); |
|
178 | - } catch ( InvalidArgumentException $e ) { |
|
179 | - return self::formatByRole( $role, |
|
180 | - htmlspecialchars( $propertyId ) ); |
|
177 | + return $this->formatEntityId(new PropertyId($propertyId), $role); |
|
178 | + } catch (InvalidArgumentException $e) { |
|
179 | + return self::formatByRole($role, |
|
180 | + htmlspecialchars($propertyId)); |
|
181 | 181 | } |
182 | 182 | } else { |
183 | - throw new InvalidArgumentException( '$propertyId must be either PropertyId or string' ); |
|
183 | + throw new InvalidArgumentException('$propertyId must be either PropertyId or string'); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | * @param string|null $role one of the Role constants or null |
194 | 194 | * @return string HTML |
195 | 195 | */ |
196 | - public function formatItemId( $itemId, $role = null ) { |
|
197 | - if ( $itemId instanceof ItemId ) { |
|
198 | - return $this->formatEntityId( $itemId, $role ); |
|
199 | - } elseif ( is_string( $itemId ) ) { |
|
196 | + public function formatItemId($itemId, $role = null) { |
|
197 | + if ($itemId instanceof ItemId) { |
|
198 | + return $this->formatEntityId($itemId, $role); |
|
199 | + } elseif (is_string($itemId)) { |
|
200 | 200 | try { |
201 | - return $this->formatEntityId( new ItemId( $itemId ), $role ); |
|
202 | - } catch ( InvalidArgumentException $e ) { |
|
203 | - return self::formatByRole( $role, |
|
204 | - htmlspecialchars( $itemId ) ); |
|
201 | + return $this->formatEntityId(new ItemId($itemId), $role); |
|
202 | + } catch (InvalidArgumentException $e) { |
|
203 | + return self::formatByRole($role, |
|
204 | + htmlspecialchars($itemId)); |
|
205 | 205 | } |
206 | 206 | } else { |
207 | - throw new InvalidArgumentException( '$itemId must be either ItemId or string' ); |
|
207 | + throw new InvalidArgumentException('$itemId must be either ItemId or string'); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | * @param string|null $role one of the Role constants or null |
216 | 216 | * @return string HTML |
217 | 217 | */ |
218 | - public function formatItemIdSnakValue( ItemIdSnakValue $value, $role = null ) { |
|
219 | - switch ( true ) { |
|
218 | + public function formatItemIdSnakValue(ItemIdSnakValue $value, $role = null) { |
|
219 | + switch (true) { |
|
220 | 220 | case $value->isValue(): |
221 | - return $this->formatEntityId( $value->getItemId(), $role ); |
|
221 | + return $this->formatEntityId($value->getItemId(), $role); |
|
222 | 222 | case $value->isSomeValue(): |
223 | - return self::formatByRole( $role, |
|
223 | + return self::formatByRole($role, |
|
224 | 224 | '<span class="wikibase-snakview-variation-somevaluesnak">' |
225 | - . wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped() |
|
226 | - . '</span>' ); |
|
225 | + . wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped() |
|
226 | + . '</span>'); |
|
227 | 227 | case $value->isNoValue(): |
228 | - return self::formatByRole( $role, |
|
228 | + return self::formatByRole($role, |
|
229 | 229 | '<span class="wikibase-snakview-variation-novaluesnak">' |
230 | - . wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped() |
|
231 | - . '</span>' ); |
|
230 | + . wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped() |
|
231 | + . '</span>'); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @param string|null $role one of the Role constants or null |
240 | 240 | * @return string HTML |
241 | 241 | */ |
242 | - public function formatConstraintScope( $scope, $role = null ) { |
|
243 | - switch ( $scope ) { |
|
242 | + public function formatConstraintScope($scope, $role = null) { |
|
243 | + switch ($scope) { |
|
244 | 244 | case Context::TYPE_STATEMENT: |
245 | 245 | $itemId = $this->config->get( |
246 | 246 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | // callers should never let this happen, but if it does happen, |
261 | 261 | // showing “unknown value” seems reasonable |
262 | 262 | // @codeCoverageIgnoreStart |
263 | - return $this->formatItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
263 | + return $this->formatItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
264 | 264 | // @codeCoverageIgnoreEnd |
265 | 265 | } |
266 | - return $this->formatItemId( $itemId, $role ); |
|
266 | + return $this->formatItemId($itemId, $role); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -276,15 +276,15 @@ discard block |
||
276 | 276 | * @param string|null $role one of the Role constants or null |
277 | 277 | * @return string[] HTML |
278 | 278 | */ |
279 | - public function formatPropertyIdList( array $propertyIds, $role = null ) { |
|
280 | - if ( empty( $propertyIds ) ) { |
|
281 | - return [ '<ul></ul>' ]; |
|
279 | + public function formatPropertyIdList(array $propertyIds, $role = null) { |
|
280 | + if (empty($propertyIds)) { |
|
281 | + return ['<ul></ul>']; |
|
282 | 282 | } |
283 | - $propertyIds = $this->limitArrayLength( $propertyIds ); |
|
284 | - $formattedPropertyIds = array_map( [ $this, "formatPropertyId" ], $propertyIds, array_fill( 0, count( $propertyIds ), $role ) ); |
|
283 | + $propertyIds = $this->limitArrayLength($propertyIds); |
|
284 | + $formattedPropertyIds = array_map([$this, "formatPropertyId"], $propertyIds, array_fill(0, count($propertyIds), $role)); |
|
285 | 285 | array_unshift( |
286 | 286 | $formattedPropertyIds, |
287 | - '<ul><li>' . implode( '</li><li>', $formattedPropertyIds ) . '</li></ul>' |
|
287 | + '<ul><li>'.implode('</li><li>', $formattedPropertyIds).'</li></ul>' |
|
288 | 288 | ); |
289 | 289 | return $formattedPropertyIds; |
290 | 290 | } |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | * @param string|null $role one of the Role constants or null |
300 | 300 | * @return string[] HTML |
301 | 301 | */ |
302 | - public function formatItemIdList( array $itemIds, $role = null ) { |
|
303 | - if ( empty( $itemIds ) ) { |
|
304 | - return [ '<ul></ul>' ]; |
|
302 | + public function formatItemIdList(array $itemIds, $role = null) { |
|
303 | + if (empty($itemIds)) { |
|
304 | + return ['<ul></ul>']; |
|
305 | 305 | } |
306 | - $itemIds = $this->limitArrayLength( $itemIds ); |
|
307 | - $formattedItemIds = array_map( [ $this, "formatItemId" ], $itemIds, array_fill( 0, count( $itemIds ), $role ) ); |
|
306 | + $itemIds = $this->limitArrayLength($itemIds); |
|
307 | + $formattedItemIds = array_map([$this, "formatItemId"], $itemIds, array_fill(0, count($itemIds), $role)); |
|
308 | 308 | array_unshift( |
309 | 309 | $formattedItemIds, |
310 | - '<ul><li>' . implode( '</li><li>', $formattedItemIds ) . '</li></ul>' |
|
310 | + '<ul><li>'.implode('</li><li>', $formattedItemIds).'</li></ul>' |
|
311 | 311 | ); |
312 | 312 | return $formattedItemIds; |
313 | 313 | } |
@@ -322,23 +322,23 @@ discard block |
||
322 | 322 | * @param string|null $role one of the Role constants or null |
323 | 323 | * @return string[] HTML |
324 | 324 | */ |
325 | - public function formatEntityIdList( array $entityIds, $role = null ) { |
|
326 | - if ( empty( $entityIds ) ) { |
|
327 | - return [ '<ul></ul>' ]; |
|
325 | + public function formatEntityIdList(array $entityIds, $role = null) { |
|
326 | + if (empty($entityIds)) { |
|
327 | + return ['<ul></ul>']; |
|
328 | 328 | } |
329 | 329 | $formattedEntityIds = []; |
330 | - foreach ( $entityIds as $entityId ) { |
|
331 | - if ( count( $formattedEntityIds ) >= self::MAX_PARAMETER_ARRAY_LENGTH ) { |
|
330 | + foreach ($entityIds as $entityId) { |
|
331 | + if (count($formattedEntityIds) >= self::MAX_PARAMETER_ARRAY_LENGTH) { |
|
332 | 332 | $formattedEntityIds[] = '...'; |
333 | 333 | break; |
334 | 334 | } |
335 | - if ( $entityId !== null ) { |
|
336 | - $formattedEntityIds[] = $this->formatEntityId( $entityId, $role ); |
|
335 | + if ($entityId !== null) { |
|
336 | + $formattedEntityIds[] = $this->formatEntityId($entityId, $role); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | array_unshift( |
340 | 340 | $formattedEntityIds, |
341 | - '<ul><li>' . implode( '</li><li>', $formattedEntityIds ) . '</li></ul>' |
|
341 | + '<ul><li>'.implode('</li><li>', $formattedEntityIds).'</li></ul>' |
|
342 | 342 | ); |
343 | 343 | return $formattedEntityIds; |
344 | 344 | } |
@@ -353,24 +353,24 @@ discard block |
||
353 | 353 | * @param string|null $role one of the Role constants or null |
354 | 354 | * @return string[] HTML |
355 | 355 | */ |
356 | - public function formatItemIdSnakValueList( array $values, $role = null ) { |
|
357 | - if ( empty( $values ) ) { |
|
358 | - return [ '<ul></ul>' ]; |
|
356 | + public function formatItemIdSnakValueList(array $values, $role = null) { |
|
357 | + if (empty($values)) { |
|
358 | + return ['<ul></ul>']; |
|
359 | 359 | } |
360 | - $values = $this->limitArrayLength( $values ); |
|
360 | + $values = $this->limitArrayLength($values); |
|
361 | 361 | $formattedValues = array_map( |
362 | - function( $value ) use ( $role ) { |
|
363 | - if ( $value === '...' ) { |
|
362 | + function($value) use ($role) { |
|
363 | + if ($value === '...') { |
|
364 | 364 | return '...'; |
365 | 365 | } else { |
366 | - return $this->formatItemIdSnakValue( $value, $role ); |
|
366 | + return $this->formatItemIdSnakValue($value, $role); |
|
367 | 367 | } |
368 | 368 | }, |
369 | 369 | $values |
370 | 370 | ); |
371 | 371 | array_unshift( |
372 | 372 | $formattedValues, |
373 | - '<ul><li>' . implode( '</li><li>', $formattedValues ) . '</li></ul>' |
|
373 | + '<ul><li>'.implode('</li><li>', $formattedValues).'</li></ul>' |
|
374 | 374 | ); |
375 | 375 | return $formattedValues; |
376 | 376 | } |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | * @param string|null $role one of the Role constants or null |
386 | 386 | * @return string[] HTML |
387 | 387 | */ |
388 | - public function formatConstraintScopeList( array $scopes, $role = null ) { |
|
389 | - if ( empty( $scopes ) ) { |
|
390 | - return [ '<ul></ul>' ]; |
|
388 | + public function formatConstraintScopeList(array $scopes, $role = null) { |
|
389 | + if (empty($scopes)) { |
|
390 | + return ['<ul></ul>']; |
|
391 | 391 | } |
392 | - $scopes = $this->limitArrayLength( $scopes ); |
|
392 | + $scopes = $this->limitArrayLength($scopes); |
|
393 | 393 | $formattedScopes = array_map( |
394 | - function( $scope ) use ( $role ) { |
|
395 | - if ( $scope === '...' ) { |
|
394 | + function($scope) use ($role) { |
|
395 | + if ($scope === '...') { |
|
396 | 396 | return '...'; |
397 | 397 | } else { |
398 | - return $this->formatConstraintScope( $scope, $role ); |
|
398 | + return $this->formatConstraintScope($scope, $role); |
|
399 | 399 | } |
400 | 400 | }, |
401 | 401 | $scopes |
402 | 402 | ); |
403 | 403 | array_unshift( |
404 | 404 | $formattedScopes, |
405 | - '<ul><li>' . implode( '</li><li>', $formattedScopes ) . '</li></ul>' |
|
405 | + '<ul><li>'.implode('</li><li>', $formattedScopes).'</li></ul>' |
|
406 | 406 | ); |
407 | 407 | return $formattedScopes; |
408 | 408 | } |
@@ -35,16 +35,16 @@ |
||
35 | 35 | ]; |
36 | 36 | } |
37 | 37 | |
38 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
39 | - if ( $context->getType() === Context::TYPE_STATEMENT ) { |
|
40 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '' ); |
|
38 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
39 | + if ($context->getType() === Context::TYPE_STATEMENT) { |
|
40 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE, ''); |
|
41 | 41 | } else { |
42 | - $message = wfMessage( 'wbqc-violation-message-valueOnly' )->escaped(); |
|
43 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
42 | + $message = wfMessage('wbqc-violation-message-valueOnly')->escaped(); |
|
43 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
47 | + public function checkConstraintParameters(Constraint $constraint) { |
|
48 | 48 | // no parameters |
49 | 49 | return []; |
50 | 50 | } |
@@ -35,16 +35,16 @@ |
||
35 | 35 | ]; |
36 | 36 | } |
37 | 37 | |
38 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
39 | - if ( $context->getType() === Context::TYPE_REFERENCE ) { |
|
40 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '' ); |
|
38 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
39 | + if ($context->getType() === Context::TYPE_REFERENCE) { |
|
40 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE, ''); |
|
41 | 41 | } else { |
42 | - $message = wfMessage( 'wbqc-violation-message-reference' )->escaped(); |
|
43 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
42 | + $message = wfMessage('wbqc-violation-message-reference')->escaped(); |
|
43 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
47 | + public function checkConstraintParameters(Constraint $constraint) { |
|
48 | 48 | // no parameters |
49 | 49 | return []; |
50 | 50 | } |