@@ -22,21 +22,21 @@ discard block |
||
| 22 | 22 | * @return DiffOp |
| 23 | 23 | * @throws InvalidArgumentException |
| 24 | 24 | */ |
| 25 | - public function newFromArray( array $diffOp ) { |
|
| 26 | - $this->assertHasKey( 'type', $diffOp ); |
|
| 25 | + public function newFromArray(array $diffOp) { |
|
| 26 | + $this->assertHasKey('type', $diffOp); |
|
| 27 | 27 | |
| 28 | 28 | // see EntityDiff::getType() and ItemDiff::getType() |
| 29 | - if ( preg_match( '!^diff/(.*)$!', $diffOp['type'], $matches ) ) { |
|
| 29 | + if (preg_match('!^diff/(.*)$!', $diffOp['type'], $matches)) { |
|
| 30 | 30 | $itemType = $matches[1]; |
| 31 | - $this->assertHasKey( 'operations', $diffOp ); |
|
| 31 | + $this->assertHasKey('operations', $diffOp); |
|
| 32 | 32 | |
| 33 | - $operations = $this->createOperations( $diffOp['operations'] ); |
|
| 34 | - $diff = EntityDiff::newForType( $itemType, $operations ); |
|
| 33 | + $operations = $this->createOperations($diffOp['operations']); |
|
| 34 | + $diff = EntityDiff::newForType($itemType, $operations); |
|
| 35 | 35 | |
| 36 | 36 | return $diff; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - return parent::newFromArray( $diffOp ); |
|
| 39 | + return parent::newFromArray($diffOp); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | * @param array $data the input data |
| 47 | 47 | * @return DiffOp[] The diff ops |
| 48 | 48 | */ |
| 49 | - private function createOperations( array $data ) { |
|
| 49 | + private function createOperations(array $data) { |
|
| 50 | 50 | $operations = []; |
| 51 | 51 | |
| 52 | - foreach ( $data as $key => $operation ) { |
|
| 53 | - $operations[$key] = $this->newFromArray( $operation ); |
|
| 52 | + foreach ($data as $key => $operation) { |
|
| 53 | + $operations[$key] = $this->newFromArray($operation); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return $operations; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return bool |
| 44 | 44 | */ |
| 45 | - public function canPatchEntityType( $entityType ) { |
|
| 45 | + public function canPatchEntityType($entityType) { |
|
| 46 | 46 | return $entityType === 'item'; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -52,27 +52,27 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @throws InvalidArgumentException |
| 54 | 54 | */ |
| 55 | - public function patchEntity( EntityDocument $entity, EntityDiff $patch ) { |
|
| 56 | - $item = $this->assertIsItemAndCast( $entity ); |
|
| 55 | + public function patchEntity(EntityDocument $entity, EntityDiff $patch) { |
|
| 56 | + $item = $this->assertIsItemAndCast($entity); |
|
| 57 | 57 | |
| 58 | - $this->patchItem( $item, $patch ); |
|
| 58 | + $this->patchItem($item, $patch); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - private function assertIsItemAndCast( EntityDocument $item ): Item { |
|
| 62 | - if ( !( $item instanceof Item ) ) { |
|
| 63 | - throw new InvalidArgumentException( '$item must be an instance of Item' ); |
|
| 61 | + private function assertIsItemAndCast(EntityDocument $item): Item { |
|
| 62 | + if (!($item instanceof Item)) { |
|
| 63 | + throw new InvalidArgumentException('$item must be an instance of Item'); |
|
| 64 | 64 | } |
| 65 | 65 | return $item; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - private function patchItem( Item $item, EntityDiff $patch ) { |
|
| 69 | - $this->fingerprintPatcher->patchFingerprint( $item->getFingerprint(), $patch ); |
|
| 68 | + private function patchItem(Item $item, EntityDiff $patch) { |
|
| 69 | + $this->fingerprintPatcher->patchFingerprint($item->getFingerprint(), $patch); |
|
| 70 | 70 | |
| 71 | - if ( $patch instanceof ItemDiff ) { |
|
| 72 | - $item->setSiteLinkList( $this->siteLinkListPatcher->getPatchedSiteLinkList( |
|
| 71 | + if ($patch instanceof ItemDiff) { |
|
| 72 | + $item->setSiteLinkList($this->siteLinkListPatcher->getPatchedSiteLinkList( |
|
| 73 | 73 | $item->getSiteLinkList(), |
| 74 | 74 | $patch->getSiteLinkDiff() |
| 75 | - ) ); |
|
| 75 | + )); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $this->statementListPatcher->patchStatementList( |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return bool |
| 20 | 20 | */ |
| 21 | - public function canDiffEntityType( $entityType ); |
|
| 21 | + public function canDiffEntityType($entityType); |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @param EntityDocument $from |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return EntityDiff |
| 28 | 28 | * @throws InvalidArgumentException |
| 29 | 29 | */ |
| 30 | - public function diffEntities( EntityDocument $from, EntityDocument $to ); |
|
| 30 | + public function diffEntities(EntityDocument $from, EntityDocument $to); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @param EntityDocument $entity |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return EntityDiff |
| 36 | 36 | * @throws InvalidArgumentException |
| 37 | 37 | */ |
| 38 | - public function getConstructionDiff( EntityDocument $entity ); |
|
| 38 | + public function getConstructionDiff(EntityDocument $entity); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @param EntityDocument $entity |
@@ -43,6 +43,6 @@ discard block |
||
| 43 | 43 | * @return EntityDiff |
| 44 | 44 | * @throws InvalidArgumentException |
| 45 | 45 | */ |
| 46 | - public function getDestructionDiff( EntityDocument $entity ); |
|
| 46 | + public function getDestructionDiff(EntityDocument $entity); |
|
| 47 | 47 | |
| 48 | 48 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | private $statementListDiffer; |
| 29 | 29 | |
| 30 | 30 | public function __construct() { |
| 31 | - $this->recursiveMapDiffer = new MapDiffer( true ); |
|
| 31 | + $this->recursiveMapDiffer = new MapDiffer(true); |
|
| 32 | 32 | $this->statementListDiffer = new StatementListDiffer(); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return bool |
| 39 | 39 | */ |
| 40 | - public function canDiffEntityType( $entityType ) { |
|
| 40 | + public function canDiffEntityType($entityType) { |
|
| 41 | 41 | return $entityType === 'item'; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -48,50 +48,50 @@ discard block |
||
| 48 | 48 | * @return ItemDiff |
| 49 | 49 | * @throws InvalidArgumentException |
| 50 | 50 | */ |
| 51 | - public function diffEntities( EntityDocument $from, EntityDocument $to ) { |
|
| 52 | - $fromItem = $this->assertIsItemAndCast( $from ); |
|
| 53 | - $toItem = $this->assertIsItemAndCast( $to ); |
|
| 51 | + public function diffEntities(EntityDocument $from, EntityDocument $to) { |
|
| 52 | + $fromItem = $this->assertIsItemAndCast($from); |
|
| 53 | + $toItem = $this->assertIsItemAndCast($to); |
|
| 54 | 54 | |
| 55 | - return $this->diffItems( $fromItem, $toItem ); |
|
| 55 | + return $this->diffItems($fromItem, $toItem); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private function assertIsItemAndCast( EntityDocument $item ): Item { |
|
| 59 | - if ( !( $item instanceof Item ) ) { |
|
| 60 | - throw new InvalidArgumentException( '$item must be an instance of Item' ); |
|
| 58 | + private function assertIsItemAndCast(EntityDocument $item): Item { |
|
| 59 | + if (!($item instanceof Item)) { |
|
| 60 | + throw new InvalidArgumentException('$item must be an instance of Item'); |
|
| 61 | 61 | } |
| 62 | 62 | return $item; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function diffItems( Item $from, Item $to ): ItemDiff { |
|
| 65 | + public function diffItems(Item $from, Item $to): ItemDiff { |
|
| 66 | 66 | $diffOps = $this->recursiveMapDiffer->doDiff( |
| 67 | - $this->toDiffArray( $from ), |
|
| 68 | - $this->toDiffArray( $to ) |
|
| 67 | + $this->toDiffArray($from), |
|
| 68 | + $this->toDiffArray($to) |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | - $diffOps['claim'] = $this->statementListDiffer->getDiff( $from->getStatements(), $to->getStatements() ); |
|
| 71 | + $diffOps['claim'] = $this->statementListDiffer->getDiff($from->getStatements(), $to->getStatements()); |
|
| 72 | 72 | |
| 73 | - return new ItemDiff( $diffOps ); |
|
| 73 | + return new ItemDiff($diffOps); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - private function toDiffArray( Item $item ): array { |
|
| 76 | + private function toDiffArray(Item $item): array { |
|
| 77 | 77 | $array = []; |
| 78 | 78 | |
| 79 | 79 | $array['aliases'] = $item->getAliasGroups()->toTextArray(); |
| 80 | 80 | $array['label'] = $item->getLabels()->toTextArray(); |
| 81 | 81 | $array['description'] = $item->getDescriptions()->toTextArray(); |
| 82 | - $array['links'] = $this->getSiteLinksInDiffFormat( $item->getSiteLinkList() ); |
|
| 82 | + $array['links'] = $this->getSiteLinksInDiffFormat($item->getSiteLinkList()); |
|
| 83 | 83 | |
| 84 | 84 | return $array; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - private function getSiteLinksInDiffFormat( SiteLinkList $siteLinks ): array { |
|
| 87 | + private function getSiteLinksInDiffFormat(SiteLinkList $siteLinks): array { |
|
| 88 | 88 | $linksInDiffFormat = []; |
| 89 | 89 | |
| 90 | - foreach ( $siteLinks->toArray() as $siteLink ) { |
|
| 90 | + foreach ($siteLinks->toArray() as $siteLink) { |
|
| 91 | 91 | $linksInDiffFormat[$siteLink->getSiteId()] = [ |
| 92 | 92 | 'name' => $siteLink->getPageName(), |
| 93 | 93 | 'badges' => array_map( |
| 94 | - static function( ItemId $id ) { |
|
| 94 | + static function(ItemId $id) { |
|
| 95 | 95 | return $id->getSerialization(); |
| 96 | 96 | }, |
| 97 | 97 | $siteLink->getBadges() |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * @return ItemDiff |
| 109 | 109 | * @throws InvalidArgumentException |
| 110 | 110 | */ |
| 111 | - public function getConstructionDiff( EntityDocument $entity ) { |
|
| 112 | - $item = $this->assertIsItemAndCast( $entity ); |
|
| 113 | - return $this->diffEntities( new Item(), $item ); |
|
| 111 | + public function getConstructionDiff(EntityDocument $entity) { |
|
| 112 | + $item = $this->assertIsItemAndCast($entity); |
|
| 113 | + return $this->diffEntities(new Item(), $item); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | * @return ItemDiff |
| 120 | 120 | * @throws InvalidArgumentException |
| 121 | 121 | */ |
| 122 | - public function getDestructionDiff( EntityDocument $entity ) { |
|
| 123 | - $item = $this->assertIsItemAndCast( $entity ); |
|
| 124 | - return $this->diffEntities( $item, new Item() ); |
|
| 122 | + public function getDestructionDiff(EntityDocument $entity) { |
|
| 123 | + $item = $this->assertIsItemAndCast($entity); |
|
| 124 | + return $this->diffEntities($item, new Item()); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return bool |
| 37 | 37 | */ |
| 38 | - public function canPatchEntityType( $entityType ) { |
|
| 38 | + public function canPatchEntityType($entityType) { |
|
| 39 | 39 | return $entityType === 'property'; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -45,21 +45,21 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @throws InvalidArgumentException |
| 47 | 47 | */ |
| 48 | - public function patchEntity( EntityDocument $entity, EntityDiff $patch ) { |
|
| 49 | - $property = $this->assertIsPropertyAndCast( $entity ); |
|
| 48 | + public function patchEntity(EntityDocument $entity, EntityDiff $patch) { |
|
| 49 | + $property = $this->assertIsPropertyAndCast($entity); |
|
| 50 | 50 | |
| 51 | - $this->patchProperty( $property, $patch ); |
|
| 51 | + $this->patchProperty($property, $patch); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - private function assertIsPropertyAndCast( EntityDocument $property ): Property { |
|
| 55 | - if ( !( $property instanceof Property ) ) { |
|
| 56 | - throw new InvalidArgumentException( '$property must be an instance of Property' ); |
|
| 54 | + private function assertIsPropertyAndCast(EntityDocument $property): Property { |
|
| 55 | + if (!($property instanceof Property)) { |
|
| 56 | + throw new InvalidArgumentException('$property must be an instance of Property'); |
|
| 57 | 57 | } |
| 58 | 58 | return $property; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - private function patchProperty( Property $property, EntityDiff $patch ) { |
|
| 62 | - $this->fingerprintPatcher->patchFingerprint( $property->getFingerprint(), $patch ); |
|
| 61 | + private function patchProperty(Property $property, EntityDiff $patch) { |
|
| 62 | + $this->fingerprintPatcher->patchFingerprint($property->getFingerprint(), $patch); |
|
| 63 | 63 | |
| 64 | 64 | $this->statementListPatcher->patchStatementList( |
| 65 | 65 | $property->getStatements(), |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @param DiffOp[] $operations |
| 20 | 20 | */ |
| 21 | - public function __construct( array $operations = [] ) { |
|
| 22 | - $this->fixSubstructureDiff( $operations, 'links' ); |
|
| 21 | + public function __construct(array $operations = []) { |
|
| 22 | + $this->fixSubstructureDiff($operations, 'links'); |
|
| 23 | 23 | |
| 24 | - parent::__construct( $operations ); |
|
| 24 | + parent::__construct($operations); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @return Diff |
| 31 | 31 | */ |
| 32 | 32 | public function getSiteLinkDiff() { |
| 33 | - return $this['links'] ?? new Diff( [], true ); |
|
| 33 | + return $this['links'] ?? new Diff([], true); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | private $differStrategies; |
| 21 | 21 | |
| 22 | 22 | public function __construct() { |
| 23 | - $this->registerEntityDifferStrategy( new ItemDiffer() ); |
|
| 24 | - $this->registerEntityDifferStrategy( new PropertyDiffer() ); |
|
| 23 | + $this->registerEntityDifferStrategy(new ItemDiffer()); |
|
| 24 | + $this->registerEntityDifferStrategy(new PropertyDiffer()); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function registerEntityDifferStrategy( EntityDifferStrategy $differStrategy ) { |
|
| 27 | + public function registerEntityDifferStrategy(EntityDifferStrategy $differStrategy) { |
|
| 28 | 28 | $this->differStrategies[] = $differStrategy; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | * @throws InvalidArgumentException |
| 37 | 37 | * @throws RuntimeException |
| 38 | 38 | */ |
| 39 | - public function diffEntities( EntityDocument $from, EntityDocument $to ) { |
|
| 40 | - $this->assertTypesMatch( $from, $to ); |
|
| 39 | + public function diffEntities(EntityDocument $from, EntityDocument $to) { |
|
| 40 | + $this->assertTypesMatch($from, $to); |
|
| 41 | 41 | |
| 42 | - return $this->getDiffStrategy( $from->getType() )->diffEntities( $from, $to ); |
|
| 42 | + return $this->getDiffStrategy($from->getType())->diffEntities($from, $to); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - private function assertTypesMatch( EntityDocument $from, EntityDocument $to ) { |
|
| 46 | - if ( $from->getType() !== $to->getType() ) { |
|
| 47 | - throw new InvalidArgumentException( 'Can only diff two entities of the same type' ); |
|
| 45 | + private function assertTypesMatch(EntityDocument $from, EntityDocument $to) { |
|
| 46 | + if ($from->getType() !== $to->getType()) { |
|
| 47 | + throw new InvalidArgumentException('Can only diff two entities of the same type'); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | * @throws RuntimeException |
| 55 | 55 | * @return EntityDifferStrategy |
| 56 | 56 | */ |
| 57 | - private function getDiffStrategy( $entityType ) { |
|
| 58 | - foreach ( $this->differStrategies as $diffStrategy ) { |
|
| 59 | - if ( $diffStrategy->canDiffEntityType( $entityType ) ) { |
|
| 57 | + private function getDiffStrategy($entityType) { |
|
| 58 | + foreach ($this->differStrategies as $diffStrategy) { |
|
| 59 | + if ($diffStrategy->canDiffEntityType($entityType)) { |
|
| 60 | 60 | return $diffStrategy; |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - throw new RuntimeException( 'Diffing the provided types of entities is not supported' ); |
|
| 64 | + throw new RuntimeException('Diffing the provided types of entities is not supported'); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @return EntityDiff |
| 71 | 71 | * @throws InvalidArgumentException |
| 72 | 72 | */ |
| 73 | - public function getConstructionDiff( EntityDocument $entity ) { |
|
| 74 | - return $this->getDiffStrategy( $entity->getType() )->getConstructionDiff( $entity ); |
|
| 73 | + public function getConstructionDiff(EntityDocument $entity) { |
|
| 74 | + return $this->getDiffStrategy($entity->getType())->getConstructionDiff($entity); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | * @return EntityDiff |
| 81 | 81 | * @throws InvalidArgumentException |
| 82 | 82 | */ |
| 83 | - public function getDestructionDiff( EntityDocument $entity ) { |
|
| 84 | - return $this->getDiffStrategy( $entity->getType() )->getDestructionDiff( $entity ); |
|
| 83 | + public function getDestructionDiff(EntityDocument $entity) { |
|
| 84 | + return $this->getDiffStrategy($entity->getType())->getDestructionDiff($entity); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | private $patcherStrategies; |
| 22 | 22 | |
| 23 | 23 | public function __construct() { |
| 24 | - $this->registerEntityPatcherStrategy( new ItemPatcher() ); |
|
| 25 | - $this->registerEntityPatcherStrategy( new PropertyPatcher() ); |
|
| 24 | + $this->registerEntityPatcherStrategy(new ItemPatcher()); |
|
| 25 | + $this->registerEntityPatcherStrategy(new PropertyPatcher()); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function registerEntityPatcherStrategy( EntityPatcherStrategy $patcherStrategy ) { |
|
| 28 | + public function registerEntityPatcherStrategy(EntityPatcherStrategy $patcherStrategy) { |
|
| 29 | 29 | $this->patcherStrategies[] = $patcherStrategy; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | * @throws InvalidArgumentException |
| 37 | 37 | * @throws RuntimeException |
| 38 | 38 | */ |
| 39 | - public function patchEntity( EntityDocument $entity, EntityDiff $patch ) { |
|
| 40 | - $this->getPatcherStrategy( $entity->getType() )->patchEntity( $entity, $patch ); |
|
| 39 | + public function patchEntity(EntityDocument $entity, EntityDiff $patch) { |
|
| 40 | + $this->getPatcherStrategy($entity->getType())->patchEntity($entity, $patch); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | * @throws RuntimeException |
| 47 | 47 | * @return EntityPatcherStrategy |
| 48 | 48 | */ |
| 49 | - private function getPatcherStrategy( $entityType ) { |
|
| 50 | - foreach ( $this->patcherStrategies as $patcherStrategy ) { |
|
| 51 | - if ( $patcherStrategy->canPatchEntityType( $entityType ) ) { |
|
| 49 | + private function getPatcherStrategy($entityType) { |
|
| 50 | + foreach ($this->patcherStrategies as $patcherStrategy) { |
|
| 51 | + if ($patcherStrategy->canPatchEntityType($entityType)) { |
|
| 52 | 52 | return $patcherStrategy; |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - throw new RuntimeException( 'Patching the provided types of entities is not supported' ); |
|
| 56 | + throw new RuntimeException('Patching the provided types of entities is not supported'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | } |
@@ -22,24 +22,24 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return self |
| 24 | 24 | */ |
| 25 | - public static function newForType( $entityType, array $operations = [] ) { |
|
| 26 | - if ( $entityType === Item::ENTITY_TYPE ) { |
|
| 27 | - return new ItemDiff( $operations ); |
|
| 25 | + public static function newForType($entityType, array $operations = []) { |
|
| 26 | + if ($entityType === Item::ENTITY_TYPE) { |
|
| 27 | + return new ItemDiff($operations); |
|
| 28 | 28 | } else { |
| 29 | - return new self( $operations ); |
|
| 29 | + return new self($operations); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * @param DiffOp[] $operations |
| 35 | 35 | */ |
| 36 | - public function __construct( array $operations = [] ) { |
|
| 37 | - $this->fixSubstructureDiff( $operations, 'aliases' ); |
|
| 38 | - $this->fixSubstructureDiff( $operations, 'label' ); |
|
| 39 | - $this->fixSubstructureDiff( $operations, 'description' ); |
|
| 40 | - $this->fixSubstructureDiff( $operations, 'claim' ); |
|
| 36 | + public function __construct(array $operations = []) { |
|
| 37 | + $this->fixSubstructureDiff($operations, 'aliases'); |
|
| 38 | + $this->fixSubstructureDiff($operations, 'label'); |
|
| 39 | + $this->fixSubstructureDiff($operations, 'description'); |
|
| 40 | + $this->fixSubstructureDiff($operations, 'claim'); |
|
| 41 | 41 | |
| 42 | - parent::__construct( $operations, true ); |
|
| 42 | + parent::__construct($operations, true); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -52,18 +52,18 @@ discard block |
||
| 52 | 52 | * substructure diff can be replaced if need be. |
| 53 | 53 | * @param string $key The key of the substructure |
| 54 | 54 | */ |
| 55 | - protected function fixSubstructureDiff( array &$operations, $key ) { |
|
| 56 | - if ( !isset( $operations[$key] ) ) { |
|
| 55 | + protected function fixSubstructureDiff(array &$operations, $key) { |
|
| 56 | + if (!isset($operations[$key])) { |
|
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( !( $operations[$key] instanceof Diff ) ) { |
|
| 61 | - $warning = "Invalid substructure diff for key $key: " . get_class( $operations[$key] ); |
|
| 60 | + if (!($operations[$key] instanceof Diff)) { |
|
| 61 | + $warning = "Invalid substructure diff for key $key: " . get_class($operations[$key]); |
|
| 62 | 62 | |
| 63 | - if ( function_exists( 'wfLogWarning' ) ) { |
|
| 64 | - wfLogWarning( $warning ); |
|
| 63 | + if (function_exists('wfLogWarning')) { |
|
| 64 | + wfLogWarning($warning); |
|
| 65 | 65 | } else { |
| 66 | - trigger_error( $warning, E_USER_WARNING ); |
|
| 66 | + trigger_error($warning, E_USER_WARNING); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // We could look into the atomic diff, see if it uses arrays as values, |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | // actual old behavior of MapDiffer didn't cause that to happen, let's |
| 72 | 72 | // just use an empty diff, which is what MapDiffer should have returned |
| 73 | 73 | // in the actual broken case mentioned in bug 51363. |
| 74 | - $operations[$key] = new Diff( [], true ); |
|
| 74 | + $operations[$key] = new Diff([], true); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return Diff |
| 84 | 84 | */ |
| 85 | 85 | public function getAliasesDiff() { |
| 86 | - return $this['aliases'] ?? new Diff( [], true ); |
|
| 86 | + return $this['aliases'] ?? new Diff([], true); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @return Diff |
| 95 | 95 | */ |
| 96 | 96 | public function getLabelsDiff() { |
| 97 | - return $this['label'] ?? new Diff( [], true ); |
|
| 97 | + return $this['label'] ?? new Diff([], true); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return Diff |
| 106 | 106 | */ |
| 107 | 107 | public function getDescriptionsDiff() { |
| 108 | - return $this['description'] ?? new Diff( [], true ); |
|
| 108 | + return $this['description'] ?? new Diff([], true); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @return Diff |
| 117 | 117 | */ |
| 118 | 118 | public function getClaimsDiff() { |
| 119 | - return $this['claim'] ?? new Diff( [], true ); |
|
| 119 | + return $this['claim'] ?? new Diff([], true); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |