Skip to content

Commit

Permalink
CC-15974: Code issues during phpstan 7|8 upgrades. (#9159)
Browse files Browse the repository at this point in the history
CC-15974 Code issues during phpstan 7|8 upgrades
  • Loading branch information
dmiseev authored Feb 23, 2022
1 parent b55f8fa commit f461e6d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
parameters:
level: 6
level: 7
checkMissingIterableValueType: false
32 changes: 4 additions & 28 deletions psalm-report.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ protected function installLocales()
*/
protected function executeInstallLocalesTransaction(): void
{
/** @var resource $localeFile */
$localeFile = fopen($this->localeFile, 'r');

while (!feof($localeFile)) {
$locale = trim(fgets($localeFile));
/** @var string $locale */
$locale = fgets($localeFile);
$locale = trim($locale);

$query = $this->localeQueryContainer->queryLocaleByName($locale);

Expand Down
4 changes: 3 additions & 1 deletion src/Spryker/Zed/Locale/Business/Manager/LocaleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ protected function getAvailableLocaleCollection(Store $store): array
$localeTransfers = $this->localeRepository->getLocaleTransfersByLocaleNames($availableLocales);

$indexedLocaleTransfers = $this->indexLocaleTransfersByLocalename($localeTransfers);
/** @var array<\Generated\Shared\Transfer\LocaleTransfer> $availableLocales */
$availableLocales = array_intersect_key(array_flip($availableLocales), $indexedLocaleTransfers);

return array_merge(array_flip($availableLocales), $indexedLocaleTransfers);
return array_merge($availableLocales, $indexedLocaleTransfers);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Spryker/Zed/Locale/LocaleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class LocaleConfig extends AbstractBundleConfig
*/
public function getLocaleFile()
{
/** @phpstan-var string */
return realpath(__DIR__ . '/Business/Internal/Install/locales.txt');
}
}
18 changes: 18 additions & 0 deletions tests/SprykerTest/Zed/Locale/Business/LocaleFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class LocaleFacadeTest extends Unit
*/
protected $localeNames = [];

/**
* @var \SprykerTest\Zed\Locale\LocaleBusinessTester
*/
protected $tester;

/**
* @return void
*/
Expand Down Expand Up @@ -105,4 +110,17 @@ public function testCurrentLocaleIsChangeable(): void
//Assert
$this->assertSame($currentLocale->getLocaleName(), $newCurrentLocale->getLocaleName());
}

/**
* @return void
*/
public function testGetLocaleCollectionGetsLocalesFromStoreInstance(): void
{
// Act
$localeTransfers = $this->localeFacade->getLocaleCollection();

// Assert
$this->assertSame('en_US', array_keys($localeTransfers)[0]);
$this->assertSame('de_DE', array_keys($localeTransfers)[1]);
}
}

0 comments on commit f461e6d

Please sign in to comment.