diff --git a/CHANGELOG.md b/CHANGELOG.md index 1655c5e0..40c29579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [9.4.2] - 2025-07-17 +### Changed +- [GH#286](https://github.com/jolicode/automapper/pull/286) Optimize condition order to avoid unnecessary method calls by prioritizing custom conditions + ## [Unreleased] ### Fixed - [GH#272](https://github.com/jolicode/automapper/pull/272) Fixed circular references with promoted properties diff --git a/src/Generator/PropertyConditionsGenerator.php b/src/Generator/PropertyConditionsGenerator.php index db98c09e..529c7ce2 100644 --- a/src/Generator/PropertyConditionsGenerator.php +++ b/src/Generator/PropertyConditionsGenerator.php @@ -40,6 +40,7 @@ public function generate(GeneratorMetadata $metadata, PropertyMetadata $property { $conditions = []; + $conditions[] = $this->customCondition($metadata, $propertyMetadata); $conditions[] = $this->propertyExistsForStdClass($metadata, $propertyMetadata); $conditions[] = $this->propertyExistsForArray($metadata, $propertyMetadata); @@ -60,8 +61,6 @@ public function generate(GeneratorMetadata $metadata, PropertyMetadata $property $conditions[] = $this->maxDepthCheck($metadata, $propertyMetadata); } - $conditions[] = $this->customCondition($metadata, $propertyMetadata); - $conditions = array_values(array_filter($conditions)); if (!$conditions) {