Skip to content

Commit 4391c88

Browse files
committed
Replaced test with more extensive one on both callbacks
1 parent 653d334 commit 4391c88

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

tests/Type/Symfony/ExtensionTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public function dataFileAsserts(): iterable
2121

2222
yield from $this->gatherAssertTypes(__DIR__ . '/data/tree_builder.php');
2323

24-
if (interface_exists('\Symfony\Contracts\Cache\CacheInterface')) {
25-
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleCacheInterface.php');
26-
}
27-
2824
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleBaseCommand.php');
2925
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleOptionCommand.php');
3026
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleOptionLazyCommand.php');
@@ -56,6 +52,7 @@ public function dataFileAsserts(): iterable
5652
yield from $this->gatherAssertTypes(__DIR__ . '/data/denormalizer.php');
5753

5854
yield from $this->gatherAssertTypes(__DIR__ . '/data/FormInterface_getErrors.php');
55+
yield from $this->gatherAssertTypes(__DIR__ . '/data/cache.php');
5956
}
6057

6158
/**

tests/Type/Symfony/data/ExampleCacheInterface.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/Type/Symfony/data/cache.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Type\Symfony\cache;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
function testCacheCallable(\Symfony\Contracts\Cache\CacheInterface $cache): void {
8+
$result = $cache->get('foo', function (): string {
9+
return '';
10+
});
11+
12+
assertType('string', $result);
13+
};
14+
15+
/**
16+
* @param \Symfony\Contracts\Cache\CallbackInterface<\stdClass> $cb
17+
*/
18+
function testCacheCallbackInterface(\Symfony\Contracts\Cache\CacheInterface $cache, \Symfony\Contracts\Cache\CallbackInterface $cb): void {
19+
$result = $cache->get('foo',$cb);
20+
21+
assertType('stdClass', $result);
22+
};

0 commit comments

Comments
 (0)