Skip to content
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"php": "^8.0.2",
"latte/latte": "^2.6|^3.0.25",
"latte/latte": "^3.0.25",
"nette/di": "^3.0.6",
"nette/finder": "^2.5.2|^3.0.0",
"nette/http": "^3.0.7",
Expand Down
52 changes: 0 additions & 52 deletions phpstan.lowest.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,3 @@ parameters:
count: 2
message: '#^Variable property access on object\.$#'
path: 'src/Loaders/Doctrine.php'

# -------------------------------------------------------------------
# for back compatibility with old packages - will be remove in future
# -------------------------------------------------------------------

-
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: """
#^Parameter \\$translator of method Contributte\\\\Translation\\\\Latte\\\\TranslatorExtension\\:\\:__construct\\(\\) has typehint with deprecated interface Nette\\\\Localization\\\\ITranslator\\:
use Nette\\\\Localization\\\\Translator$#
"""
path: src/Latte/TranslatorExtension.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

-
message: """
#^Fetching class constant class of deprecated class Nette\\\\Bridges\\\\ApplicationLatte\\\\ILatteFactory\\:
use Nette\\\\Bridges\\\\ApplicationLatte\\\\LatteFactory$#
"""
count: 1
path: src/DI/TranslationExtension.php
74 changes: 0 additions & 74 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,3 @@ parameters:
count: 2
message: '#^Variable property access on object\.$#'
path: 'src/Loaders/Doctrine.php'

-
count: 2
message: '#^Comparison operation "\<" between \d+ and \d+ is always false\.$#'
path: 'src/Latte/Macros.php'

-
count: 1
message: '#^Comparison operation "\>=" between \d+ and \d+ is always true\.$#'
path: 'src/Latte/Macros.php'

-
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 interface Nette\\\\Bridges\\\\ApplicationLatte\\\\ILatteFactory\\:
use Nette\\\\Bridges\\\\ApplicationLatte\\\\LatteFactory$#
"""
count: 1
path: src/DI/TranslationExtension.php

-
message: """
#^Fetching class constant class of deprecated interface 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: """
#^Parameter \\$translator of method Contributte\\\\Translation\\\\Latte\\\\TranslatorExtension\\:\\:__construct\\(\\) has typehint with deprecated interface Nette\\\\Localization\\\\ITranslator\\:
use Nette\\\\Localization\\\\Translator$#
"""
path: src/Latte/TranslatorExtension.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

-
message: """
#^Instantiation of deprecated class Nette\\\\PhpGenerator\\\\PhpLiteral\\:
use Nette\\\\PhpGenerator\\\\Literal$#
"""
count: 1
path: src/DI/TranslationExtension.php
32 changes: 8 additions & 24 deletions src/DI/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Contributte\Translation\Exceptions\InvalidArgument;
use Contributte\Translation\FallbackResolver;
use Contributte\Translation\Helpers;
use Contributte\Translation\Latte\Filters;
use Contributte\Translation\Latte\Macros;
use Contributte\Translation\Latte\TranslatorExtension;
use Contributte\Translation\Loaders\Neon;
use Contributte\Translation\LocaleResolver;
Expand All @@ -18,12 +16,11 @@
use Contributte\Translation\LocalesResolvers\Session;
use Contributte\Translation\Tracy\Panel;
use Contributte\Translation\Translator;
use Nette\Bridges\ApplicationLatte\ILatteFactory;
use Nette\Bridges\ApplicationLatte\LatteFactory;
use Nette\DI\CompilerExtension;
use Nette\DI\MissingServiceException;
use Nette\Localization\ITranslator;
use Nette\Localization\Translator as NetteTranslator;
use Nette\PhpGenerator\ClassType;
use Nette\PhpGenerator\PhpLiteral;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use Nette\Utils\Finder;
Expand Down Expand Up @@ -82,7 +79,7 @@ public function getConfigSchema(): Schema
'translatorFactory' => Expect::string()->default(null),
'returnOriginalMessage' => Expect::bool()->default(true),
'autowired' => Expect::type('bool|array')->default(true),
'latteFactory' => Expect::string(ILatteFactory::class)->nullable(),
'latteFactory' => Expect::string(LatteFactory::class)->nullable(),
]);
}

Expand Down Expand Up @@ -144,7 +141,7 @@ public function loadConfiguration(): void

if ($this->config->autowired === true) {
$autowired = [
ITranslator::class,
NetteTranslator::class,
TranslatorInterface::class,
Translator::class,
];
Expand Down Expand Up @@ -233,26 +230,13 @@ public function beforeCompile(): void
$latteFactoryName = $this->config->latteFactory ? $builder->getByType($this->config->latteFactory) : null;

if ($latteFactoryName !== null) {
$iTranslator = $builder->getDefinitionByType(ITranslator::class);

$latteFilters = $builder->addDefinition($this->prefix('latte.filters'))
->setFactory(Filters::class);

/** @var \Nette\DI\Definitions\FactoryDefinition $latteFactory */
$latteFactory = $builder->getDefinition($latteFactoryName);

/** @phpstan-ignore-next-line */
if (version_compare(\Latte\Engine::VERSION, '3', '<')) {
$latteFactory->getResultDefinition()
->addSetup('?->onCompile[] = function (Latte\\Engine $engine): void { ?::install($engine->getCompiler()); }', ['@self', new PhpLiteral(Macros::class)])
->addSetup('addProvider', ['translator', $iTranslator])
->addSetup('addFilter', ['translate', [$latteFilters, 'translate']]);
} else {
$latteExtension = $builder->addDefinition($this->prefix('latte.extension'))
->setFactory(TranslatorExtension::class);
$latteFactory->getResultDefinition()
->addSetup('addExtension', [$latteExtension]);
}
$latteExtension = $builder->addDefinition($this->prefix('latte.extension'))
->setFactory(TranslatorExtension::class);
$latteFactory->getResultDefinition()
->addSetup('addExtension', [$latteExtension]);
}

/** @var \Contributte\Translation\DI\TranslationProviderInterface $v1 */
Expand Down
34 changes: 0 additions & 34 deletions src/Latte/Filters.php

This file was deleted.

136 changes: 0 additions & 136 deletions src/Latte/Macros.php

This file was deleted.

Loading