@@ -10,5 +10,5 @@ |
||
| 10 | 10 | |
| 11 | 11 | /** English (English) */ |
| 12 | 12 | $specialPageAliases['en'] = [ |
| 13 | - 'ConstraintReport' => [ 'ConstraintReport', 'Constraint Report' ], |
|
| 13 | + 'ConstraintReport' => ['ConstraintReport', 'Constraint Report'], |
|
| 14 | 14 | ]; |
@@ -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 | } |
@@ -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 | } |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | StatementList $statementList, |
| 31 | 31 | PropertyId $propertyId |
| 32 | 32 | ) { |
| 33 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
| 34 | - if ( $statementListByPropertyId->isEmpty() ) { |
|
| 33 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
| 34 | + if ($statementListByPropertyId->isEmpty()) { |
|
| 35 | 35 | return null; |
| 36 | 36 | } else { |
| 37 | 37 | return $statementListByPropertyId->toArray()[0]; |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | PropertyId $propertyId, |
| 53 | 53 | EntityId $value |
| 54 | 54 | ) { |
| 55 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
| 55 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
| 56 | 56 | /** @var Statement $statement */ |
| 57 | - foreach ( $statementListByPropertyId as $statement ) { |
|
| 57 | + foreach ($statementListByPropertyId as $statement) { |
|
| 58 | 58 | $snak = $statement->getMainSnak(); |
| 59 | - if ( $snak instanceof PropertyValueSnak ) { |
|
| 59 | + if ($snak instanceof PropertyValueSnak) { |
|
| 60 | 60 | $dataValue = $snak->getDataValue(); |
| 61 | - if ( $dataValue instanceof EntityIdValue && |
|
| 62 | - $dataValue->getEntityId()->equals( $value ) |
|
| 61 | + if ($dataValue instanceof EntityIdValue && |
|
| 62 | + $dataValue->getEntityId()->equals($value) |
|
| 63 | 63 | ) { |
| 64 | 64 | return $statement; |
| 65 | 65 | } |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | PropertyId $propertyId, |
| 83 | 83 | array $values |
| 84 | 84 | ) { |
| 85 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
| 85 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
| 86 | 86 | /** @var Statement $statement */ |
| 87 | - foreach ( $statementListByPropertyId as $statement ) { |
|
| 87 | + foreach ($statementListByPropertyId as $statement) { |
|
| 88 | 88 | $snak = $statement->getMainSnak(); |
| 89 | - foreach ( $values as $value ) { |
|
| 90 | - if ( $value->matchesSnak( $snak ) ) { |
|
| 89 | + foreach ($values as $value) { |
|
| 90 | + if ($value->matchesSnak($snak)) { |
|
| 91 | 91 | return $statement; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @param bool $serializeConstraintParameters Whether to serialize constraint parameters or not. |
| 18 | 18 | */ |
| 19 | - public function __construct( $serializeConstraintParameters = true ) { |
|
| 19 | + public function __construct($serializeConstraintParameters = true) { |
|
| 20 | 20 | $this->serializeConstraintParameters = $serializeConstraintParameters; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | * @param Constraint $constraint |
| 25 | 25 | * @return array |
| 26 | 26 | */ |
| 27 | - public function serialize( Constraint $constraint ) { |
|
| 27 | + public function serialize(Constraint $constraint) { |
|
| 28 | 28 | $serialization = [ |
| 29 | 29 | 'id' => $constraint->getConstraintId(), |
| 30 | 30 | 'pid' => $constraint->getPropertyId()->getSerialization(), |
| 31 | 31 | 'qid' => $constraint->getConstraintTypeItemId(), |
| 32 | 32 | ]; |
| 33 | - if ( $this->serializeConstraintParameters ) { |
|
| 33 | + if ($this->serializeConstraintParameters) { |
|
| 34 | 34 | $serialization['params'] = $constraint->getConstraintParameters(); |
| 35 | 35 | } |
| 36 | 36 | return $serialization; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | class TooManySparqlRequestsException extends SparqlHelperException { |
| 9 | 9 | |
| 10 | 10 | public function __construct() { |
| 11 | - parent::__construct( 'The SPARQL query endpoint reports too many requests.' ); |
|
| 11 | + parent::__construct('The SPARQL query endpoint reports too many requests.'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | } |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | * @param ContextCursor $cursor |
| 14 | 14 | * @return array |
| 15 | 15 | */ |
| 16 | - public function serialize( ContextCursor $cursor ) { |
|
| 17 | - if ( $cursor instanceof EntityContextCursor ) { |
|
| 16 | + public function serialize(ContextCursor $cursor) { |
|
| 17 | + if ($cursor instanceof EntityContextCursor) { |
|
| 18 | 18 | return [ |
| 19 | 19 | 't' => '\entity', |
| 20 | 20 | 'i' => $cursor->getEntityId(), |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | 'h' => $cursor->getSnakHash(), |
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | - if ( $type === Context::TYPE_QUALIFIER || $type === Context::TYPE_REFERENCE ) { |
|
| 33 | + if ($type === Context::TYPE_QUALIFIER || $type === Context::TYPE_REFERENCE) { |
|
| 34 | 34 | $serialization['P'] = $cursor->getSnakPropertyId(); |
| 35 | - if ( $type === Context::TYPE_REFERENCE ) { |
|
| 35 | + if ($type === Context::TYPE_REFERENCE) { |
|
| 36 | 36 | /** @var ReferenceContextCursor $cursor */ |
| 37 | 37 | '@phan-var ReferenceContextCursor $cursor'; |
| 38 | 38 | $serialization['r'] = $cursor->getReferenceHash(); |
@@ -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 | $itemId = $dataValue->getEntityId(); |
| 89 | - if ( $itemId instanceof ItemId ) { |
|
| 90 | - return self::fromItemId( $itemId ); |
|
| 89 | + if ($itemId instanceof ItemId) { |
|
| 90 | + return self::fromItemId($itemId); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | break; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return self::noValue(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' ); |
|
| 100 | + throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | * @return ItemId |
| 136 | 136 | */ |
| 137 | 137 | public function getItemId() { |
| 138 | - if ( !$this->isValue() ) { |
|
| 139 | - throw new DomainException( 'This value does not contain an item ID.' ); |
|
| 138 | + if (!$this->isValue()) { |
|
| 139 | + throw new DomainException('This value does not contain an item ID.'); |
|
| 140 | 140 | } |
| 141 | 141 | return $this->itemId; |
| 142 | 142 | } |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | * @param Snak $snak |
| 149 | 149 | * @return bool |
| 150 | 150 | */ |
| 151 | - public function matchesSnak( Snak $snak ) { |
|
| 152 | - switch ( true ) { |
|
| 151 | + public function matchesSnak(Snak $snak) { |
|
| 152 | + switch (true) { |
|
| 153 | 153 | case $snak instanceof PropertyValueSnak: |
| 154 | 154 | $dataValue = $snak->getDataValue(); |
| 155 | 155 | return $this->isValue() && |
| 156 | 156 | $dataValue instanceof EntityIdValue && |
| 157 | 157 | $dataValue->getEntityId() instanceof ItemId && |
| 158 | - $dataValue->getEntityId()->equals( $this->getItemId() ); |
|
| 158 | + $dataValue->getEntityId()->equals($this->getItemId()); |
|
| 159 | 159 | case $snak instanceof PropertySomeValueSnak: |
| 160 | 160 | return $this->isSomeValue(); |
| 161 | 161 | case $snak instanceof PropertyNoValueSnak: |
@@ -37,25 +37,25 @@ discard block |
||
| 37 | 37 | * @param Title $title |
| 38 | 38 | * @param string[] $params should contain 'entityId' => 'Q1234' |
| 39 | 39 | */ |
| 40 | - public function __construct( Title $title, array $params ) { |
|
| 41 | - parent::__construct( self::COMMAND, $title, $params ); |
|
| 40 | + public function __construct(Title $title, array $params) { |
|
| 41 | + parent::__construct(self::COMMAND, $title, $params); |
|
| 42 | 42 | $this->removeDuplicates = true; |
| 43 | 43 | |
| 44 | - Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' ); |
|
| 44 | + Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']'); |
|
| 45 | 45 | |
| 46 | - $resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() ); |
|
| 46 | + $resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance()); |
|
| 47 | 47 | '@phan-var CachingResultsSource $resultSource'; |
| 48 | 48 | // This job should only ever be used when caching result sources are used. |
| 49 | - $this->setResultsSource( $resultSource ); |
|
| 49 | + $this->setResultsSource($resultSource); |
|
| 50 | 50 | |
| 51 | - $this->setEntityIdParser( WikibaseRepo::getEntityIdParser() ); |
|
| 51 | + $this->setEntityIdParser(WikibaseRepo::getEntityIdParser()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function setResultsSource( CachingResultsSource $resultsSource ) { |
|
| 54 | + public function setResultsSource(CachingResultsSource $resultsSource) { |
|
| 55 | 55 | $this->resultsSource = $resultsSource; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function setEntityIdParser( EntityIdParser $parser ) { |
|
| 58 | + public function setEntityIdParser(EntityIdParser $parser) { |
|
| 59 | 59 | $this->entityIdParser = $parser; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -66,19 +66,19 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function run() { |
| 68 | 68 | try { |
| 69 | - $entityId = $this->entityIdParser->parse( $this->params['entityId'] ); |
|
| 70 | - } catch ( EntityIdParsingException $e ) { |
|
| 69 | + $entityId = $this->entityIdParser->parse($this->params['entityId']); |
|
| 70 | + } catch (EntityIdParsingException $e) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $this->checkConstraints( $entityId ); |
|
| 74 | + $this->checkConstraints($entityId); |
|
| 75 | 75 | |
| 76 | 76 | return true; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - private function checkConstraints( EntityId $entityId ) { |
|
| 79 | + private function checkConstraints(EntityId $entityId) { |
|
| 80 | 80 | $this->resultsSource->getResults( |
| 81 | - [ $entityId ], |
|
| 81 | + [$entityId], |
|
| 82 | 82 | [], |
| 83 | 83 | null, |
| 84 | 84 | [] |