Skip to content

[Maker] Running make:command throw TypeError with FileLinkFormatter  #1382

@TheoD02

Description

@TheoD02

Symfony version(s) affected

7.0

Description

When i want to create command with Maker, make:command throw a TypeError

How to reproduce

  • Install project with Symfony 7.0 BETA-1 (--webapp)
  • run php bin/console make:command

Possible Solution

Change import of FileLinkFormatter in Symfony\Bundle\MakerBundle\Util\MakerFileLinkFormatter
from: Symfony\Component\HttpKernel\Debug\FileLinkFormatter
to: Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter

<?php

/*
 * This file is part of the Symfony MakerBundle package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\MakerBundle\Util;

use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;

/**
 * @internal
 */
final class MakerFileLinkFormatter
{
    public function __construct(
        private ?FileLinkFormatter $fileLinkFormatter = null,
    ) {
    }
    
    // ... rest of code
}

Additional Context

Error :

TypeError {#205
  #message: "Symfony\Bundle\MakerBundle\Util\MakerFileLinkFormatter::__construct(): Argument symfony/symfony#1 ($fileLinkFormatter) must be of type ?Symfony\Component\HttpKernel\Debug\FileLinkFormatter, Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter given, called in /shared/httpd/sf/var/cache/dev/ContainerV0krxqw/getMaker_FileLinkFormatterService.php on line 22"
  #code: 0
  #file: "./vendor/symfony/maker-bundle/src/Util/MakerFileLinkFormatter.php"
  #line: 22
  trace: {
    ./vendor/symfony/maker-bundle/src/Util/MakerFileLinkFormatter.php:22 { …}
    ./var/cache/dev/ContainerV0krxqw/getMaker_FileLinkFormatterService.php:22 {
      ContainerV0krxqw\getMaker_FileLinkFormatterService::do($container, $lazyLoad = true)^
      › 
      ›     return $container->privates['maker.file_link_formatter'] = new \Symfony\Bundle\MakerBundle\Util\MakerFileLinkFormatter(($container->privates['debug.file_link_formatter'] ?? self::getDebug_FileLinkFormatterService($container)));
      › }
      arguments: {
        $fileLinkFormatter: Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter {#201 …}
      }
    }
    ./var/cache/dev/ContainerV0krxqw/App_KernelDevDebugContainer.php:477 { …}
    ./var/cache/dev/ContainerV0krxqw/getMaker_FileManagerService.php:25 { …}
    ./var/cache/dev/ContainerV0krxqw/App_KernelDevDebugContainer.php:477 { …}
    ./var/cache/dev/ContainerV0krxqw/getMaker_PhpCompatUtilService.php:22 { …}
    ./var/cache/dev/ContainerV0krxqw/App_KernelDevDebugContainer.php:477 { …}
    ./var/cache/dev/ContainerV0krxqw/getMaker_AutoCommand_MakeCommandService.php:27 { …}
    ./var/cache/dev/ContainerV0krxqw/App_KernelDevDebugContainer.php:477 { …}
    ./var/cache/dev/ContainerV0krxqw/get_Maker_AutoCommand_MakeCommand_LazyService.php:23 { …}
    ./vendor/symfony/console/Command/LazyCommand.php:185 { …}
    ./vendor/symfony/console/Application.php:314 { …}
    ./vendor/symfony/framework-bundle/Console/Application.php:79 { …}
    ./vendor/symfony/console/Application.php:169 { …}
    ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49 { …}
    ./vendor/autoload_runtime.php:29 { …}
    ./bin/console:11 { …}
  }
}

Seem impact all make:* commands

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions