Skip to content

Commit bc217c0

Browse files
authored
Merge pull request #12486 from greg0ire/3.6.x
Merge 2.20.x up into 3.6.x
2 parents 471b129 + e75a435 commit bc217c0

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,12 +2856,6 @@ parameters:
28562856
count: 1
28572857
path: src/Tools/Console/Command/MappingDescribeCommand.php
28582858

2859-
-
2860-
message: '#^Parameter \#1 \$entityListeners of method Doctrine\\ORM\\Tools\\Console\\Command\\MappingDescribeCommand\:\:formatEntityListeners\(\) expects list\<object\>, array\<string, list\<array\{class\: class\-string, method\: string\}\>\> given\.$#'
2861-
identifier: argument.type
2862-
count: 1
2863-
path: src/Tools/Console/Command/MappingDescribeCommand.php
2864-
28652859
-
28662860
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(class\-string\)\: bool\)\|null, Closure\(mixed\)\: \(0\|1\|false\) given\.$#'
28672861
identifier: argument.type

src/Tools/Console/Command/MappingDescribeCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,21 @@ private function formatMappingsAsJson(array $propertyMappings): array
376376
/**
377377
* Format the entity listeners
378378
*
379-
* @phpstan-param list<object> $entityListeners
379+
* @phpstan-param array<string, list<array{class: class-string, method: string}>> $entityListeners
380380
*
381381
* @return string[]
382382
* @phpstan-return array{0: string, 1: string}
383383
*/
384384
private function formatEntityListeners(array $entityListeners): array
385385
{
386-
return $this->formatField('Entity listeners', array_map('get_class', $entityListeners));
386+
$listeners = [];
387+
388+
foreach ($entityListeners as $eventName => $eventListeners) {
389+
foreach ($eventListeners as $listener) {
390+
$listeners[] = sprintf('%s: %s::%s', $eventName, $listener['class'], $listener['method']);
391+
}
392+
}
393+
394+
return $this->formatField('Entity listeners', $listeners);
387395
}
388396
}

tests/Tests/ORM/Tools/Console/Command/MappingDescribeCommandTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Doctrine\ORM\Tools\Console\Command\MappingDescribeCommand;
99
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
1010
use Doctrine\Tests\Models\Cache\AttractionInfo;
11+
use Doctrine\Tests\Models\CMS\CmsAddress;
1112
use Doctrine\Tests\OrmFunctionalTestCase;
1213
use InvalidArgumentException;
1314
use PHPUnit\Framework\Attributes\CoversClass;
@@ -138,4 +139,22 @@ public static function provideCompletionSuggestions(): iterable
138139
['text', 'json'],
139140
];
140141
}
142+
143+
public function testShowEntityWithEntityListeners(): void
144+
{
145+
$this->tester->execute(
146+
[
147+
'command' => $this->command->getName(),
148+
'entityName' => CmsAddress::class,
149+
],
150+
);
151+
152+
$display = $this->tester->getDisplay();
153+
154+
self::assertStringContainsString(CmsAddress::class, $display);
155+
self::assertStringContainsString('Entity listeners', $display);
156+
self::assertStringContainsString('CmsAddressListener', $display);
157+
self::assertStringContainsString('postPersist', $display);
158+
self::assertStringContainsString('prePersist', $display);
159+
}
141160
}

0 commit comments

Comments
 (0)