@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | EntityDocument $entity, |
24 | 24 | Statement $statement |
25 | 25 | ) { |
26 | - parent::__construct( $entity, $statement->getMainSnak() ); |
|
26 | + parent::__construct($entity, $statement->getMainSnak()); |
|
27 | 27 | $this->statement = $statement; |
28 | 28 | } |
29 | 29 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | return $this->statement; |
40 | 40 | } |
41 | 41 | |
42 | - protected function &getMainArray( array &$container ) { |
|
42 | + protected function &getMainArray(array &$container) { |
|
43 | 43 | $statementArray = &$this->getStatementArray( |
44 | 44 | $container, |
45 | 45 | $this->entity->getId()->getSerialization(), |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | $this->statement->getGuid() |
48 | 48 | ); |
49 | 49 | |
50 | - if ( !array_key_exists( 'mainsnak', $statementArray ) ) { |
|
51 | - $statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ]; |
|
50 | + if (!array_key_exists('mainsnak', $statementArray)) { |
|
51 | + $statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()]; |
|
52 | 52 | } |
53 | 53 | $mainsnakArray = &$statementArray['mainsnak']; |
54 | 54 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | Statement $statement, |
22 | 22 | Snak $snak |
23 | 23 | ) { |
24 | - parent::__construct( $entity, $snak ); |
|
24 | + parent::__construct($entity, $snak); |
|
25 | 25 | $this->statement = $statement; |
26 | 26 | } |
27 | 27 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return self::TYPE_QUALIFIER; |
30 | 30 | } |
31 | 31 | |
32 | - protected function &getMainArray( array &$container ) { |
|
32 | + protected function &getMainArray(array &$container) { |
|
33 | 33 | $statementArray = &$this->getStatementArray( |
34 | 34 | $container, |
35 | 35 | $this->entity->getId()->getSerialization(), |
@@ -37,25 +37,25 @@ discard block |
||
37 | 37 | $this->statement->getGuid() |
38 | 38 | ); |
39 | 39 | |
40 | - if ( !array_key_exists( 'qualifiers', $statementArray ) ) { |
|
40 | + if (!array_key_exists('qualifiers', $statementArray)) { |
|
41 | 41 | $statementArray['qualifiers'] = []; |
42 | 42 | } |
43 | 43 | $qualifiersArray = &$statementArray['qualifiers']; |
44 | 44 | |
45 | 45 | $propertyId = $this->getSnak()->getPropertyId()->getSerialization(); |
46 | - if ( !array_key_exists( $propertyId, $qualifiersArray ) ) { |
|
46 | + if (!array_key_exists($propertyId, $qualifiersArray)) { |
|
47 | 47 | $qualifiersArray[$propertyId] = []; |
48 | 48 | } |
49 | 49 | $propertyArray = &$qualifiersArray[$propertyId]; |
50 | 50 | |
51 | - foreach ( $propertyArray as &$potentialQualifierArray ) { |
|
52 | - if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) { |
|
51 | + foreach ($propertyArray as &$potentialQualifierArray) { |
|
52 | + if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) { |
|
53 | 53 | $qualifierArray = &$potentialQualifierArray; |
54 | 54 | break; |
55 | 55 | } |
56 | 56 | } |
57 | - if ( !isset( $qualifierArray ) ) { |
|
58 | - $qualifierArray = [ 'hash' => $this->getSnak()->getHash() ]; |
|
57 | + if (!isset($qualifierArray)) { |
|
58 | + $qualifierArray = ['hash' => $this->getSnak()->getHash()]; |
|
59 | 59 | $propertyArray[] = &$qualifierArray; |
60 | 60 | } |
61 | 61 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | Reference $reference, |
29 | 29 | Snak $snak |
30 | 30 | ) { |
31 | - parent::__construct( $entity, $snak ); |
|
31 | + parent::__construct($entity, $snak); |
|
32 | 32 | $this->statement = $statement; |
33 | 33 | $this->reference = $reference; |
34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | return self::TYPE_REFERENCE; |
38 | 38 | } |
39 | 39 | |
40 | - protected function &getMainArray( array &$container ) { |
|
40 | + protected function &getMainArray(array &$container) { |
|
41 | 41 | $statementArray = &$this->getStatementArray( |
42 | 42 | $container, |
43 | 43 | $this->entity->getId()->getSerialization(), |
@@ -45,38 +45,38 @@ discard block |
||
45 | 45 | $this->statement->getGuid() |
46 | 46 | ); |
47 | 47 | |
48 | - if ( !array_key_exists( 'references', $statementArray ) ) { |
|
48 | + if (!array_key_exists('references', $statementArray)) { |
|
49 | 49 | $statementArray['references'] = []; |
50 | 50 | } |
51 | 51 | $referencesArray = &$statementArray['references']; |
52 | 52 | |
53 | - foreach ( $referencesArray as &$potentialReferenceArray ) { |
|
54 | - if ( $potentialReferenceArray['hash'] === $this->reference->getHash() ) { |
|
53 | + foreach ($referencesArray as &$potentialReferenceArray) { |
|
54 | + if ($potentialReferenceArray['hash'] === $this->reference->getHash()) { |
|
55 | 55 | $referenceArray = &$potentialReferenceArray; |
56 | 56 | break; |
57 | 57 | } |
58 | 58 | } |
59 | - if ( !isset( $referenceArray ) ) { |
|
60 | - $referenceArray = [ 'hash' => $this->reference->getHash(), 'snaks' => [] ]; |
|
59 | + if (!isset($referenceArray)) { |
|
60 | + $referenceArray = ['hash' => $this->reference->getHash(), 'snaks' => []]; |
|
61 | 61 | $referencesArray[] = &$referenceArray; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $snaksArray = &$referenceArray['snaks']; |
65 | 65 | |
66 | 66 | $propertyId = $this->getSnak()->getPropertyId()->getSerialization(); |
67 | - if ( !array_key_exists( $propertyId, $snaksArray ) ) { |
|
67 | + if (!array_key_exists($propertyId, $snaksArray)) { |
|
68 | 68 | $snaksArray[$propertyId] = []; |
69 | 69 | } |
70 | 70 | $propertyArray = &$snaksArray[$propertyId]; |
71 | 71 | |
72 | - foreach ( $propertyArray as &$potentialSnakArray ) { |
|
73 | - if ( $potentialSnakArray['hash'] === $this->getSnak()->getHash() ) { |
|
72 | + foreach ($propertyArray as &$potentialSnakArray) { |
|
73 | + if ($potentialSnakArray['hash'] === $this->getSnak()->getHash()) { |
|
74 | 74 | $snakArray = &$potentialSnakArray; |
75 | 75 | break; |
76 | 76 | } |
77 | 77 | } |
78 | - if ( !isset( $snakArray ) ) { |
|
79 | - $snakArray = [ 'hash' => $this->getSnak()->getHash() ]; |
|
78 | + if (!isset($snakArray)) { |
|
79 | + $snakArray = ['hash' => $this->getSnak()->getHash()]; |
|
80 | 80 | $propertyArray[] = &$snakArray; |
81 | 81 | } |
82 | 82 |
@@ -25,22 +25,22 @@ |
||
25 | 25 | */ |
26 | 26 | const NULL_PROPERTY_ID = 'P2147483647'; |
27 | 27 | |
28 | - public function __construct( Context $context ) { |
|
28 | + public function __construct(Context $context) { |
|
29 | 29 | $constraint = new Constraint( |
30 | 30 | 'null', |
31 | - new PropertyId( self::NULL_PROPERTY_ID ), |
|
31 | + new PropertyId(self::NULL_PROPERTY_ID), |
|
32 | 32 | 'none', |
33 | 33 | [] |
34 | 34 | ); |
35 | - parent::__construct( $context, $constraint ); |
|
35 | + parent::__construct($context, $constraint); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getConstraint() { |
39 | - throw new DomainException( 'NullResult holds no constraint' ); |
|
39 | + throw new DomainException('NullResult holds no constraint'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getConstraintId() { |
43 | - throw new DomainException( 'NullResult holds no constraint' ); |
|
43 | + throw new DomainException('NullResult holds no constraint'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @throws ConstraintParameterException if the constraint parameters are invalid |
23 | 23 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
24 | 24 | */ |
25 | - public function checkConstraint( Context $context, Constraint $constraint ); |
|
25 | + public function checkConstraint(Context $context, Constraint $constraint); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Check if the constraint parameters of $constraint are valid. |
@@ -33,6 +33,6 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return ConstraintParameterException[] |
35 | 35 | */ |
36 | - public function checkConstraintParameters( Constraint $constraint ); |
|
36 | + public function checkConstraintParameters(Constraint $constraint); |
|
37 | 37 | |
38 | 38 | } |
@@ -52,46 +52,46 @@ |
||
52 | 52 | * |
53 | 53 | * @return CheckResult |
54 | 54 | */ |
55 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
56 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
57 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
55 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
56 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
57 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
58 | 58 | } |
59 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
60 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK ); |
|
59 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
60 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $parameters = []; |
64 | 64 | $constraintParameters = $constraint->getConstraintParameters(); |
65 | 65 | |
66 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
67 | - $parameters['property'] = [ $propertyId ]; |
|
66 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
67 | + $parameters['property'] = [$propertyId]; |
|
68 | 68 | |
69 | - $message = wfMessage( "wbqc-violation-message-mandatory-qualifier" ) |
|
69 | + $message = wfMessage("wbqc-violation-message-mandatory-qualifier") |
|
70 | 70 | ->rawParams( |
71 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
72 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE ) |
|
71 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
72 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE) |
|
73 | 73 | ) |
74 | 74 | ->escaped(); |
75 | 75 | $status = CheckResult::STATUS_VIOLATION; |
76 | 76 | |
77 | 77 | /** @var Snak $qualifier */ |
78 | - foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) { |
|
79 | - if ( $propertyId->equals( $qualifier->getPropertyId() ) ) { |
|
78 | + foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) { |
|
79 | + if ($propertyId->equals($qualifier->getPropertyId())) { |
|
80 | 80 | $message = ''; |
81 | 81 | $status = CheckResult::STATUS_COMPLIANCE; |
82 | 82 | break; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
86 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
87 | 87 | } |
88 | 88 | |
89 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
89 | + public function checkConstraintParameters(Constraint $constraint) { |
|
90 | 90 | $constraintParameters = $constraint->getConstraintParameters(); |
91 | 91 | $exceptions = []; |
92 | 92 | try { |
93 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
94 | - } catch ( ConstraintParameterException $e ) { |
|
93 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
94 | + } catch (ConstraintParameterException $e) { |
|
95 | 95 | $exceptions[] = $e; |
96 | 96 | } |
97 | 97 | return $exceptions; |
@@ -70,22 +70,22 @@ discard block |
||
70 | 70 | * |
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 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
77 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
78 | 78 | // TODO T175562 |
79 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK ); |
|
79 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $parameters = []; |
83 | 83 | $constraintParameters = $constraint->getConstraintParameters(); |
84 | 84 | |
85 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
86 | - $parameters['property'] = [ $propertyId ]; |
|
85 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
86 | + $parameters['property'] = [$propertyId]; |
|
87 | 87 | |
88 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
88 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
89 | 89 | $parameters['items'] = $items; |
90 | 90 | |
91 | 91 | /* |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | * a) a property only |
94 | 94 | * b) a property and a number of items (each combination of property and item forming an individual claim) |
95 | 95 | */ |
96 | - if ( $items === [] ) { |
|
96 | + if ($items === []) { |
|
97 | 97 | $offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
98 | 98 | $context->getEntity()->getStatements(), |
99 | 99 | $propertyId |
100 | 100 | ); |
101 | - if ( $offendingStatement !== null ) { |
|
102 | - $message = wfMessage( "wbqc-violation-message-conflicts-with-property" ) |
|
101 | + if ($offendingStatement !== null) { |
|
102 | + $message = wfMessage("wbqc-violation-message-conflicts-with-property") |
|
103 | 103 | ->rawParams( |
104 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
105 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
104 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
105 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
106 | 106 | ) |
107 | 107 | ->escaped(); |
108 | 108 | $status = CheckResult::STATUS_VIOLATION; |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | $propertyId, |
117 | 117 | $items |
118 | 118 | ); |
119 | - if ( $offendingStatement !== null ) { |
|
120 | - $offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() ); |
|
121 | - $message = wfMessage( "wbqc-violation-message-conflicts-with-claim" ) |
|
119 | + if ($offendingStatement !== null) { |
|
120 | + $offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak()); |
|
121 | + $message = wfMessage("wbqc-violation-message-conflicts-with-claim") |
|
122 | 122 | ->rawParams( |
123 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
124 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
125 | - $this->constraintParameterRenderer->formatItemIdSnakValue( $offendingValue, Role::OBJECT ) |
|
123 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
124 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
125 | + $this->constraintParameterRenderer->formatItemIdSnakValue($offendingValue, Role::OBJECT) |
|
126 | 126 | ) |
127 | 127 | ->escaped(); |
128 | 128 | $status = CheckResult::STATUS_VIOLATION; |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
135 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
136 | 136 | } |
137 | 137 | |
138 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
138 | + public function checkConstraintParameters(Constraint $constraint) { |
|
139 | 139 | $constraintParameters = $constraint->getConstraintParameters(); |
140 | 140 | $exceptions = []; |
141 | 141 | try { |
142 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
143 | - } catch ( ConstraintParameterException $e ) { |
|
142 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
143 | + } catch (ConstraintParameterException $e) { |
|
144 | 144 | $exceptions[] = $e; |
145 | 145 | } |
146 | 146 | try { |
147 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
148 | - } catch ( ConstraintParameterException $e ) { |
|
147 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
148 | + } catch (ConstraintParameterException $e) { |
|
149 | 149 | $exceptions[] = $e; |
150 | 150 | } |
151 | 151 | return $exceptions; |
@@ -35,33 +35,33 @@ |
||
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 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
42 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
43 | 43 | // TODO T175566 |
44 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK ); |
|
44 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_MAIN_SNAK); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $propertyId = $context->getSnak()->getPropertyId(); |
48 | 48 | |
49 | 49 | $parameters = []; |
50 | 50 | |
51 | - $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount( $context->getEntity()->getStatements() ); |
|
51 | + $propertyCountArray = $this->valueCountCheckerHelper->getPropertyCount($context->getEntity()->getStatements()); |
|
52 | 52 | |
53 | - if ( $propertyCountArray[$propertyId->getSerialization()] > 1 ) { |
|
54 | - $message = wfMessage( "wbqc-violation-message-single-value" )->escaped(); |
|
53 | + if ($propertyCountArray[$propertyId->getSerialization()] > 1) { |
|
54 | + $message = wfMessage("wbqc-violation-message-single-value")->escaped(); |
|
55 | 55 | $status = CheckResult::STATUS_VIOLATION; |
56 | 56 | } else { |
57 | 57 | $message = ''; |
58 | 58 | $status = CheckResult::STATUS_COMPLIANCE; |
59 | 59 | } |
60 | 60 | |
61 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
61 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
62 | 62 | } |
63 | 63 | |
64 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
64 | + public function checkConstraintParameters(Constraint $constraint) { |
|
65 | 65 | // no parameters |
66 | 66 | return []; |
67 | 67 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * |
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 = []; |
@@ -80,42 +80,42 @@ discard block |
||
80 | 80 | |
81 | 81 | $snak = $context->getSnak(); |
82 | 82 | |
83 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
83 | + if (!$snak instanceof PropertyValueSnak) { |
|
84 | 84 | // nothing to check |
85 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
85 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $dataValue = $snak->getDataValue(); |
89 | 89 | |
90 | - list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter( |
|
90 | + list($min, $max) = $this->constraintParameterParser->parseRangeParameter( |
|
91 | 91 | $constraintParameters, |
92 | 92 | $constraint->getConstraintTypeItemId(), |
93 | 93 | $dataValue->getType() |
94 | 94 | ); |
95 | 95 | $parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date'; |
96 | - if ( $min !== null ) { |
|
97 | - $parameters['minimum_' . $parameterKey] = [ $min ]; |
|
96 | + if ($min !== null) { |
|
97 | + $parameters['minimum_'.$parameterKey] = [$min]; |
|
98 | 98 | } |
99 | - if ( $max !== null ) { |
|
100 | - $parameters['maximum_' . $parameterKey] = [ $max ]; |
|
99 | + if ($max !== null) { |
|
100 | + $parameters['maximum_'.$parameterKey] = [$max]; |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 || |
|
104 | - $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0 |
|
103 | + if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 || |
|
104 | + $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0 |
|
105 | 105 | ) { |
106 | 106 | // at least one of $min, $max is set at this point, otherwise there could be no violation |
107 | 107 | $type = $dataValue->getType(); |
108 | - $openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen'; |
|
109 | - $message = wfMessage( "wbqc-violation-message-range-$type-$openness" ); |
|
108 | + $openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen'; |
|
109 | + $message = wfMessage("wbqc-violation-message-range-$type-$openness"); |
|
110 | 110 | $message->rawParams( |
111 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ), |
|
112 | - $this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT ) |
|
111 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE), |
|
112 | + $this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT) |
|
113 | 113 | ); |
114 | - if ( $min !== null ) { |
|
115 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) ); |
|
114 | + if ($min !== null) { |
|
115 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT)); |
|
116 | 116 | } |
117 | - if ( $max !== null ) { |
|
118 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) ); |
|
117 | + if ($max !== null) { |
|
118 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT)); |
|
119 | 119 | } |
120 | 120 | $message = $message->escaped(); |
121 | 121 | $status = CheckResult::STATUS_VIOLATION; |
@@ -124,22 +124,22 @@ discard block |
||
124 | 124 | $status = CheckResult::STATUS_COMPLIANCE; |
125 | 125 | } |
126 | 126 | |
127 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
127 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
128 | 128 | } |
129 | 129 | |
130 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
130 | + public function checkConstraintParameters(Constraint $constraint) { |
|
131 | 131 | $constraintParameters = $constraint->getConstraintParameters(); |
132 | 132 | $exceptions = []; |
133 | 133 | try { |
134 | 134 | // we don’t have a data value here, so get the type from the property instead |
135 | 135 | // (the distinction between data type and data value type is irrelevant for 'quantity' and 'time') |
136 | - $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() ); |
|
136 | + $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId()); |
|
137 | 137 | $this->constraintParameterParser->parseRangeParameter( |
138 | 138 | $constraintParameters, |
139 | 139 | $constraint->getConstraintTypeItemId(), |
140 | 140 | $type |
141 | 141 | ); |
142 | - } catch ( ConstraintParameterException $e ) { |
|
142 | + } catch (ConstraintParameterException $e) { |
|
143 | 143 | $exceptions[] = $e; |
144 | 144 | } |
145 | 145 | return $exceptions; |