@@ -16,8 +16,8 @@ |
||
16 | 16 | /** |
17 | 17 | * @param string $message HTML |
18 | 18 | */ |
19 | - public function __construct( $message ) { |
|
20 | - parent::__construct( $message ); |
|
19 | + public function __construct($message) { |
|
20 | + parent::__construct($message); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | * |
25 | 25 | * @return int[] |
26 | 26 | */ |
27 | - public function getPropertyCount( StatementList $statements ) { |
|
28 | - if ( !isset( $this->propertyCount ) ) { |
|
27 | + public function getPropertyCount(StatementList $statements) { |
|
28 | + if (!isset($this->propertyCount)) { |
|
29 | 29 | $this->propertyCount = []; |
30 | 30 | |
31 | 31 | /** @var Statement $statement */ |
32 | - foreach ( $statements as $statement ) { |
|
32 | + foreach ($statements as $statement) { |
|
33 | 33 | $counter = $statement->getRank() === Statement::RANK_DEPRECATED ? 0 : 1; |
34 | - if ( array_key_exists( $statement->getPropertyId()->getSerialization(), $this->propertyCount ) ) { |
|
34 | + if (array_key_exists($statement->getPropertyId()->getSerialization(), $this->propertyCount)) { |
|
35 | 35 | $this->propertyCount[$statement->getPropertyId()->getSerialization()] += $counter; |
36 | 36 | } else { |
37 | 37 | $this->propertyCount[$statement->getPropertyId()->getSerialization()] = $counter; |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | StatementList $statementList, |
29 | 29 | PropertyId $propertyId |
30 | 30 | ) { |
31 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
32 | - if ( $statementListByPropertyId->isEmpty() ) { |
|
31 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
32 | + if ($statementListByPropertyId->isEmpty()) { |
|
33 | 33 | return null; |
34 | 34 | } else { |
35 | 35 | return $statementListByPropertyId->toArray()[0]; |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | PropertyId $propertyId, |
51 | 51 | EntityId $value |
52 | 52 | ) { |
53 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
53 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
54 | 54 | /** @var Statement $statement */ |
55 | - foreach ( $statementListByPropertyId as $statement ) { |
|
55 | + foreach ($statementListByPropertyId as $statement) { |
|
56 | 56 | $snak = $statement->getMainSnak(); |
57 | - if ( $snak->getType() === 'value' ) { |
|
57 | + if ($snak->getType() === 'value') { |
|
58 | 58 | $dataValue = $snak->getDataValue(); |
59 | 59 | if ( |
60 | 60 | $dataValue->getType() === 'wikibase-entityid' && |
61 | - $dataValue->getEntityId()->equals( $value ) |
|
61 | + $dataValue->getEntityId()->equals($value) |
|
62 | 62 | ) { |
63 | 63 | return $statement; |
64 | 64 | } |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | PropertyId $propertyId, |
82 | 82 | array $values |
83 | 83 | ) { |
84 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
84 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
85 | 85 | /** @var Statement $statement */ |
86 | - foreach ( $statementListByPropertyId as $statement ) { |
|
86 | + foreach ($statementListByPropertyId as $statement) { |
|
87 | 87 | $snak = $statement->getMainSnak(); |
88 | - foreach ( $values as $value ) { |
|
89 | - if ( $value->matchesSnak( $snak ) ) { |
|
88 | + foreach ($values as $value) { |
|
89 | + if ($value->matchesSnak($snak)) { |
|
90 | 90 | return $statement; |
91 | 91 | } |
92 | 92 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | $this->dataFactory = $dataFactory; |
49 | 49 | $this->logger = $logger; |
50 | 50 | $this->constraintCheckDurationLimits = [ |
51 | - 'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ), |
|
52 | - 'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ), |
|
51 | + 'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'), |
|
52 | + 'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'), |
|
53 | 53 | ]; |
54 | 54 | } |
55 | 55 | |
@@ -75,41 +75,41 @@ discard block |
||
75 | 75 | $durationSeconds, |
76 | 76 | $method |
77 | 77 | ) { |
78 | - $constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 ); |
|
78 | + $constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1); |
|
79 | 79 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
80 | 80 | |
81 | 81 | $this->dataFactory->timing( |
82 | - 'wikibase.quality.constraints.check.timing.' . |
|
83 | - $constraintTypeItemId . '-' . |
|
82 | + 'wikibase.quality.constraints.check.timing.'. |
|
83 | + $constraintTypeItemId.'-'. |
|
84 | 84 | $constraintCheckerClassShortName, |
85 | 85 | $durationSeconds * 1000 |
86 | 86 | ); |
87 | 87 | |
88 | 88 | // find the longest limit (and associated log level) that the duration exceeds |
89 | - foreach ( $this->constraintCheckDurationLimits as $level => $limit ) { |
|
89 | + foreach ($this->constraintCheckDurationLimits as $level => $limit) { |
|
90 | 90 | if ( |
91 | 91 | // duration exceeds this limit |
92 | - isset( $limit ) && $durationSeconds > $limit && |
|
92 | + isset($limit) && $durationSeconds > $limit && |
|
93 | 93 | // this limit is longer than previous longest limit |
94 | - ( !isset( $limitSeconds ) || $limit > $limitSeconds ) |
|
94 | + (!isset($limitSeconds) || $limit > $limitSeconds) |
|
95 | 95 | ) { |
96 | 96 | $limitSeconds = $limit; |
97 | 97 | $logLevel = $level; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - if ( !isset( $limitSeconds ) ) { |
|
101 | + if (!isset($limitSeconds)) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
104 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
105 | 105 | // TODO log less details but still log something |
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $this->logger->log( |
110 | 110 | $logLevel, |
111 | - 'Constraint check with {constraintCheckerClassShortName} ' . |
|
112 | - 'took longer than {limitSeconds} second(s) ' . |
|
111 | + 'Constraint check with {constraintCheckerClassShortName} '. |
|
112 | + 'took longer than {limitSeconds} second(s) '. |
|
113 | 113 | '(duration: {durationSeconds} seconds).', |
114 | 114 | [ |
115 | 115 | 'method' => $method, |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | public function getDataValue() { |
147 | 147 | $mainSnak = $this->context->getSnak(); |
148 | 148 | |
149 | - if ( $mainSnak instanceof PropertyValueSnak ) { |
|
149 | + if ($mainSnak instanceof PropertyValueSnak) { |
|
150 | 150 | return $mainSnak->getDataValue(); |
151 | 151 | } |
152 | 152 | |
153 | - throw new LogicException( 'Cannot get DataValue, Snak is of type ' . $this->getSnakType() . '.' ); |
|
153 | + throw new LogicException('Cannot get DataValue, Snak is of type '.$this->getSnakType().'.'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string $key |
179 | 179 | * @param string $value |
180 | 180 | */ |
181 | - public function addParameter( $key, $value ) { |
|
181 | + public function addParameter($key, $value) { |
|
182 | 182 | $this->parameters[$key][] = $value; |
183 | 183 | } |
184 | 184 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /** |
193 | 193 | * @param string $status |
194 | 194 | */ |
195 | - public function setStatus( $status ) { |
|
195 | + public function setStatus($status) { |
|
196 | 196 | $this->status = $status; |
197 | 197 | } |
198 | 198 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param Metadata $cm |
208 | 208 | * @return self |
209 | 209 | */ |
210 | - public function withMetadata( Metadata $cm ) { |
|
210 | + public function withMetadata(Metadata $cm) { |
|
211 | 211 | $this->metadata = $cm; |
212 | 212 | return $this; |
213 | 213 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return CheckResult |
62 | 62 | */ |
63 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
64 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
65 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
63 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
64 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
65 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
66 | 66 | } |
67 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
68 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK ); |
|
67 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
68 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $parameters = []; |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | $snak = $context->getSnak(); |
74 | 74 | $propertyId = $context->getSnak()->getPropertyId(); |
75 | 75 | |
76 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
76 | + if (!$snak instanceof PropertyValueSnak) { |
|
77 | 77 | // nothing to check |
78 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
78 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $dataValue = $snak->getDataValue(); |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | * error handling: |
85 | 85 | * type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid' |
86 | 86 | */ |
87 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
88 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
87 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
88 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
89 | 89 | ->rawParams( |
90 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
90 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
91 | 91 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
92 | 92 | ) |
93 | 93 | ->escaped(); |
94 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
94 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
95 | 95 | } |
96 | 96 | /** @var EntityIdValue $dataValue */ |
97 | 97 | |
98 | 98 | $targetEntityId = $dataValue->getEntityId(); |
99 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
100 | - if ( $targetEntity === null ) { |
|
101 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
102 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
99 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
100 | + if ($targetEntity === null) { |
|
101 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
102 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -107,26 +107,26 @@ discard block |
||
107 | 107 | $propertyId, |
108 | 108 | $context->getEntity()->getId() |
109 | 109 | ); |
110 | - if ( $symmetricStatement !== null ) { |
|
110 | + if ($symmetricStatement !== null) { |
|
111 | 111 | $message = ''; |
112 | 112 | $status = CheckResult::STATUS_COMPLIANCE; |
113 | 113 | } else { |
114 | - $message = wfMessage( 'wbqc-violation-message-symmetric' ) |
|
114 | + $message = wfMessage('wbqc-violation-message-symmetric') |
|
115 | 115 | ->rawParams( |
116 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
117 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
118 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
116 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
117 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
118 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
119 | 119 | ) |
120 | 120 | ->escaped(); |
121 | 121 | $status = CheckResult::STATUS_VIOLATION; |
122 | 122 | } |
123 | 123 | |
124 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
125 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
126 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
124 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
125 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
126 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
127 | 127 | } |
128 | 128 | |
129 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
129 | + public function checkConstraintParameters(Constraint $constraint) { |
|
130 | 130 | // no parameters |
131 | 131 | return []; |
132 | 132 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | private $metadata; |
22 | 22 | |
23 | - public function __construct( array $array, Metadata $metadata ) { |
|
23 | + public function __construct(array $array, Metadata $metadata) { |
|
24 | 24 | $this->array = $array; |
25 | 25 | $this->metadata = $metadata; |
26 | 26 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param EntityId $entityId An entity ID from which the value was derived. |
30 | 30 | * @return self Indication that a value is was derived from the entity with the given ID. |
31 | 31 | */ |
32 | - public static function ofEntityId( EntityId $entityId ) { |
|
32 | + public static function ofEntityId(EntityId $entityId) { |
|
33 | 33 | $ret = new self; |
34 | 34 | $ret->entityIds[] = $entityId; |
35 | 35 | return $ret; |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @param self[] $metadatas |
40 | 40 | * @return self |
41 | 41 | */ |
42 | - public static function merge( array $metadatas ) { |
|
43 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
42 | + public static function merge(array $metadatas) { |
|
43 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
44 | 44 | $ret = new self; |
45 | - foreach ( $metadatas as $metadata ) { |
|
46 | - $ret->entityIds = array_merge( $ret->entityIds, $metadata->entityIds ); |
|
45 | + foreach ($metadatas as $metadata) { |
|
46 | + $ret->entityIds = array_merge($ret->entityIds, $metadata->entityIds); |
|
47 | 47 | } |
48 | 48 | return $ret; |
49 | 49 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param bool $bool |
25 | 25 | * @param Metadata $metadata |
26 | 26 | */ |
27 | - public function __construct( $bool, Metadata $metadata ) { |
|
27 | + public function __construct($bool, Metadata $metadata) { |
|
28 | 28 | $this->bool = $bool; |
29 | 29 | $this->metadata = $metadata; |
30 | 30 | } |