Skip to content

Commit cd11637

Browse files
committed
Reordered custom condition logic in PropertyConditionsGenerator
Update changelog
1 parent 9acfbea commit cd11637

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [9.4.2] - 2025-07-17
9+
### Changed
10+
- [GH#286](https://github.com/jolicode/automapper/pull/286) Optimize condition order to avoid unnecessary method calls by prioritizing custom conditions
11+
812
## [Unreleased]
913
### Fixed
1014
- [GH#272](https://github.com/jolicode/automapper/pull/272) Fixed circular references with promoted properties

src/Generator/PropertyConditionsGenerator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function generate(GeneratorMetadata $metadata, PropertyMetadata $property
4040
{
4141
$conditions = [];
4242

43+
$conditions[] = $this->customCondition($metadata, $propertyMetadata);
4344
$conditions[] = $this->propertyExistsForStdClass($metadata, $propertyMetadata);
4445
$conditions[] = $this->propertyExistsForArray($metadata, $propertyMetadata);
4546

@@ -60,8 +61,6 @@ public function generate(GeneratorMetadata $metadata, PropertyMetadata $property
6061
$conditions[] = $this->maxDepthCheck($metadata, $propertyMetadata);
6162
}
6263

63-
$conditions[] = $this->customCondition($metadata, $propertyMetadata);
64-
6564
$conditions = array_values(array_filter($conditions));
6665

6766
if (!$conditions) {

0 commit comments

Comments
 (0)