diff --git a/phpstan.neon b/phpstan.neon index baa53ee..1b53a9b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,3 +29,46 @@ parameters: count: 1 message: '#^Result of && is always false\.$#' path: 'src/Latte/Macros.php' + + # ------------------------------------------------------------------- + # for back compatibility with old packages - will be remove in future + # ------------------------------------------------------------------- + - + message: """ + #^Fetching class constant class of deprecated class Nette\\\\Bridges\\\\ApplicationLatte\\\\ILatteFactory\\: + use Nette\\\\Bridges\\\\ApplicationLatte\\\\LatteFactory$# + """ + count: 1 + path: src/DI/TranslationExtension.php + + - + message: """ + #^Fetching class constant class of deprecated class Nette\\\\Localization\\\\ITranslator\\: + use Nette\\\\Localization\\\\Translator$# + """ + count: 2 + path: src/DI/TranslationExtension.php + + - + count: 1 + message: """ + #^Parameter \\$translator of method Contributte\\\\Translation\\\\Latte\\\\Filters\\:\\:__construct\\(\\) has typehint with deprecated interface Nette\\\\Localization\\\\ITranslator\\: + use Nette\\\\Localization\\\\Translator$# + """ + path: src/Latte/Filters.php + + - + count: 1 + message: """ + #^Class Contributte\\\\Translation\\\\PrefixedTranslator implements deprecated interface Nette\\\\Localization\\\\ITranslator\\: + use Nette\\\\Localization\\\\Translator$# + """ + path: src/PrefixedTranslator.php + + - + count: 1 + message: """ + #^Class Contributte\\\\Translation\\\\Translator implements deprecated interface Nette\\\\Localization\\\\ITranslator\\: + use Nette\\\\Localization\\\\Translator$# + """ + path: src/Translator.php diff --git a/src/DI/TranslationExtension.php b/src/DI/TranslationExtension.php index 0698c0e..0476fec 100644 --- a/src/DI/TranslationExtension.php +++ b/src/DI/TranslationExtension.php @@ -251,8 +251,12 @@ public function beforeCompile(): void if (count($this->config->dirs) > 0) { foreach ($this->config->loaders as $k1 => $v1) { - foreach (Finder::find('*.' . $k1)->from($this->config->dirs) as $v2) { - $match = Strings::match($v2->getFilename(), '~^(?P.*?)\.(?P[^\.]+)\.(?P[^\.]+)$~'); + /** @var array<\SplFileInfo> $finder */ + $finder = Finder::find('*.' . $k1) + ->from($this->config->dirs); + + foreach ($finder as $fileInfo) { + $match = Strings::match($fileInfo->getFilename(), '~^(?P.*?)\.(?P[^\.]+)\.(?P[^\.]+)$~'); if ($match === null) { continue; @@ -260,19 +264,19 @@ public function beforeCompile(): void if ($whitelistRegexp !== null && Strings::match($match['locale'], $whitelistRegexp) === null) { if (isset($tracyPanel)) { - $tracyPanel->addSetup('addIgnoredResource', [$v2->getPathname(), $match['locale'], $match['domain']]); + $tracyPanel->addSetup('addIgnoredResource', [$fileInfo->getPathname(), $match['locale'], $match['domain']]); } continue; } - $translator->addSetup('addResource', [$match['format'], $v2->getPathname(), $match['locale'], $match['domain']]); + $translator->addSetup('addResource', [$match['format'], $fileInfo->getPathname(), $match['locale'], $match['domain']]); if (!isset($tracyPanel)) { continue; } - $tracyPanel->addSetup('addResource', [$v2->getPathname(), $match['locale'], $match['domain']]); + $tracyPanel->addSetup('addResource', [$fileInfo->getPathname(), $match['locale'], $match['domain']]); } } }