Skip to content

Commit af68358

Browse files
authored
refactor: fix phpstan errors in mock classes (#9594)
1 parent c2f9731 commit af68358

23 files changed

+126
-183
lines changed

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class BaseBuilder
256256
* Specifies which sql statements
257257
* support the ignore option.
258258
*
259-
* @var array
259+
* @var array<string, string>
260260
*/
261261
protected $supportedIgnoreStatements = [];
262262

system/Database/BaseResult.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ abstract protected function fetchAssoc();
529529
/**
530530
* Returns the result set as an object.
531531
*
532-
* Overridden by child classes.
532+
* @param class-string $className
533533
*
534-
* @return Entity|false|object|stdClass
534+
* @return false|object
535535
*/
536-
abstract protected function fetchObject(string $className = 'stdClass');
536+
abstract protected function fetchObject(string $className = stdClass::class);
537537
}

system/Database/MySQLi/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Builder extends BaseBuilder
3333
* Specifies which sql statements
3434
* support the ignore option.
3535
*
36-
* @var array
36+
* @var array<string, string>
3737
*/
3838
protected $supportedIgnoreStatements = [
3939
'update' => 'IGNORE',

system/Database/Postgre/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Builder extends BaseBuilder
3636
* Specifies which sql statements
3737
* support the ignore option.
3838
*
39-
* @var array
39+
* @var array<string, string>
4040
*/
4141
protected $supportedIgnoreStatements = [
4242
'insert' => 'ON CONFLICT DO NOTHING',

system/Database/SQLite3/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Builder extends BaseBuilder
4949
];
5050

5151
/**
52-
* @var array
52+
* @var array<string, string>
5353
*/
5454
protected $supportedIgnoreStatements = [
5555
'insert' => 'OR IGNORE',

system/HTTP/CURLRequest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ protected function setCURLOptions(array $curlOptions = [], array $config = [])
696696
* Does the actual work of initializing cURL, setting the options,
697697
* and grabbing the output.
698698
*
699+
* @param array<int, mixed> $curlOptions
700+
*
699701
* @codeCoverageIgnore
700702
*/
701703
protected function sendRequest(array $curlOptions = []): string

system/Test/Mock/MockBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
class MockBuilder extends BaseBuilder
1919
{
20+
/**
21+
* @var array<string, string>
22+
*/
2023
protected $supportedIgnoreStatements = [
2124
'update' => 'IGNORE',
2225
'insert' => 'IGNORE',

system/Test/Mock/MockCLIConfig.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717

1818
class MockCLIConfig extends App
1919
{
20-
public string $baseURL = 'http://example.com/';
21-
public string $uriProtocol = 'REQUEST_URI';
22-
public array $proxyIPs = [];
23-
public string $CSRFTokenName = 'csrf_test_name';
24-
public string $CSRFCookieName = 'csrf_cookie_name';
25-
public int $CSRFExpire = 7200;
26-
public bool $CSRFRegenerate = true;
27-
public $CSRFExcludeURIs = ['http://example.com'];
20+
public string $baseURL = 'http://example.com/';
21+
public string $uriProtocol = 'REQUEST_URI';
22+
public array $proxyIPs = [];
23+
public string $CSRFTokenName = 'csrf_test_name';
24+
public string $CSRFCookieName = 'csrf_cookie_name';
25+
public int $CSRFExpire = 7200;
26+
public bool $CSRFRegenerate = true;
27+
28+
/**
29+
* @var list<string>
30+
*/
31+
public array $CSRFExcludeURIs = ['http://example.com'];
32+
2833
public string $CSRFSameSite = 'Lax';
2934
public bool $CSPEnabled = false;
3035
public string $defaultLocale = 'en';

system/Test/Mock/MockCURLRequest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
*/
2424
class MockCURLRequest extends CURLRequest
2525
{
26+
/**
27+
* @var array<int, mixed>
28+
*/
2629
public $curl_options;
30+
31+
/**
32+
* @var string
33+
*/
2734
protected $output = '';
2835

2936
/**
@@ -38,11 +45,13 @@ public function setOutput($output)
3845
return $this;
3946
}
4047

48+
/**
49+
* @param array<int, mixed> $curlOptions
50+
*/
4151
protected function sendRequest(array $curlOptions = []): string
4252
{
4353
$this->response = clone $this->responseOrig;
4454

45-
// Save so we can access later.
4655
$this->curl_options = $curlOptions;
4756

4857
return $this->output;

system/Test/Mock/MockCache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,9 @@ public function getCacheInfo()
214214
/**
215215
* Returns detailed information about the specific item in the cache.
216216
*
217-
* @return array|null Returns null if the item does not exist, otherwise array<string, mixed>
218-
* with at least the 'expire' key for absolute epoch expiry (or null).
217+
* @return array{expire: int|null}|null Returns null if the item does not exist,
218+
* otherwise, array with the 'expire' key for
219+
* absolute epoch expiry (or null).
219220
*/
220221
public function getMetaData(string $key)
221222
{

0 commit comments

Comments
 (0)