-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CacheInterface.stubphp from symfony contracts (#74)
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Symfony\Contracts\Cache; | ||
|
||
use Psr\Cache\CacheItemInterface; | ||
|
||
interface CacheInterface | ||
{ | ||
/** | ||
* @template T | ||
* | ||
* @psalm-param CallbackInterface|callable(CacheItemInterface, bool): T $callback | ||
* @psalm-return T | ||
*/ | ||
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@symfony-common | ||
Feature: CacheInterface | ||
|
||
Background: | ||
Given I have the following config | ||
""" | ||
<?xml version="1.0"?> | ||
<psalm errorLevel="1"> | ||
<projectFiles> | ||
<directory name="."/> | ||
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles> | ||
</projectFiles> | ||
<plugins> | ||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/> | ||
</plugins> | ||
</psalm> | ||
""" | ||
|
||
Scenario: CacheInterface::get has the same return type as the passed callback | ||
Given I have the following code | ||
""" | ||
<?php | ||
use Psr\Cache\CacheItemInterface; | ||
use Symfony\Contracts\Cache\CacheInterface; | ||
function test(CacheInterface $cache): stdClass | ||
{ | ||
return $cache->get('key', function (CacheItemInterface $item, bool &$save): stdClass { | ||
return new stdClass(); | ||
}); | ||
} | ||
""" | ||
When I run Psalm | ||
Then I see no errors |