Skip to content

Commit

Permalink
PHP Stan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Nov 1, 2021
1 parent 3a2eb12 commit db2873c
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Classes/Event/DetectUserLanguages.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ final class DetectUserLanguages extends AbstractEvent
{
private SiteInterface $site;
private ServerRequestInterface $request;

/** @var array<string> */
private array $userLanguages = [];

public function __construct(SiteInterface $site, ServerRequestInterface $request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

class DisableLanguageDetectionException extends AbstractHandlerException
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
parent::__construct('Disable language detection', 1_236_781, $previous);
}
protected $message = 'Disable language detection';

protected $code = 1_236_781;
}
7 changes: 3 additions & 4 deletions Classes/Handler/Exception/NoResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

class NoResponseException extends AbstractHandlerException
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
parent::__construct('No response was created', 7_829_342, $previous);
}
protected $message = 'No response was created';

protected $code = 7_829_342;
}
7 changes: 3 additions & 4 deletions Classes/Handler/Exception/NoSelectedLanguageException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

class NoSelectedLanguageException extends AbstractHandlerException
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
parent::__construct('No selectable language', 2_374_892, $previous);
}
protected $message = 'No selectable language';

protected $code = 2_374_892;
}
7 changes: 3 additions & 4 deletions Classes/Handler/Exception/NoUserLanguagesException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

class NoUserLanguagesException extends AbstractHandlerException
{
public function __construct($message = '', $code = 0, Throwable $previous = null)
{
parent::__construct('No user languages', 3_284_924, $previous);
}
protected $message = 'No user languages';

protected $code = 3_284_924;
}
2 changes: 1 addition & 1 deletion Tests/Unit/Check/FromCurrentPageListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testInvalidReferrer(string $referrer, string $baseUri, bool $isS
}

/**
* @return array<int, array<string|bool>>
* @return array<string, array<int, bool|string>>
*/
public function data(): array
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Detect/BrowserLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testClassIsInvokable(): void
* @covers \LD\LanguageDetection\Detect\BrowserLanguage
* @covers \LD\LanguageDetection\Event\DetectUserLanguages
*
* @param mixed[]|string[] $result
* @param string[] $result
*/
public function testFetchLanguageResults(string $acceptLanguage, array $result): void
{
Expand All @@ -42,7 +42,7 @@ public function testFetchLanguageResults(string $acceptLanguage, array $result):
}

/**
* @return array<int, mixed[]>
* @return array<string, array<int, array<int, string>|string>>
*/
public function data(): array
{
Expand Down
1 change: 1 addition & 0 deletions Tests/Unit/Handler/LanguageDetectionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class LanguageDetectionHandlerTest extends AbstractTest
public function testBreakAfterCheckLanguageDetectionByAddingBotAgent(): void
{
self::expectException(DisableLanguageDetectionException::class);
self::expectExceptionCode(1_236_781);

$serverRequest = new ServerRequest(null, null, 'php://input', ['user-agent' => 'AdsBot-Google']);
$serverRequest = $serverRequest->withAttribute('site', new Site('dummy', 1, []));
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Negotiation/FallbackNegotiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FallbackNegotiationTest extends AbstractTest
* @covers \LD\LanguageDetection\Negotiation\FallbackNegotiation
* @dataProvider dataInvalid
*
* @param string|int[] $configuration
* @param array $configuration
*/
public function testInvalidFallbackLanguages(array $configuration): void
{
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testValidConfigurationButNoFallback(): void
}

/**
* @return array<int, mixed[]>
* @return array<string, array<int, array<string, array<int, int>|string>>>
*/
public function dataInvalid(): array
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Service/NormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testNormalizeList(): void
}

/**
* @return array<int, array<string>>
* @return array<string, array<int, string>>
*/
public function normalizeProvider(): array
{
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"typo3/testing-framework": "^6.1",
"phpmetrics/phpmetrics": "^2.4",
"friendsofphp/php-cs-fixer": "^2.16",
"rector/rector": "^0.11.53"
"rector/rector": "dev-main",
"phpstan/phpstan": "^1.0"
},
"config": {
"vendor-dir": ".Build/vendor",
Expand All @@ -63,6 +64,9 @@
"code:metrics": [
"phpmetrics --report-html='.Build/Metrics' --exclude='.Build' --exclude='Tests' ."
],
"code:phpstan": [
"phpstan analyse -l 3 Classes Tests"
],
"test": [
"phpunit -c phpunit.xml --coverage-text --testdox"
]
Expand Down

0 comments on commit db2873c

Please sign in to comment.