Skip to content
241 changes: 1 addition & 240 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,241 +1,2 @@
parameters:
ignoreErrors:
-
rawMessage: 'Parameter #2 $array of function implode expects array<string>, list<mixed> given.'
identifier: argument.type
count: 1
path: src/Command/TtSyncSubticketsCommand.php

-
rawMessage: 'Parameter #2 $array of function implode expects array<string>, array<mixed> given.'
identifier: argument.type
count: 2
path: src/Service/Integration/Jira/JiraAuthenticationService.php

-
rawMessage: 'Parameter #2 $array of function implode expects array<string>, array<mixed, mixed> given.'
identifier: argument.type
count: 1
path: src/Service/Integration/Jira/JiraHttpClientService.php

-
rawMessage: 'Parameter #2 $array of function implode expects array<string>, list<mixed> given.'
identifier: argument.type
count: 1
path: src/Service/Integration/Jira/JiraHttpClientService.php

-
rawMessage: 'Parameter #1 $array of function natcasesort expects an array of values castable to string, list<mixed> given.'
identifier: argument.type
count: 1
path: src/Service/SubticketSyncService.php

-
rawMessage: 'Parameter #2 $array of function implode expects array<string>, array<int, mixed> given.'
identifier: argument.type
count: 1
path: src/Service/SubticketSyncService.php

-
rawMessage: 'Property Tests\AbstractWebTestCase::$filepath (string) on left side of ?? is not nullable.'
identifier: nullCoalesce.property
count: 1
path: tests/AbstractWebTestCase.php

-
rawMessage: Cannot access offset 'error' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 5
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: Cannot access offset 'exception' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: Cannot access offset 'message' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 5
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: Cannot access offset 'redirect_url' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Cannot call method getContent() on Symfony\Component\HttpFoundation\Response|null.'
identifier: method.nonObject
count: 3
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Dynamic call to static method PHPUnit\Framework\Assert::callback().'
identifier: staticMethod.dynamicCall
count: 3
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Method App\Tests\EventSubscriber\ExceptionSubscriberTest::provideDefaultMessages() should return array<string, array{int, string}> but returns array{400: array{400, ''The request was…''}, 401: array{401, ''Authentication is…''}, 403: array{403, ''You do not have…''}, 404: array{404, ''The requested…''}, 405: array{405, ''The request method…''}, 406: array{406, ''The requested…''}, 409: array{409, ''The request…''}, 422: array{422, ''The request was…''}, ...}.'
identifier: return.type
count: 1
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Parameter #2 $array of method PHPUnit\Framework\Assert::assertArrayHasKey() expects array<mixed>|ArrayAccess<(int|string), mixed>, mixed given.'
identifier: argument.type
count: 1
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Parameter #2 $array of method PHPUnit\Framework\Assert::assertArrayNotHasKey() expects array<mixed>|ArrayAccess<(int|string), mixed>, mixed given.'
identifier: argument.type
count: 4
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Parameter #2 $haystack of method PHPUnit\Framework\Assert::assertStringContainsString() expects string, mixed given.'
identifier: argument.type
count: 1
path: tests/EventSubscriber/ExceptionSubscriberTest.php

-
rawMessage: 'Parameter #1 $array of function array_sum expects an array of values castable to number, list<mixed> given.'
identifier: argument.type
count: 2
path: tests/Performance/PerformanceBenchmarkRunner.php

-
rawMessage: 'Parameter #1 $callbacks of method App\Service\Cache\QueryCacheService::warmUp() expects array<string, callable(): mixed>, array{key1: Closure(): ''value1'', key2: ''not_a_callable''} given.'
identifier: argument.type
count: 1
path: tests/Service/Cache/QueryCacheServiceTest.php

-
rawMessage: 'Parameter #2 $haystack of method PHPUnit\Framework\Assert::assertContains() expects iterable, mixed given.'
identifier: argument.type
count: 4
path: tests/Service/Cache/QueryCacheServiceTest.php

-
rawMessage: 'Parameter #2 $haystack of method PHPUnit\Framework\Assert::assertNotContains() expects iterable, mixed given.'
identifier: argument.type
count: 1
path: tests/Service/Cache/QueryCacheServiceTest.php

-
rawMessage: Binary operation "." between 'encrypted_' and mixed results in an error.
identifier: binaryOp.invalid
count: 3
path: tests/Service/Integration/Jira/JiraAuthenticationServiceTest.php

-
rawMessage: 'Call to method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true.'
identifier: method.alreadyNarrowedType
count: 2
path: tests/Service/Integration/Jira/JiraAuthenticationServiceTest.php

-
rawMessage: Unreachable statement - code above always terminates.
identifier: deadCode.unreachable
count: 1
path: tests/Service/Integration/Jira/JiraAuthenticationServiceTest.php

-
rawMessage: Access to an undefined property object::$id.
identifier: property.notFound
count: 1
path: tests/Service/Integration/Jira/JiraHttpClientServiceTest.php

-
rawMessage: Access to an undefined property object::$key.
identifier: property.notFound
count: 1
path: tests/Service/Integration/Jira/JiraHttpClientServiceTest.php

-
rawMessage: 'Call to method PHPUnit\Framework\Assert::assertInstanceOf() with ''GuzzleHttp\\Client'' and GuzzleHttp\Client will always evaluate to true.'
identifier: method.alreadyNarrowedType
count: 3
path: tests/Service/Integration/Jira/JiraHttpClientServiceTest.php

