Skip to content

Commit

Permalink
Merge pull request codeigniter4#8612 from kenjis/fix-MockCache-phpsta…
Browse files Browse the repository at this point in the history
…n-errors

docs: add/fix PHPDoc types in MockCache
  • Loading branch information
kenjis authored Mar 10, 2024
2 parents bcb88b4 + 731e891 commit 9342e38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
30 changes: 0 additions & 30 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -3106,36 +3106,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockCURLRequest.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot unset offset string on array\\<int, int\\>\\|null\\.$#',
'count' => 2,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:assertHas\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:assertHasValue\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:assertMissing\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Return type \\(mixed\\) of method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:get\\(\\) should be covariant with return type \\(array\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method CodeIgniter\\\\Cache\\\\CacheInterface\\:\\:get\\(\\)$#',
'count' => 2,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Return type \\(mixed\\) of method CodeIgniter\\\\Test\\\\Mock\\\\MockCache\\:\\:remember\\(\\) should be covariant with return type \\(array\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method CodeIgniter\\\\Cache\\\\Handlers\\\\BaseHandler\\:\\:remember\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/system/Test/Mock/MockCache.php',
];
$ignoreErrors[] = [
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
'count' => 2,
Expand Down
10 changes: 8 additions & 2 deletions system/Test/Mock/MockCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function initialize()
*
* @param string $key Cache item name
*
* @return mixed
* @return bool|null
*/
public function get(string $key)
{
Expand All @@ -66,7 +66,7 @@ public function get(string $key)
/**
* Get an item from the cache, or execute the given Closure and store the result.
*
* @return mixed
* @return bool|null
*/
public function remember(string $key, int $ttl, Closure $callback)
{
Expand Down Expand Up @@ -266,6 +266,8 @@ public function bypass(bool $bypass = true)
* Asserts that the cache has an item named $key.
* The value is not checked since storing false or null
* values is valid.
*
* @return void
*/
public function assertHas(string $key)
{
Expand All @@ -276,6 +278,8 @@ public function assertHas(string $key)
* Asserts that the cache has an item named $key with a value matching $value.
*
* @param mixed $value
*
* @return void
*/
public function assertHasValue(string $key, $value = null)
{
Expand All @@ -292,6 +296,8 @@ public function assertHasValue(string $key, $value = null)

/**
* Asserts that the cache does NOT have an item named $key.
*
* @return void
*/
public function assertMissing(string $key)
{
Expand Down

0 comments on commit 9342e38

Please sign in to comment.