Skip to content

Commit 4e3fe89

Browse files
committed
Fix usage with inherited constructor from abstract class
1 parent 69f7789 commit 4e3fe89

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/Metadata/GeneratorMetadata.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ public function hasConstructor(): bool
8989
return false;
9090
}
9191

92-
if ($constructor->getDeclaringClass()->isInterface() || $constructor->getDeclaringClass()->isAbstract()) {
93-
return false;
94-
}
95-
9692
$parameters = $constructor->getParameters();
9793
$mandatoryParameters = [];
9894

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AutoMapper\Tests\AutoMapperTest\Issue284\Banana {
2+
+weight: 1
3+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AutoMapper\Tests\AutoMapperTest\Issue284;
6+
7+
use AutoMapper\Tests\AutoMapperBuilder;
8+
9+
abstract readonly class Fruit
10+
{
11+
public function __construct(
12+
public int $weight
13+
) {
14+
}
15+
}
16+
17+
final readonly class Banana extends Fruit
18+
{
19+
}
20+
21+
return AutoMapperBuilder::buildAutoMapper()->map(['weight' => 1], Banana::class);

0 commit comments

Comments
 (0)