-
rawMessage: Cannot access property $id on mixed.
identifier: property.nonObject
count: 2
path: tests/Service/Integration/Jira/JiraHttpClientServiceTest.php

-
rawMessage: 'Parameter #1 $exception of method PHPUnit\Framework\TestCase::expectException() expects class-string<Throwable>, string given.'
identifier: argument.type
count: 1
path: tests/Service/Integration/Jira/JiraHttpClientServiceTest.php

-
rawMessage: Cannot access offset 'description' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access offset 'issuetype' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access offset 'key' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access offset 'name' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access offset 'project' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access offset 'summary' on mixed.
identifier: offsetAccess.nonOffsetAccessible
count: 3
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access property $id on mixed.
identifier: property.nonObject
count: 1
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access property $key on mixed.
identifier: property.nonObject
count: 2
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: Cannot access property $total on mixed.
identifier: property.nonObject
count: 1
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: 'Dynamic call to static method PHPUnit\Framework\Assert::callback().'
identifier: staticMethod.dynamicCall
count: 5
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php

-
rawMessage: 'Parameter #1 $haystack of function str_contains expects string, mixed given.'
identifier: argument.type
count: 4
path: tests/Service/Integration/Jira/JiraTicketServiceTest.php
ignoreErrors: []
2 changes: 1 addition & 1 deletion src/Service/Cache/QueryCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function warmUp(array $callbacks): void
/**
* Gets cache statistics.
*
* @return array<string, mixed>
* @return array{adapter: class-string, tags: list<string>, tag_count: int<0, max>}
*/
public function getStats(): array
{
Expand Down
32 changes: 28 additions & 4 deletions src/Service/Integration/Jira/JiraAuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Throwable;

use function is_array;
use function is_scalar;
use function is_string;
use function sprintf;

Expand Down Expand Up @@ -136,23 +137,46 @@
parse_str($responseBody, $tokens);

if (isset($tokens['oauth_problem'])) {
$problem = is_array($tokens['oauth_problem'])
? implode(', ', $tokens['oauth_problem'])
: $tokens['oauth_problem'];
$problem = $this->stringifyParsedValue($tokens['oauth_problem'], ', ');
throw new JiraApiException(sprintf('OAuth problem: %s', $problem), 401);
}

// Normalize to string values
$result = [];
foreach ($tokens as $key => $value) {
if (is_string($key)) {
$result[$key] = is_array($value) ? implode(',', $value) : $value;
$result[$key] = $this->stringifyParsedValue($value, ',');
}
}

return $result;
}

/**
* Recursively coerces a value parsed from {@see parse_str()} into a string.
*/
private function stringifyParsedValue(mixed $value, string $separator): string

Check warning on line 158 in src/Service/Integration/Jira/JiraAuthenticationService.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This method has 4 returns, which is more than the 3 allowed.

See more on https://sonarcloud.io/project/issues?id=netresearch_timetracker&issues=AZ39ddvTde_Mn-3XvqW1&open=AZ39ddvTde_Mn-3XvqW1&pullRequest=285
{
if (is_array($value)) {
$parts = [];
foreach ($value as $item) {
$parts[] = $this->stringifyParsedValue($item, $separator);
}

return implode($separator, $parts);
}

if (is_string($value)) {
return $value;
}

if (is_scalar($value)) {
return (string) $value;
}

return '';
}

/**
* Stores OAuth tokens for user and ticket system.
*
Expand Down
5 changes: 3 additions & 2 deletions src/Service/Integration/Jira/JiraHttpClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use UnexpectedValueException;

use function is_array;
use function is_scalar;
use function sprintf;

use const JSON_THROW_ON_ERROR;
Expand Down Expand Up @@ -271,11 +272,11 @@ private function extractErrorMessage(string $body): string
}

if (isset($data['errorMessages']) && is_array($data['errorMessages'])) {
return implode(', ', $data['errorMessages']);
return implode(', ', array_map(static fn (mixed $v): string => (string) (is_scalar($v) ? $v : ''), $data['errorMessages']));
}

if (isset($data['errors']) && is_array($data['errors'])) {
return implode(', ', array_values($data['errors']));
return implode(', ', array_map(static fn (mixed $v): string => (string) (is_scalar($v) ? $v : ''), array_values($data['errors'])));
}

return $body;
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Integration/Jira/JiraOAuthApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public function doesTicketExist(string $sTicket): bool
/**
* Get an array of ticket numbers that are subtickets of the given issue.
*
* @psalm-return list<mixed>
* @return list<string>
*/
public function getSubtickets(string $sTicket): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Integration/Jira/JiraTicketService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
*
* @throws JiraApiException
*/
public function createTicket(Entry $entry): mixed
public function createTicket(Entry $entry): object
{
$project = $entry->getProject();

Expand Down
4 changes: 1 addition & 3 deletions src/Service/SubticketSyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public function __construct(private readonly ManagerRegistry $managerRegistry, p
* @throws Exception When something goes wrong.
* Exception codes are sensible HTTP status codes
*
* @return (mixed|string)[] Array of subticket keys
*
* @psalm-return list<mixed|string>
* @return list<string> Array of subticket keys
*/
public function syncProjectSubtickets(int|Project $projectOrProjectId): array
{
Expand Down
Loading
Loading