Skip to content

Commit 74584f4

Browse files
committed
lint
1 parent b5c6a07 commit 74584f4

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

src/Exceptions/TwitterException.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace Felix\TwitterStream\Exceptions;
44

5-
use Exception;
6-
use JsonException;
75
use Psr\Http\Message\ResponseInterface;
86

9-
class TwitterException extends Exception
7+
class TwitterException extends \Exception
108
{
119
private const PRETTY_PRINT_FLAGS = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
1210

@@ -16,7 +14,7 @@ protected function __construct(string $message)
1614
}
1715

1816
/**
19-
* @throws JsonException
17+
* @throws \JsonException
2018
*/
2119
public static function fromResponse(ResponseInterface $response): TwitterException
2220
{
@@ -26,7 +24,7 @@ public static function fromResponse(ResponseInterface $response): TwitterExcepti
2624

2725
try {
2826
$body = json_decode($response->getBody()->getContents(), true, 512, flags: JSON_THROW_ON_ERROR);
29-
} catch (JsonException $e) {
27+
} catch (\JsonException $e) {
3028
return TwitterException::sprintf(
3129
'Twitter response was not valid JSON: %s (error while parsing: %s)',
3230
$response->getBody()->getContents(),
@@ -77,7 +75,7 @@ public static function sprintf(string $message, mixed ...$args): self
7775

7876
private static function handleTitleDetailErrors(array $body): self
7977
{
80-
$title = $body['title'];
78+
$title = $body['title'];
8179
$detail = $body['detail'];
8280

8381
// Remove the detail if it's the same as the title

src/Parser/Listener.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ public function key(string $key): void
113113
$this->key = $key;
114114
}
115115

116-
/**
117-
* @param mixed $value
118-
*/
119116
public function value($value): void
120117
{
121118
$obj = array_pop($this->stack);

src/Parser/Parser.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ private function consumeChar(string $char): void
128128
// valid whitespace characters in JSON (from RFC4627 for JSON) include:
129129
// space, horizontal tab, line feed or new line, and carriage return.
130130
// thanks: http://stackoverflow.com/questions/16042274/definition-of-whitespace-in-json
131-
if ((' ' === $char || "\t" === $char || "\n" === $char || "\r" === $char) &&
132-
!(self::STATE_IN_STRING === $this->state ||
133-
self::STATE_UNICODE === $this->state ||
134-
self::STATE_START_ESCAPE === $this->state ||
135-
self::STATE_IN_NUMBER === $this->state)
131+
if ((' ' === $char || "\t" === $char || "\n" === $char || "\r" === $char)
132+
&& !(self::STATE_IN_STRING === $this->state
133+
|| self::STATE_UNICODE === $this->state
134+
|| self::STATE_START_ESCAPE === $this->state
135+
|| self::STATE_IN_NUMBER === $this->state)
136136
) {
137137
// we wrap this so that we don't make a ton of unnecessary function calls
138138
// unless someone really, really cares about whitespace.
@@ -317,8 +317,8 @@ private function checkAndSkipUtfBom(string $c): bool
317317
}
318318
}
319319

320-
if (self::UTF16_BOM === $this->utfBom && 2 === $this->charNumber &&
321-
$c === \chr(254)) {
320+
if (self::UTF16_BOM === $this->utfBom && 2 === $this->charNumber
321+
&& $c === \chr(254)) {
322322
$this->utfBom = self::UTF32_BOM;
323323
}
324324

src/RuleManager.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function all(): array
1313
{
1414
$rules = $this->connection->request('GET', 'https://api.twitter.com/2/tweets/search/stream/rules');
1515

16-
return array_map(fn(array $rule) => new Rule(
16+
return array_map(fn (array $rule) => new Rule(
1717
$rule['value'],
1818
$rule['tag'] ?? null,
1919
$rule['id'] ?? null,
@@ -39,9 +39,8 @@ public function delete(Rule|string|array $ids): ?TwitterResponse
3939
return null;
4040
}
4141

42-
4342
$ids = array_filter(
44-
array_map(fn($id) => $id instanceof Rule ? $id->id : $id, $ids)
43+
array_map(fn ($id) => $id instanceof Rule ? $id->id : $id, $ids)
4544
);
4645

4746
return $this->connection->request('POST', 'https://api.twitter.com/2/tweets/search/stream/rules', [
@@ -61,7 +60,7 @@ public function validate(string $rule): array
6160
return $this->save($rule, dryRun: true)->getPayload();
6261
}
6362

64-
public function save(Rule|string $value, ?string $tag = null, bool $dryRun = false): TwitterResponse
63+
public function save(Rule|string $value, string $tag = null, bool $dryRun = false): TwitterResponse
6564
{
6665
if ($value instanceof Rule) {
6766
return $this->saveMany([$value], $dryRun);
@@ -77,7 +76,7 @@ public function saveMany(array $rules, bool $dryRun = false): TwitterResponse
7776

7877
return $this->connection->request('POST', 'https://api.twitter.com/2/tweets/search/stream/rules' . $dryRun, [
7978
'body' => [
80-
'add' => array_map(fn($rule) => ['value' => $rule->value, 'tag' => $rule->tag], $rules),
79+
'add' => array_map(fn ($rule) => ['value' => $rule->value, 'tag' => $rule->tag], $rules),
8180
],
8281
]);
8382
}

0 commit comments

Comments
 (0)