Skip to content

Symfony 7/8 Fixes & Compatibility#505

Closed
dsoriano wants to merge 9 commits into
lexik:masterfrom
dsoriano:sf8-compatibility
Closed

Symfony 7/8 Fixes & Compatibility#505
dsoriano wants to merge 9 commits into
lexik:masterfrom
dsoriano:sf8-compatibility

Conversation

@dsoriano

@dsoriano dsoriano commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

This pull request aim to improve the whole bundle compatibility with Symfony 7 / 8

  • Move the LexikTranslator to a Symfony Translator decorator
  • As a decorator, the bundle now use most of the Symfony Translator configuration (but no BC Break with olds configs)
  • Fix all level 5 PHPStan errors (~80)
  • Remove or upgrade deprecated code
  • Fix tests
  • Clean Code with CS Fixer
  • Update configuration doc
  • Fix Docker
  • Fix a lot of PHPStorm / PHP Inspections Code analysis reports (but not all at the moment 🥵)

✅ Unit tests OK
✅ Tested on a real project

There is still a lot of work to do but this PR is a good start !

Fix #500 and #490

@dsoriano
dsoriano marked this pull request as ready for review March 15, 2026 21:37
@dsoriano

Copy link
Copy Markdown
Contributor Author

@bartmcleod hi !
After a long and hard work, the PR is finally ready and is fully compatible with Symfony 7 and Symfony 8 👍!

@bartmcleod bartmcleod left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time I try to review this I get stuck on the sheer amount of changes.

I have added one comment so far, more of a question, that applies to more than one location.

Also, when I load this PR in my Symfony 8 project, I get an error "TypeError
HTTP 500 Internal Server Error
Lexik\Bundle\TranslationBundle\Translation\Translator::__construct(): Argument #2 ($container) must be of type Psr\Container\ContainerInterface, Symfony\Component\Translation\Formatter\MessageFormatter given, called in /app/var/cache/dev/ContainerEprdT7G/getLexikTranslation_TranslatorService.php on line 26"

Maybe I need to clear the cache [Edit] yes, that works

}

if ($this->input->getOption('cache-clear')) {
if ($this->input->getOption('cache-clear') && method_exists($this->translator, 'removeLocalesCacheFiles')) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsoriano Why do you need to call method_exists? Is there no interface defined for a translator that covers this?

@bartmcleod

Copy link
Copy Markdown
Collaborator

@dsoriano When I try to eport translations it goes to Resources/translations, the directory Resources does not exist, hence the following error. Is this by design? My Symfony 8 default project just has translations, not Resources/translations.

root@618695ffc32c:/app# bin/console lexik:t:e
# Exporting "vendor/l`exik/translation-bundle/Resources/translations/LexikTranslationBundle.en.yml":
# OutputPath "/app/Resources/translations":
# OutputFile "/app/Resources/translations/LexikTranslationBundle.en.yml":
Output file: /app/Resources/translations/LexikTranslationBundle.en.yml
1 translations to export: "Warning: file_put_contents(/app/Resources/translations/LexikTranslationBundle.en.yml): Failed to open stream: No such file or directory"

@bartmcleod

bartmcleod commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

@dsoriano When I save and add a new translation, I get the error

Typed property Lexik\Bundle\TranslationBundle\Entity\Translation::$file must not be accessed before initialization
image

@bartmcleod bartmcleod self-assigned this Jun 29, 2026
@bartmcleod bartmcleod added this to the Symfony 8 milestone Jun 29, 2026
@bartmcleod
bartmcleod marked this pull request as draft July 2, 2026 20:49
@bartmcleod

Copy link
Copy Markdown
Collaborator

@dsoriano I noticed that a new translation is also broken in current master, so it need not block this PR. Can you rebase please and resolve any conflicts?

@bartmcleod

Copy link
Copy Markdown
Collaborator

@dsoriano I'm also trying to fix this, as currently master is broken

@bartmcleod bartmcleod mentioned this pull request Jul 7, 2026
@bartmcleod

Copy link
Copy Markdown
Collaborator

@dsoriano Thank you for all your hard work! I made only a few minor fixes that complete this work in PR #514

@bartmcleod bartmcleod closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot extend final class Translator

2 participants