Skip to content

Commit f8b64d3

Browse files
authored
Update PHPCS (#1599)
1 parent a8901b2 commit f8b64d3

File tree

73 files changed

+358
-420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+358
-420
lines changed

.github/workflows/static-analysis.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2
2020
with:
21-
php-version: '8.1'
21+
php-version: '8.2'
2222

2323
- name: Install dependencies
2424
run: composer update --no-progress --no-interaction --prefer-dist

.php-cs-fixer.dist.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010
'imports_order' => ['class', 'function', 'const'],
1111
],
1212
'declare_strict_types' => true,
13-
'yoda_style' => true,
13+
'get_class_to_class_keyword' => false,
14+
'yoda_style' => [
15+
'equal' => false,
16+
'identical' => false,
17+
'less_and_greater' => false,
18+
],
1419
'self_accessor' => false,
15-
'phpdoc_no_useless_inheritdoc' => false,
20+
'modernize_strpos' => false,
21+
'nullable_type_declaration_for_default_null_value' => [
22+
'use_nullable_type_declaration' => true,
23+
],
24+
'no_superfluous_phpdoc_tags' => [
25+
'allow_mixed' => true,
26+
],
1627
'phpdoc_to_comment' => false,
1728
'phpdoc_align' => [
1829
'tags' => ['param', 'return', 'throws', 'type', 'var'],

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"symfony/options-resolver": "^4.4.30|^5.0.11|^6.0|^7.0"
3030
},
3131
"require-dev": {
32-
"friendsofphp/php-cs-fixer": "^2.19|3.4.*",
32+
"friendsofphp/php-cs-fixer": "^3.4",
3333
"guzzlehttp/promises": "^1.0|^2.0",
3434
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
3535
"http-interop/http-factory-guzzle": "^1.0",

phpstan-baseline.neon

-70
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ parameters:
55
count: 1
66
path: src/Client.php
77

8-
-
9-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$hint$#"
10-
count: 3
11-
path: src/ClientInterface.php
12-
138
-
149
message: "#^Offset 'host' does not exist on array\\{scheme\\: 'http'\\|'https', host\\?\\: string, port\\?\\: int\\<0, 65535\\>, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\?\\: string, fragment\\?\\: string\\}\\.$#"
1510
count: 1
@@ -240,51 +235,6 @@ parameters:
240235
count: 1
241236
path: src/Serializer/AbstractSerializer.php
242237

243-
-
244-
message: "#^Method Sentry\\\\ClientInterface\\:\\:captureException\\(\\) invoked with 3 parameters, 1\\-2 required\\.$#"
245-
count: 1
246-
path: src/State/Hub.php
247-
248-
-
249-
message: "#^Method Sentry\\\\ClientInterface\\:\\:captureLastError\\(\\) invoked with 2 parameters, 0\\-1 required\\.$#"
250-
count: 1
251-
path: src/State/Hub.php
252-
253-
-
254-
message: "#^Method Sentry\\\\ClientInterface\\:\\:captureMessage\\(\\) invoked with 4 parameters, 1\\-3 required\\.$#"
255-
count: 1
256-
path: src/State/Hub.php
257-
258-
-
259-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:captureException\\(\\) invoked with 2 parameters, 1 required\\.$#"
260-
count: 1
261-
path: src/State/HubAdapter.php
262-
263-
-
264-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:captureLastError\\(\\) invoked with 1 parameter, 0 required\\.$#"
265-
count: 1
266-
path: src/State/HubAdapter.php
267-
268-
-
269-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:captureMessage\\(\\) invoked with 3 parameters, 1\\-2 required\\.$#"
270-
count: 1
271-
path: src/State/HubAdapter.php
272-
273-
-
274-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:startTransaction\\(\\) invoked with 2 parameters, 1 required\\.$#"
275-
count: 1
276-
path: src/State/HubAdapter.php
277-
278-
-
279-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$customSamplingContext$#"
280-
count: 1
281-
path: src/State/HubInterface.php
282-
283-
-
284-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$hint$#"
285-
count: 3
286-
path: src/State/HubInterface.php
287-
288238
-
289239
message: "#^Call to method getResponse\\(\\) on an unknown class GuzzleHttp\\\\Exception\\\\RequestException\\.$#"
290240
count: 1
@@ -324,23 +274,3 @@ parameters:
324274
message: "#^Method Sentry\\\\Util\\\\JSON\\:\\:encode\\(\\) should return string but returns string\\|false\\.$#"
325275
count: 1
326276
path: src/Util/JSON.php
327-
328-
-
329-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:captureException\\(\\) invoked with 2 parameters, 1 required\\.$#"
330-
count: 1
331-
path: src/functions.php
332-
333-
-
334-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:captureLastError\\(\\) invoked with 1 parameter, 0 required\\.$#"
335-
count: 1
336-
path: src/functions.php
337-
338-
-
339-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:captureMessage\\(\\) invoked with 3 parameters, 1\\-2 required\\.$#"
340-
count: 1
341-
path: src/functions.php
342-
343-
-
344-
message: "#^Method Sentry\\\\State\\\\HubInterface\\:\\:startTransaction\\(\\) invoked with 2 parameters, 1 required\\.$#"
345-
count: 1
346-
path: src/functions.php

src/CheckIn.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final class CheckIn
4949
public function __construct(
5050
string $monitorSlug,
5151
CheckInStatus $status,
52-
string $id = null,
52+
?string $id = null,
5353
?string $release = null,
5454
?string $environment = null,
5555
$duration = null,

src/Client.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function getCspReportUrl(): ?string
115115
{
116116
$dsn = $this->options->getDsn();
117117

118-
if (null === $dsn) {
118+
if ($dsn === null) {
119119
return null;
120120
}
121121

@@ -151,7 +151,7 @@ public function captureException(\Throwable $exception, ?Scope $scope = null, ?E
151151
{
152152
$hint = $hint ?? new EventHint();
153153

154-
if (null === $hint->exception) {
154+
if ($hint->exception === null) {
155155
$hint->exception = $exception;
156156
}
157157

@@ -165,7 +165,7 @@ public function captureEvent(Event $event, ?EventHint $hint = null, ?Scope $scop
165165
{
166166
$event = $this->prepareEvent($event, $hint, $scope);
167167

168-
if (null === $event) {
168+
if ($event === null) {
169169
return null;
170170
}
171171

@@ -174,7 +174,7 @@ public function captureEvent(Event $event, ?EventHint $hint = null, ?Scope $scop
174174
$result = $this->transport->send($event);
175175
$event = $result->getEvent();
176176

177-
if (null !== $event) {
177+
if ($event !== null) {
178178
return $event->getId();
179179
}
180180
} catch (\Throwable $exception) {
@@ -194,7 +194,7 @@ public function captureLastError(?Scope $scope = null, ?EventHint $hint = null):
194194
{
195195
$error = error_get_last();
196196

197-
if (null === $error || !isset($error['message'][0])) {
197+
if ($error === null || !isset($error['message'][0])) {
198198
return null;
199199
}
200200

@@ -241,12 +241,12 @@ public function getStacktraceBuilder(): StacktraceBuilder
241241
*/
242242
private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $scope = null): ?Event
243243
{
244-
if (null !== $hint) {
245-
if (null !== $hint->exception && empty($event->getExceptions())) {
244+
if ($hint !== null) {
245+
if ($hint->exception !== null && empty($event->getExceptions())) {
246246
$this->addThrowableToEvent($event, $hint->exception, $hint);
247247
}
248248

249-
if (null !== $hint->stacktrace && null === $event->getStacktrace()) {
249+
if ($hint->stacktrace !== null && $event->getStacktrace() === null) {
250250
$event->setStacktrace($hint->stacktrace);
251251
}
252252
}
@@ -257,19 +257,19 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco
257257
$event->setSdkVersion($this->sdkVersion);
258258
$event->setTags(array_merge($this->options->getTags(), $event->getTags()));
259259

260-
if (null === $event->getServerName()) {
260+
if ($event->getServerName() === null) {
261261
$event->setServerName($this->options->getServerName());
262262
}
263263

264-
if (null === $event->getRelease()) {
264+
if ($event->getRelease() === null) {
265265
$event->setRelease($this->options->getRelease());
266266
}
267267

268-
if (null === $event->getEnvironment()) {
268+
if ($event->getEnvironment() === null) {
269269
$event->setEnvironment($this->options->getEnvironment() ?? Event::DEFAULT_ENVIRONMENT);
270270
}
271271

272-
if (null === $event->getLogger()) {
272+
if ($event->getLogger() === null) {
273273
$event->setLogger($this->options->getLogger(false));
274274
}
275275

@@ -284,15 +284,15 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco
284284

285285
$event = $this->applyIgnoreOptions($event);
286286

287-
if (null === $event) {
287+
if ($event === null) {
288288
return null;
289289
}
290290

291-
if (null !== $scope) {
291+
if ($scope !== null) {
292292
$beforeEventProcessors = $event;
293293
$event = $scope->applyToEvent($event, $hint, $this->options);
294294

295-
if (null === $event) {
295+
if ($event === null) {
296296
$this->logger->info(
297297
'The event will be discarded because one of the event processors returned "null".',
298298
['event' => $beforeEventProcessors]
@@ -305,7 +305,7 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco
305305
$beforeSendCallback = $event;
306306
$event = $this->applyBeforeSendCallback($event, $hint);
307307

308-
if (null === $event) {
308+
if ($event === null) {
309309
$this->logger->info(
310310
sprintf(
311311
'The event will be discarded because the "%s" callback returned "null".',
@@ -344,7 +344,7 @@ private function applyIgnoreOptions(Event $event): ?Event
344344
if ($event->getType() === EventType::transaction()) {
345345
$transactionName = $event->getTransaction();
346346

347-
if (null === $transactionName) {
347+
if ($transactionName === null) {
348348
return $event;
349349
}
350350

@@ -397,7 +397,7 @@ private function addMissingStacktraceToEvent(Event $event): void
397397
}
398398

399399
// We should not add a stacktrace when the event already has one or contains exceptions
400-
if (null !== $event->getStacktrace() || !empty($event->getExceptions())) {
400+
if ($event->getStacktrace() !== null || !empty($event->getExceptions())) {
401401
return;
402402
}
403403

@@ -417,7 +417,7 @@ private function addMissingStacktraceToEvent(Event $event): void
417417
*/
418418
private function addThrowableToEvent(Event $event, \Throwable $exception, EventHint $hint): void
419419
{
420-
if ($exception instanceof \ErrorException && null === $event->getLevel()) {
420+
if ($exception instanceof \ErrorException && $event->getLevel() === null) {
421421
$event->setLevel(Severity::fromError($exception->getSeverity()));
422422
}
423423

src/ClientBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ final class ClientBuilder
5959
*
6060
* @param Options|null $options The client options
6161
*/
62-
public function __construct(Options $options = null)
62+
public function __construct(?Options $options = null)
6363
{
6464
$this->options = $options ?? new Options();
6565

src/ClientInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getOptions(): Options;
3131
* @param Scope|null $scope An optional scope keeping the state
3232
* @param EventHint|null $hint Object that can contain additional information about the event
3333
*/
34-
public function captureMessage(string $message, ?Severity $level = null, ?Scope $scope = null/*, ?EventHint $hint = null*/): ?EventId;
34+
public function captureMessage(string $message, ?Severity $level = null, ?Scope $scope = null, ?EventHint $hint = null): ?EventId;
3535

3636
/**
3737
* Logs an exception.
@@ -40,15 +40,15 @@ public function captureMessage(string $message, ?Severity $level = null, ?Scope
4040
* @param Scope|null $scope An optional scope keeping the state
4141
* @param EventHint|null $hint Object that can contain additional information about the event
4242
*/
43-
public function captureException(\Throwable $exception, ?Scope $scope = null/*, ?EventHint $hint = null*/): ?EventId;
43+
public function captureException(\Throwable $exception, ?Scope $scope = null, ?EventHint $hint = null): ?EventId;
4444

4545
/**
4646
* Logs the most recent error (obtained with {@link error_get_last}).
4747
*
4848
* @param Scope|null $scope An optional scope keeping the state
4949
* @param EventHint|null $hint Object that can contain additional information about the event
5050
*/
51-
public function captureLastError(?Scope $scope = null/*, ?EventHint $hint = null*/): ?EventId;
51+
public function captureLastError(?Scope $scope = null, ?EventHint $hint = null): ?EventId;
5252

5353
/**
5454
* Captures a new event using the provided data.

src/Context/OsContext.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(
5252
?string $kernelVersion = null,
5353
?string $machineType = null
5454
) {
55-
if ('' === trim($name)) {
55+
if (trim($name) === '') {
5656
throw new \InvalidArgumentException('The $name argument cannot be an empty string.');
5757
}
5858

@@ -78,7 +78,7 @@ public function getName(): string
7878
*/
7979
public function setName(string $name): void
8080
{
81-
if ('' === trim($name)) {
81+
if (trim($name) === '') {
8282
throw new \InvalidArgumentException('The $name argument cannot be an empty string.');
8383
}
8484

src/Context/RuntimeContext.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class RuntimeContext
2929
*/
3030
public function __construct(string $name, ?string $version = null)
3131
{
32-
if ('' === trim($name)) {
32+
if (trim($name) === '') {
3333
throw new \InvalidArgumentException('The $name argument cannot be an empty string.');
3434
}
3535

@@ -52,7 +52,7 @@ public function getName(): string
5252
*/
5353
public function setName(string $name): void
5454
{
55-
if ('' === trim($name)) {
55+
if (trim($name) === '') {
5656
throw new \InvalidArgumentException('The $name argument cannot be an empty string.');
5757
}
5858

0 commit comments

Comments
 (0)