File tree Expand file tree Collapse file tree 4 files changed +53
-0
lines changed
Expand file tree Collapse file tree 4 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,10 @@ private function getPropertyMetadataList(ReflectionClass $reflectionClass): arra
138138 continue ;
139139 }
140140
141+ if ($ reflectionProperty ->getDeclaringClass ()->getName () !== $ reflectionClass ->getName ()) {
142+ continue ;
143+ }
144+
141145 $ fieldName = $ this ->getFieldName ($ reflectionProperty );
142146
143147 if (array_key_exists ($ fieldName , $ properties )) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Patchlevel \Hydrator \Tests \Unit \Fixture ;
6+
7+ use DateTimeImmutable ;
8+
9+ final class DistributionCreated extends DomainEvent
10+ {
11+ public function __construct (
12+ DateTimeImmutable $ distributionDate ,
13+ ) {
14+ parent ::__construct ($ distributionDate );
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Patchlevel \Hydrator \Tests \Unit \Fixture ;
6+
7+ use DateTimeImmutable ;
8+
9+ abstract class DomainEvent
10+ {
11+ public function __construct (
12+ protected readonly DateTimeImmutable $ recordedDate ,
13+ ) {
14+ }
15+
16+ public function occurredOn (): DateTimeImmutable
17+ {
18+ return $ this ->recordedDate ;
19+ }
20+ }
Original file line number Diff line number Diff line change 1818use Patchlevel \Hydrator \Metadata \SubjectIdAndPersonalDataConflict ;
1919use Patchlevel \Hydrator \Normalizer \EnumNormalizer ;
2020use Patchlevel \Hydrator \Tests \Unit \Fixture \BrokenParentDto ;
21+ use Patchlevel \Hydrator \Tests \Unit \Fixture \DistributionCreated ;
2122use Patchlevel \Hydrator \Tests \Unit \Fixture \DuplicateFieldNameDto ;
2223use Patchlevel \Hydrator \Tests \Unit \Fixture \Email ;
2324use Patchlevel \Hydrator \Tests \Unit \Fixture \EmailNormalizer ;
@@ -249,6 +250,18 @@ public function testExtendsDuplicatedFieldName(): void
249250 $ metadataFactory ->metadata (BrokenParentDto::class);
250251 }
251252
253+ public function testBug70 (): void
254+ {
255+ $ metadataFactory = new AttributeMetadataFactory ();
256+ $ metadata = $ metadataFactory ->metadata (DistributionCreated::class);
257+
258+ self ::assertCount (1 , $ metadata ->properties ());
259+
260+ $ property = $ metadata ->propertyForField ('recordedDate ' );
261+
262+ self ::assertSame ('recordedDate ' , $ property ->propertyName ());
263+ }
264+
252265 public function testSameClassDuplicatedFieldName (): void
253266 {
254267 $ this ->expectException (DuplicatedFieldNameInMetadata::class);
You can’t perform that action at this time.
0 commit comments