Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dev dependency on laminas/laminas-cache-storage-deprecated-factory #142

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"require-dev": {
"laminas/laminas-cache": "^3.12.1",
"laminas/laminas-cache-storage-adapter-memory": "^2.3.0",
"laminas/laminas-cache-storage-deprecated-factory": "^1.2",
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-config": "^3.9.0",
"laminas/laminas-eventmanager": "^3.13",
Expand Down
61 changes: 1 addition & 60 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@
<code><![CDATA[$file['type']]]></code>
<code><![CDATA[$file['type']]]></code>
<code><![CDATA[$loaderType]]></code>
<code><![CDATA[$options['cache']]]></code>
<code><![CDATA[$pattern['base_dir']]]></code>
<code><![CDATA[$pattern['pattern']]]></code>
<code><![CDATA[$pattern['pattern']]]></code>
Expand Down
4 changes: 4 additions & 0 deletions src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ public static function factory($options)
if ($options['cache'] instanceof CacheStorage) {
$translator->setCache($options['cache']);
} else {
/**
* @psalm-suppress UndefinedClass
* @psalm-suppress MixedArgument
*/
$translator->setCache(Cache\StorageFactory::factory($options['cache']));
}
}
Expand Down
12 changes: 5 additions & 7 deletions test/Translator/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace LaminasTest\I18n\Translator;

use Laminas\Cache\Storage\Adapter\Memory;
use Laminas\Cache\Storage\StorageInterface;
use Laminas\Cache\StorageFactory as CacheFactory;
use Laminas\EventManager\Event;
use Laminas\EventManager\EventInterface;
use Laminas\I18n\Translator\TextDomain;
Expand Down Expand Up @@ -133,9 +133,7 @@ public function testFactoryCreatesTranslatorWithCache(): void
'pattern' => 'translation-%s.php',
],
],
'cache' => [
'adapter' => 'memory',
],
'cache' => new Memory(),
]);

self::assertInstanceOf(Translator::class, $translator);
Expand Down Expand Up @@ -172,7 +170,7 @@ public function testTranslate(): void

public function testTranslationsLoadedFromCache(): void
{
$cache = CacheFactory::factory(['adapter' => 'memory']);
$cache = new Memory();
$this->translator->setCache($cache);

$cache->addItem(
Expand All @@ -185,7 +183,7 @@ public function testTranslationsLoadedFromCache(): void

public function testTranslationsAreStoredInCache(): void
{
$cache = CacheFactory::factory(['adapter' => 'memory']);
$cache = new Memory();
$this->translator->setCache($cache);

$loader = new TestLoader();
Expand All @@ -208,7 +206,7 @@ public function testTranslationsAreClearedFromCache(): void
$textDomain = 'default';
$locale = 'en_EN';

$cache = CacheFactory::factory(['adapter' => 'memory']);
$cache = new Memory();
$this->translator->setCache($cache);

$cache->addItem(
Expand Down