Skip to content

Commit 23db6ff

Browse files
authored
Merge pull request #6931 from kenjis/update-psalm-5.0
chore: update psalm to 5.0
2 parents f414d79 + 7483823 commit 23db6ff

7 files changed

Lines changed: 25 additions & 7 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"phpunit/phpunit": "^9.1",
2727
"predis/predis": "^1.1 || ^2.0",
2828
"rector/rector": "0.14.8",
29-
"vimeo/psalm": "^4.26"
29+
"vimeo/psalm": "^5.0"
3030
},
3131
"suggest": {
3232
"ext-curl": "If you use CURLRequest class",

system/Cookie/Cookie.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
* $cookie2 = $cookie->withName('prod_cookie');
3838
* $cookie2->getName(); // prod_cookie
3939
* ```
40+
*
41+
* @template-implements ArrayAccess<string, bool|int|string>
4042
*/
4143
class Cookie implements ArrayAccess, CloneableCookieInterface
4244
{
@@ -564,7 +566,7 @@ public function withRaw(bool $raw = true)
564566
/**
565567
* Whether an offset exists.
566568
*
567-
* @param mixed $offset
569+
* @param string $offset
568570
*/
569571
public function offsetExists($offset): bool
570572
{
@@ -574,9 +576,9 @@ public function offsetExists($offset): bool
574576
/**
575577
* Offset to retrieve.
576578
*
577-
* @param mixed $offset
579+
* @param string $offset
578580
*
579-
* @return mixed
581+
* @return bool|int|string
580582
*
581583
* @throws InvalidArgumentException
582584
*/
@@ -593,8 +595,8 @@ public function offsetGet($offset)
593595
/**
594596
* Offset to set.
595597
*
596-
* @param mixed $offset
597-
* @param mixed $value
598+
* @param string $offset
599+
* @param mixed $value
598600
*
599601
* @throws LogicException
600602
*/
@@ -606,7 +608,7 @@ public function offsetSet($offset, $value): void
606608
/**
607609
* Offset to unset.
608610
*
609-
* @param mixed $offset
611+
* @param string $offset
610612
*
611613
* @throws LogicException
612614
*/

system/Database/BaseConnection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,15 +1006,18 @@ public function protectIdentifiers($item, bool $prefixSingle = false, ?bool $pro
10061006
// Added exception for single quotes as well, we don't want to alter
10071007
// literal strings.
10081008
if (strcspn($item, "()'") !== strlen($item)) {
1009+
/** @psalm-suppress NoValue I don't know why ERROR. */
10091010
return $item;
10101011
}
10111012

10121013
// Do not protect identifiers and do not prefix, no swap prefix, there is nothing to do
10131014
if ($protectIdentifiers === false && $prefixSingle === false && $this->swapPre === '') {
1015+
/** @psalm-suppress NoValue I don't know why ERROR. */
10141016
return $item;
10151017
}
10161018

10171019
// Convert tabs or multiple spaces into single spaces
1020+
/** @psalm-suppress NoValue I don't know why ERROR. */
10181021
$item = preg_replace('/\s+/', ' ', trim($item));
10191022

10201023
// If the item has an alias declaration we remove it and set it aside.
@@ -1176,6 +1179,7 @@ public function escapeIdentifiers($item)
11761179
}
11771180

11781181
foreach ($this->reservedIdentifiers as $id) {
1182+
/** @psalm-suppress NoValue I don't know why ERROR. */
11791183
if (strpos($item, '.' . $id) !== false) {
11801184
return preg_replace(
11811185
'/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?\./i',
@@ -1185,6 +1189,7 @@ public function escapeIdentifiers($item)
11851189
}
11861190
}
11871191

1192+
/** @psalm-suppress NoValue I don't know why ERROR. */
11881193
return preg_replace(
11891194
'/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?(\.)?/i',
11901195
$this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '$2',
@@ -1228,6 +1233,7 @@ public function escape($str)
12281233
return array_map([&$this, 'escape'], $str);
12291234
}
12301235

1236+
/** @psalm-suppress NoValue I don't know why ERROR. */
12311237
if (is_string($str) || (is_object($str) && method_exists($str, '__toString'))) {
12321238
if ($str instanceof RawSql) {
12331239
return $str->__toString();

system/Database/Postgre/Connection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ public function escape($str)
188188
$this->initialize();
189189
}
190190

191+
/** @psalm-suppress NoValue I don't know why ERROR. */
191192
if (is_string($str) || (is_object($str) && method_exists($str, '__toString'))) {
192193
if ($str instanceof RawSql) {
193194
return $str->__toString();
@@ -200,6 +201,7 @@ public function escape($str)
200201
return $str ? 'TRUE' : 'FALSE';
201202
}
202203

204+
/** @psalm-suppress NoValue I don't know why ERROR. */
203205
return parent::escape($str);
204206
}
205207

system/Files/FileCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*
2424
* Representation for a group of files, with utilities for locating,
2525
* filtering, and ordering them.
26+
*
27+
* @template-implements IteratorAggregate<int, File>
2628
*/
2729
class FileCollection implements Countable, IteratorAggregate
2830
{

system/Test/Mock/MockConnection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use CodeIgniter\Database\BaseResult;
1717
use CodeIgniter\Database\Query;
1818

19+
/**
20+
* @extends BaseConnection<object|resource, object|resource>
21+
*/
1922
class MockConnection extends BaseConnection
2023
{
2124
protected $returnValues = [];

system/Test/Mock/MockResult.php

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

1414
use CodeIgniter\Database\BaseResult;
1515

16+
/**
17+
* @extends BaseResult<object|resource, object|resource>
18+
*/
1619
class MockResult extends BaseResult
1720
{
1821
/**

0 commit comments

Comments
 (0)