Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/Util/MakerFileLinkFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
namespace Symfony\Bundle\MakerBundle\Util;

use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter as LegacyFileLinkFormatter;

/**
* @internal
*/
final class MakerFileLinkFormatter
{
public function __construct(
private ?FileLinkFormatter $fileLinkFormatter = null,
private FileLinkFormatter|LegacyFileLinkFormatter|null $fileLinkFormatter = null,
Copy link
Member

Choose a reason for hiding this comment

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

Does this fail in Symfony 6.3 where FileLinkFormatter (the new one) does not exist? It seems to: https://github.com/symfony/maker-bundle/actions/runs/6610525836/job/17952630835?pr=1383#step:14:74

Do we need to remove the type until 6.3 support is dropped?

Copy link
Member Author

Choose a reason for hiding this comment

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

That shouldn't be the issue. I am gonna take a deeper look into the failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

tests fixed

) {
}

Expand Down
10 changes: 8 additions & 2 deletions tests/FileManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
use Symfony\Bundle\MakerBundle\Util\AutoloaderUtil;
use Symfony\Bundle\MakerBundle\Util\MakerFileLinkFormatter;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter as LegacyFileLinkFormatter;

class FileManagerTest extends TestCase
{
Expand Down Expand Up @@ -193,7 +194,12 @@ public function testWithMakerFileLinkFormatter(): void
$this->markTestSkipped();
}

$fileLinkFormatter = $this->createMock(FileLinkFormatter::class);
if (class_exists(FileLinkFormatter::class)) {
$fileLinkFormatter = $this->createMock(FileLinkFormatter::class);
} else {
$fileLinkFormatter = $this->createMock(LegacyFileLinkFormatter::class);
}

$fileLinkFormatter
->method('format')
->willReturnCallback(function ($path, $line) {
Expand Down
10 changes: 8 additions & 2 deletions tests/Util/MakerFileLinkFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\MakerBundle\Util\MakerFileLinkFormatter;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter as LegacyFileLinkFormatter;

final class MakerFileLinkFormatterTest extends TestCase
{
Expand All @@ -39,7 +40,12 @@ public function testMakeLinkedPath(bool $withFileLinkFormatter, bool $linkFormat

$fileLinkFormatter = null;
if ($withFileLinkFormatter) {
$fileLinkFormatter = $this->createMock(FileLinkFormatter::class);
if (class_exists(FileLinkFormatter::class)) {
$fileLinkFormatter = $this->createMock(FileLinkFormatter::class);
} else {
$fileLinkFormatter = $this->createMock(LegacyFileLinkFormatter::class);
}

$return = $linkFormatterReturnsLink ? $this->returnCallback(function ($path, $line) {
return sprintf('subl://open?url=file://%s&line=%d', $path, $line);
}) : $this->returnValue(false);
Expand Down