Completed
Push — master ( 797db0...1dc4ce )
by
unknown
40s
created
src/Html/HtmlTableHeaderBuilder.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Html;
6 6
 
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @throws InvalidArgumentException
35 35
 	 */
36
-	public function __construct( $content, bool $isSortable = false ) {
37
-		Assert::parameterType( [ 'string', HtmlArmor::class ], $content, '$content' );
36
+	public function __construct($content, bool $isSortable = false) {
37
+		Assert::parameterType(['string', HtmlArmor::class], $content, '$content');
38 38
 
39 39
 		$this->content = $content;
40 40
 		$this->isSortable = $isSortable;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @return string HTML
45 45
 	 */
46 46
 	public function getContent(): string {
47
-		return HtmlArmor::getHtml( $this->content );
47
+		return HtmlArmor::getHtml($this->content);
48 48
 	}
49 49
 
50 50
 	public function getIsSortable(): bool {
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @return string HTML
58 58
 	 */
59 59
 	public function toHtml(): string {
60
-		$attributes = [ 'role' => 'columnheader button' ];
60
+		$attributes = ['role' => 'columnheader button'];
61 61
 
62
-		if ( !$this->isSortable ) {
62
+		if (!$this->isSortable) {
63 63
 			$attributes['class'] = 'unsortable';
64 64
 		}
65 65
 
66
-		return Html::rawElement( 'th', $attributes, $this->getContent() );
66
+		return Html::rawElement('th', $attributes, $this->getContent());
67 67
 	}
68 68
 
69 69
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageSerializer.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class ViolationMessageSerializer implements Serializer {
23 23
 
24
-	private function abbreviateViolationMessageKey( string $fullMessageKey ): string {
25
-		return substr( $fullMessageKey, strlen( ViolationMessage::MESSAGE_KEY_PREFIX ) );
24
+	private function abbreviateViolationMessageKey(string $fullMessageKey): string {
25
+		return substr($fullMessageKey, strlen(ViolationMessage::MESSAGE_KEY_PREFIX));
26 26
 	}
27 27
 
28 28
 	/**
29 29
 	 * @param ViolationMessage $object
30 30
 	 * @return array
31 31
 	 */
32
-	public function serialize( $object ): array {
32
+	public function serialize($object): array {
33 33
 		/** @var ViolationMessage $object */
34
-		Assert::parameterType( ViolationMessage::class, $object, '$object' );
34
+		Assert::parameterType(ViolationMessage::class, $object, '$object');
35 35
 
36 36
 		$arguments = $object->getArguments();
37 37
 		$serializedArguments = [];
38
-		foreach ( $arguments as $argument ) {
39
-			$serializedArguments[] = $this->serializeArgument( $argument );
38
+		foreach ($arguments as $argument) {
39
+			$serializedArguments[] = $this->serializeArgument($argument);
40 40
 		}
41 41
 
42 42
 		return [
43
-			'k' => $this->abbreviateViolationMessageKey( $object->getMessageKey() ),
43
+			'k' => $this->abbreviateViolationMessageKey($object->getMessageKey()),
44 44
 			'a' => $serializedArguments,
45 45
 		];
46 46
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param array $argument element of ViolationMessage::getArguments()
50 50
 	 * @return array [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ]
51 51
 	 */
52
-	private function serializeArgument( array $argument ): array {
52
+	private function serializeArgument(array $argument): array {
53 53
 		$methods = [
54 54
 			ViolationMessage::TYPE_ENTITY_ID => 'serializeEntityId',
55 55
 			ViolationMessage::TYPE_ENTITY_ID_LIST => 'serializeEntityIdList',
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 		$value = $argument['value'];
72 72
 		$role = $argument['role'];
73 73
 
74
-		if ( array_key_exists( $type, $methods ) ) {
74
+		if (array_key_exists($type, $methods)) {
75 75
 			$method = $methods[$type];
76
-			$serializedValue = $this->$method( $value );
76
+			$serializedValue = $this->$method($value);
77 77
 		} else {
78 78
 			throw new InvalidArgumentException(
79
-				'Unknown ViolationMessage argument type ' . $type . '!'
79
+				'Unknown ViolationMessage argument type '.$type.'!'
80 80
 			);
81 81
 		}
82 82
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param string $string any value that shall simply be serialized to itself
94 94
 	 * @return string that same value, unchanged
95 95
 	 */
96
-	private function serializeStringByIdentity( string $string ): string {
96
+	private function serializeStringByIdentity(string $string): string {
97 97
 		return $string;
98 98
 	}
99 99
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @param string[] $strings
102 102
 	 * @return string[]
103 103
 	 */
104
-	private function serializeStringListByIdentity( array $strings ): array {
105
-		Assert::parameterElementType( 'string', $strings, '$strings' );
104
+	private function serializeStringListByIdentity(array $strings): array {
105
+		Assert::parameterElementType('string', $strings, '$strings');
106 106
 		return $strings;
107 107
 	}
108 108
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param EntityId $entityId
111 111
 	 * @return string entity ID serialization
112 112
 	 */
113
-	private function serializeEntityId( EntityId $entityId ): string {
113
+	private function serializeEntityId(EntityId $entityId): string {
114 114
 		return $entityId->getSerialization();
115 115
 	}
116 116
 
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 * @param EntityId[] $entityIdList
119 119
 	 * @return string[] entity ID serializations
120 120
 	 */
121
-	private function serializeEntityIdList( array $entityIdList ): array {
122
-		return array_map( [ $this, 'serializeEntityId' ], $entityIdList );
121
+	private function serializeEntityIdList(array $entityIdList): array {
122
+		return array_map([$this, 'serializeEntityId'], $entityIdList);
123 123
 	}
124 124
 
125 125
 	/**
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	 * @return string entity ID serialization, '::somevalue', or '::novalue'
128 128
 	 * (according to EntityId::PATTERN, entity ID serializations can never begin with two colons)
129 129
 	 */
130
-	private function serializeItemIdSnakValue( ItemIdSnakValue $value ): string {
131
-		switch ( true ) {
130
+	private function serializeItemIdSnakValue(ItemIdSnakValue $value): string {
131
+		switch (true) {
132 132
 			case $value->isValue():
133
-				return $this->serializeEntityId( $value->getItemId() );
133
+				return $this->serializeEntityId($value->getItemId());
134 134
 			case $value->isSomeValue():
135 135
 				return '::somevalue';
136 136
 			case $value->isNoValue():
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 	 * @param ItemIdSnakValue[] $valueList
149 149
 	 * @return string[] array of entity ID serializations, '::somevalue's or '::novalue's
150 150
 	 */
151
-	private function serializeItemIdSnakValueList( array $valueList ): array {
152
-		return array_map( [ $this, 'serializeItemIdSnakValue' ], $valueList );
151
+	private function serializeItemIdSnakValueList(array $valueList): array {
152
+		return array_map([$this, 'serializeItemIdSnakValue'], $valueList);
153 153
 	}
154 154
 
155 155
 	/**
156 156
 	 * @param DataValue $dataValue
157 157
 	 * @return array the data value in array form
158 158
 	 */
159
-	private function serializeDataValue( DataValue $dataValue ): array {
159
+	private function serializeDataValue(DataValue $dataValue): array {
160 160
 		return $dataValue->toArray();
161 161
 	}
162 162
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param string $contextType one of the Context::TYPE_* constants
165 165
 	 * @return string the abbreviated context type
166 166
 	 */
167
-	private function serializeContextType( string $contextType ): string {
168
-		switch ( $contextType ) {
167
+	private function serializeContextType(string $contextType): string {
168
+		switch ($contextType) {
169 169
 			case Context::TYPE_STATEMENT:
170 170
 				return 's';
171 171
 			case Context::TYPE_QUALIFIER:
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			default:
176 176
 				// @codeCoverageIgnoreStart
177 177
 				throw new LogicException(
178
-					'Unknown context type ' . $contextType
178
+					'Unknown context type '.$contextType
179 179
 				);
180 180
 				// @codeCoverageIgnoreEnd
181 181
 		}
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 * @param string[] $contextTypeList Context::TYPE_* constants
186 186
 	 * @return string[] abbreviated context types
187 187
 	 */
188
-	private function serializeContextTypeList( array $contextTypeList ): array {
189
-		return array_map( [ $this, 'serializeContextType' ], $contextTypeList );
188
+	private function serializeContextTypeList(array $contextTypeList): array {
189
+		return array_map([$this, 'serializeContextType'], $contextTypeList);
190 190
 	}
191 191
 
192 192
 	/**
193 193
 	 * @param MultilingualTextValue $text
194 194
 	 * @return mixed {@see MultilingualTextValue::getArrayValue}
195 195
 	 */
196
-	private function serializeMultilingualText( MultilingualTextValue $text ) {
196
+	private function serializeMultilingualText(MultilingualTextValue $text) {
197 197
 		return $text->getArrayValue();
198 198
 	}
199 199
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachingMetadata.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Cache;
6 6
 
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 * @param int $maxAge The maximum age of the cached value (in seconds).
32 32
 	 * @return self Indication that a value is possibly outdated by up to this many seconds.
33 33
 	 */
34
-	public static function ofMaximumAgeInSeconds( int $maxAge ): self {
35
-		Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' );
34
+	public static function ofMaximumAgeInSeconds(int $maxAge): self {
35
+		Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0');
36 36
 		$ret = new self;
37 37
 		$ret->maxAge = $maxAge;
38 38
 		return $ret;
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * @param array|null $array As returned by toArray.
44 44
 	 * @return self
45 45
 	 */
46
-	public static function ofArray( array $array = null ): self {
46
+	public static function ofArray(array $array = null): self {
47 47
 		$ret = new self;
48
-		if ( $array !== null ) {
48
+		if ($array !== null) {
49 49
 			$ret->maxAge = $array['maximumAgeInSeconds'];
50 50
 		}
51 51
 		return $ret;
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 * @param self[] $metadatas
56 56
 	 * @return self
57 57
 	 */
58
-	public static function merge( array $metadatas ): self {
59
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
58
+	public static function merge(array $metadatas): self {
59
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
60 60
 		$ret = new self;
61
-		foreach ( $metadatas as $metadata ) {
62
-			$ret->maxAge = max( $ret->maxAge, $metadata->maxAge );
61
+		foreach ($metadatas as $metadata) {
62
+			$ret->maxAge = max($ret->maxAge, $metadata->maxAge);
63 63
 		}
64 64
 		return $ret;
65 65
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * For a fresh value, returns 0.
78 78
 	 */
79 79
 	public function getMaximumAgeInSeconds(): int {
80
-		if ( is_int( $this->maxAge ) ) {
80
+		if (is_int($this->maxAge)) {
81 81
 			return $this->maxAge;
82 82
 		} else {
83 83
 			return 0;
@@ -92,8 +92,7 @@  discard block
 block discarded – undo
92 92
 		return $this->isCached() ?
93 93
 			[
94 94
 				'maximumAgeInSeconds' => $this->maxAge,
95
-			] :
96
-			null;
95
+			] : null;
97 96
 	}
98 97
 
99 98
 }
Please login to merge, or discard this patch.
src/Api/ExpiryLock.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private BagOStuff $cache;
23 23
 
24
-	public function __construct( BagOStuff $cache ) {
24
+	public function __construct(BagOStuff $cache) {
25 25
 		$this->cache = $cache;
26 26
 	}
27 27
 
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @throws \Wikimedia\Assert\ParameterTypeException
34 34
 	 */
35
-	private function makeKey( string $id ): string {
36
-		if ( trim( $id ) === '' ) {
37
-			throw new ParameterTypeException( '$id', 'non-empty string' );
35
+	private function makeKey(string $id): string {
36
+		if (trim($id) === '') {
37
+			throw new ParameterTypeException('$id', 'non-empty string');
38 38
 		}
39 39
 
40 40
 		return $this->cache->makeKey(
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @throws \Wikimedia\Assert\ParameterTypeException
54 54
 	 */
55
-	public function lock( string $id, ConvertibleTimestamp $expiryTimestamp ): bool {
55
+	public function lock(string $id, ConvertibleTimestamp $expiryTimestamp): bool {
56 56
 
57
-		$cacheId = $this->makeKey( $id );
57
+		$cacheId = $this->makeKey($id);
58 58
 
59
-		if ( !$this->isLockedInternal( $cacheId ) ) {
59
+		if (!$this->isLockedInternal($cacheId)) {
60 60
 			return $this->cache->set(
61 61
 				$cacheId,
62
-				$expiryTimestamp->getTimestamp( TS_UNIX ),
63
-				(int)$expiryTimestamp->getTimestamp( TS_UNIX )
62
+				$expiryTimestamp->getTimestamp(TS_UNIX),
63
+				(int) $expiryTimestamp->getTimestamp(TS_UNIX)
64 64
 			);
65 65
 		} else {
66 66
 			return false;
@@ -74,20 +74,20 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @throws \Wikimedia\Assert\ParameterTypeException
76 76
 	 */
77
-	private function isLockedInternal( string $cacheId ): bool {
78
-		$expiryTime = $this->cache->get( $cacheId );
79
-		if ( !$expiryTime ) {
77
+	private function isLockedInternal(string $cacheId): bool {
78
+		$expiryTime = $this->cache->get($cacheId);
79
+		if (!$expiryTime) {
80 80
 			return false;
81 81
 		}
82 82
 
83 83
 		try {
84
-			$lockExpiryTimeStamp = new ConvertibleTimestamp( $expiryTime );
85
-		} catch ( TimestampException $exception ) {
84
+			$lockExpiryTimeStamp = new ConvertibleTimestamp($expiryTime);
85
+		} catch (TimestampException $exception) {
86 86
 			return false;
87 87
 		}
88 88
 
89 89
 		$now = new ConvertibleTimestamp();
90
-		if ( $now->timestamp < $lockExpiryTimeStamp->timestamp ) {
90
+		if ($now->timestamp < $lockExpiryTimeStamp->timestamp) {
91 91
 			return true;
92 92
 		} else {
93 93
 			return false;
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @throws \Wikimedia\Assert\ParameterTypeException
103 103
 	 */
104
-	public function isLocked( string $id ): bool {
105
-		return $this->isLockedInternal( $this->makeKey( $id ) );
104
+	public function isLocked(string $id): bool {
105
+		return $this->isLockedInternal($this->makeKey($id));
106 106
 	}
107 107
 
108 108
 }
Please login to merge, or discard this patch.