make MinutesToSecondsInCacheRector vendor code independent

This commit is contained in:
Tomas Votruba 2019-03-04 09:39:55 +01:00
parent 0311a5211f
commit 37868819b8
4 changed files with 38 additions and 16 deletions

View File

@ -21,19 +21,24 @@ final class MinutesToSecondsInCacheRector extends AbstractRector
/**
* @var int[][]
*/
private $typesToMethods = [
'Illuminate\Support\Facades\Cache' => [
'put' => 2, // time argument position
'add' => 2,
],
'Illuminate\Contracts\Cache\Store' => [
'put' => 2,
'putMany' => 1,
],
'Illuminate\Cache\DynamoDbStore' => [
'add' => 2,
],
];
private $typesToMethods = [];
public function __construct(string $storeClass = 'Illuminate\Contracts\Cache\Store')
{
$this->typesToMethods = [
'Illuminate\Support\Facades\Cache' => [
'put' => 2, // time argument position
'add' => 2,
],
$storeClass => [
'put' => 2,
'putMany' => 1,
],
'Illuminate\Cache\DynamoDbStore' => [
'add' => 2,
],
];
}
public function getDefinition(): RectorDefinition
{

View File

@ -3,6 +3,7 @@
namespace Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector;
use Rector\Laravel\Rector\StaticCall\MinutesToSecondsInCacheRector;
use Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Source\LaravelStoreInterface;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class MinutesToSecondsInCacheRectorTest extends AbstractRectorTestCase
@ -16,4 +17,14 @@ final class MinutesToSecondsInCacheRectorTest extends AbstractRectorTestCase
{
return MinutesToSecondsInCacheRector::class;
}
/**
* @return mixed[]|null
*/
protected function getRectorConfiguration(): ?array
{
return [
'$storeClass' => LaravelStoreInterface::class, // just for test case
];
}
}

View File

@ -2,9 +2,7 @@
namespace Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Source;
use Illuminate\Contracts\Cache\Store;
final class ArrayStore implements Store
final class ArrayStore implements LaravelStoreInterface
{
public function get($key)
{

View File

@ -0,0 +1,8 @@
<?php declare(strict_types=1);
namespace Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Source;
interface LaravelStoreInterface
{
}