Passed
Push — master ( 34770a...32caf2 )
by
unknown
08:08
created
src/Diff/TermListPatcher.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @throws PatcherException
29 29
 	 */
30
-	public function patchTermList( TermList $terms, Diff $patch ) {
31
-		foreach ( $patch as $lang => $diffOp ) {
32
-			$this->patchTerm( $terms, $lang, $diffOp );
30
+	public function patchTermList(TermList $terms, Diff $patch) {
31
+		foreach ($patch as $lang => $diffOp) {
32
+			$this->patchTerm($terms, $lang, $diffOp);
33 33
 		}
34 34
 	}
35 35
 
@@ -42,34 +42,34 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @throws PatcherException
44 44
 	 */
45
-	private function patchTerm( TermList $terms, $lang, AtomicDiffOp $diffOp ) {
46
-		$hasLang = $terms->hasTermForLanguage( $lang );
45
+	private function patchTerm(TermList $terms, $lang, AtomicDiffOp $diffOp) {
46
+		$hasLang = $terms->hasTermForLanguage($lang);
47 47
 
48
-		switch ( true ) {
48
+		switch (true) {
49 49
 			case $diffOp instanceof DiffOpAdd:
50
-				if ( !$hasLang ) {
51
-					$terms->setTextForLanguage( $lang, $diffOp->getNewValue() );
50
+				if (!$hasLang) {
51
+					$terms->setTextForLanguage($lang, $diffOp->getNewValue());
52 52
 				}
53 53
 				break;
54 54
 
55 55
 			case $diffOp instanceof DiffOpChange:
56
-				if ( $hasLang
57
-					&& $terms->getByLanguage( $lang )->getText() === $diffOp->getOldValue()
56
+				if ($hasLang
57
+					&& $terms->getByLanguage($lang)->getText() === $diffOp->getOldValue()
58 58
 				) {
59
-					$terms->setTextForLanguage( $lang, $diffOp->getNewValue() );
59
+					$terms->setTextForLanguage($lang, $diffOp->getNewValue());
60 60
 				}
61 61
 				break;
62 62
 
63 63
 			case $diffOp instanceof DiffOpRemove:
64
-				if ( $hasLang
65
-					&& $terms->getByLanguage( $lang )->getText() === $diffOp->getOldValue()
64
+				if ($hasLang
65
+					&& $terms->getByLanguage($lang)->getText() === $diffOp->getOldValue()
66 66
 				) {
67
-					$terms->removeByLanguage( $lang );
67
+					$terms->removeByLanguage($lang);
68 68
 				}
69 69
 				break;
70 70
 
71 71
 			default:
72
-				throw new PatcherException( 'Invalid terms diff' );
72
+				throw new PatcherException('Invalid terms diff');
73 73
 		}
74 74
 	}
75 75
 
Please login to merge, or discard this patch.
src/Diff/EntityPatcherStrategy.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return bool
20 20
 	 */
21
-	public function canPatchEntityType( $entityType );
21
+	public function canPatchEntityType($entityType);
22 22
 
23 23
 	/**
24 24
 	 * @param EntityDocument $entity
@@ -26,6 +26,6 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @throws InvalidArgumentException
28 28
 	 */
29
-	public function patchEntity( EntityDocument $entity, EntityDiff $patch );
29
+	public function patchEntity(EntityDocument $entity, EntityDiff $patch);
30 30
 
31 31
 }
Please login to merge, or discard this patch.
src/Statement/V4GuidGenerator.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 	 * @return string
23 23
 	 */
24 24
 	public function newGuid() {
25
-		if ( function_exists( 'com_create_guid' ) ) {
26
-			return trim( com_create_guid(), '{}' );
25
+		if (function_exists('com_create_guid')) {
26
+			return trim(com_create_guid(), '{}');
27 27
 		}
28 28
 
29 29
 		return sprintf(
30 30
 			'%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
31
-			mt_rand( 0, 65535 ),
32
-			mt_rand( 0, 65535 ),
33
-			mt_rand( 0, 65535 ),
34
-			mt_rand( 16384, 20479 ),
35
-			mt_rand( 32768, 49151 ),
36
-			mt_rand( 0, 65535 ),
37
-			mt_rand( 0, 65535 ),
38
-			mt_rand( 0, 65535 )
31
+			mt_rand(0, 65535),
32
+			mt_rand(0, 65535),
33
+			mt_rand(0, 65535),
34
+			mt_rand(16384, 20479),
35
+			mt_rand(32768, 49151),
36
+			mt_rand(0, 65535),
37
+			mt_rand(0, 65535),
38
+			mt_rand(0, 65535)
39 39
 		);
40 40
 	}
41 41
 
Please login to merge, or discard this patch.
src/Statement/Grouper/NullStatementGrouper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@
 block discarded – undo
21 21
 	 * @return StatementList[] An associative array, mapping the default group identifier
22 22
 	 *  "statements" to the unmodified StatementList object.
23 23
 	 */
24
-	public function groupStatements( StatementList $statements ) {
25
-		return [ 'statements' => $statements ];
24
+	public function groupStatements(StatementList $statements) {
25
+		return ['statements' => $statements];
26 26
 	}
27 27
 
28 28
 }
Please login to merge, or discard this patch.
src/Statement/Grouper/StatementGrouper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,6 +20,6 @@
 block discarded – undo
20 20
 	 *  included. The array keys act as identifiers for each group, and can be used as (parts of)
21 21
 	 *  message keys.
22 22
 	 */
23
-	public function groupStatements( StatementList $statements );
23
+	public function groupStatements(StatementList $statements);
24 24
 
25 25
 }
Please login to merge, or discard this patch.
src/Statement/Grouper/ByPropertyIdStatementGrouper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@
 block discarded – undo
18 18
 	 * @return StatementList[] An associative array, mapping property id serializations to
19 19
 	 *  StatementList objects.
20 20
 	 */
21
-	public function groupStatements( StatementList $statements ) {
21
+	public function groupStatements(StatementList $statements) {
22 22
 		/** @var StatementList[] $groups */
23 23
 		$groups = [];
24 24
 
25
-		foreach ( $statements->toArray() as $statement ) {
25
+		foreach ($statements->toArray() as $statement) {
26 26
 			$id = $statement->getPropertyId()->getSerialization();
27 27
 
28
-			if ( !isset( $groups[$id] ) ) {
28
+			if (!isset($groups[$id])) {
29 29
 				$groups[$id] = new StatementList();
30 30
 			}
31 31
 
32
-			$groups[$id]->addStatement( $statement );
32
+			$groups[$id]->addStatement($statement);
33 33
 		}
34 34
 
35 35
 		return $groups;
Please login to merge, or discard this patch.
src/Statement/Grouper/FilteringStatementGrouper.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @throws InvalidArgumentException
40 40
 	 */
41
-	public function __construct( array $filters ) {
42
-		foreach ( $filters as $key => $filter ) {
43
-			if ( $filter instanceof StatementFilter ) {
41
+	public function __construct(array $filters) {
42
+		foreach ($filters as $key => $filter) {
43
+			if ($filter instanceof StatementFilter) {
44 44
 				$this->filters[$key] = $filter;
45
-			} elseif ( $filter === null ) {
46
-				$this->setDefaultGroupIdentifier( $key );
45
+			} elseif ($filter === null) {
46
+				$this->setDefaultGroupIdentifier($key);
47 47
 			} else {
48
-				throw new InvalidArgumentException( '$filter must be a StatementFilter or null' );
48
+				throw new InvalidArgumentException('$filter must be a StatementFilter or null');
49 49
 			}
50 50
 
51
-			$this->setGroupIdentifier( $key );
51
+			$this->setGroupIdentifier($key);
52 52
 		}
53 53
 
54 54
 		$this->initializeDefaultGroup();
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	/**
58 58
 	 * @param string $key
59 59
 	 */
60
-	private function setGroupIdentifier( $key ) {
60
+	private function setGroupIdentifier($key) {
61 61
 		$this->groupIdentifiers[$key] = $key;
62 62
 	}
63 63
 
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @throws InvalidArgumentException
68 68
 	 */
69
-	private function setDefaultGroupIdentifier( $key ) {
70
-		if ( $this->defaultGroupIdentifier !== null ) {
71
-			throw new InvalidArgumentException( 'You must only define one default group' );
69
+	private function setDefaultGroupIdentifier($key) {
70
+		if ($this->defaultGroupIdentifier !== null) {
71
+			throw new InvalidArgumentException('You must only define one default group');
72 72
 		}
73 73
 
74 74
 		$this->defaultGroupIdentifier = $key;
75 75
 	}
76 76
 
77 77
 	private function initializeDefaultGroup() {
78
-		if ( $this->defaultGroupIdentifier === null ) {
78
+		if ($this->defaultGroupIdentifier === null) {
79 79
 			$this->defaultGroupIdentifier = 'statements';
80
-			$this->setGroupIdentifier( $this->defaultGroupIdentifier );
80
+			$this->setGroupIdentifier($this->defaultGroupIdentifier);
81 81
 		}
82 82
 	}
83 83
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 *  StatementList objects. All identifiers given in the constructor are guaranteed to be in the
89 89
 	 *  result.
90 90
 	 */
91
-	public function groupStatements( StatementList $statements ) {
91
+	public function groupStatements(StatementList $statements) {
92 92
 		$groups = $this->getEmptyGroups();
93 93
 
94
-		foreach ( $statements->toArray() as $statement ) {
95
-			$key = $this->getKey( $statement );
96
-			$groups[$key]->addStatement( $statement );
94
+		foreach ($statements->toArray() as $statement) {
95
+			$key = $this->getKey($statement);
96
+			$groups[$key]->addStatement($statement);
97 97
 		}
98 98
 
99 99
 		return $groups;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	private function getEmptyGroups() {
106 106
 		$groups = [];
107 107
 
108
-		foreach ( $this->groupIdentifiers as $key ) {
108
+		foreach ($this->groupIdentifiers as $key) {
109 109
 			$groups[$key] = new StatementList();
110 110
 		}
111 111
 
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return string Statement group identifier
119 119
 	 */
120
-	private function getKey( Statement $statement ) {
121
-		foreach ( $this->filters as $key => $filter ) {
122
-			if ( $filter->statementMatches( $statement ) ) {
120
+	private function getKey(Statement $statement) {
121
+		foreach ($this->filters as $key => $filter) {
122
+			if ($filter->statementMatches($statement)) {
123 123
 				return $key;
124 124
 			}
125 125
 		}
Please login to merge, or discard this patch.
src/Statement/StatementGuidParser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Wikibase\DataModel\Services\Statement;
4 4
 
@@ -21,22 +21,22 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private EntityIdParser $entityIdParser;
23 23
 
24
-	public function __construct( EntityIdParser $entityIdParser ) {
24
+	public function __construct(EntityIdParser $entityIdParser) {
25 25
 		$this->entityIdParser = $entityIdParser;
26 26
 	}
27 27
 
28 28
 	/**
29 29
 	 * @throws StatementGuidParsingException
30 30
 	 */
31
-	public function parse( string $serialization ): StatementGuid {
32
-		$keyParts = explode( StatementGuid::SEPARATOR, $serialization, 2 );
33
-		if ( count( $keyParts ) !== 2 ) {
34
-			throw new StatementGuidParsingException( '$serialization does not have the correct number of parts' );
31
+	public function parse(string $serialization): StatementGuid {
32
+		$keyParts = explode(StatementGuid::SEPARATOR, $serialization, 2);
33
+		if (count($keyParts) !== 2) {
34
+			throw new StatementGuidParsingException('$serialization does not have the correct number of parts');
35 35
 		}
36 36
 
37 37
 		try {
38
-			return new StatementGuid( $this->entityIdParser->parse( $keyParts[0] ), $keyParts[1], $serialization );
39
-		} catch ( EntityIdParsingException $ex ) {
38
+			return new StatementGuid($this->entityIdParser->parse($keyParts[0]), $keyParts[1], $serialization);
39
+		} catch (EntityIdParsingException $ex) {
40 40
 			throw new StatementGuidParsingException(
41 41
 				'$serialization contains invalid EntityId: '
42 42
 				. $ex->getMessage()
Please login to merge, or discard this patch.
src/Statement/Filter/DataTypeStatementFilter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param PropertyDataTypeLookup $dataTypeLookup
38 38
 	 * @param string[]|string $dataTypes One or more property data type identifiers.
39 39
 	 */
40
-	public function __construct( PropertyDataTypeLookup $dataTypeLookup, $dataTypes ) {
40
+	public function __construct(PropertyDataTypeLookup $dataTypeLookup, $dataTypes) {
41 41
 		$this->dataTypeLookup = $dataTypeLookup;
42 42
 		$this->dataTypes = (array)$dataTypes;
43 43
 	}
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @return bool
51 51
 	 */
52
-	public function statementMatches( Statement $statement ) {
52
+	public function statementMatches(Statement $statement) {
53 53
 		$id = $statement->getPropertyId();
54 54
 
55 55
 		try {
56
-			$dataType = $this->dataTypeLookup->getDataTypeIdForProperty( $id );
57
-		} catch ( PropertyDataTypeLookupException $ex ) {
56
+			$dataType = $this->dataTypeLookup->getDataTypeIdForProperty($id);
57
+		} catch (PropertyDataTypeLookupException $ex) {
58 58
 			return false;
59 59
 		}
60 60
 
61
-		return in_array( $dataType, $this->dataTypes );
61
+		return in_array($dataType, $this->dataTypes);
62 62
 	}
63 63
 
64 64
 }
Please login to merge, or discard this patch.