-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: constructor with default parameter array does not work with cont…
…ext (#185) After this PR #177 behavior was fixed when not using constructor arguments context, but with context it's still uses `??`. Before: ```PHP if (\AutoMapper\MapperContext::hasConstructorArgument($context, 'ConstructorWithDefaultValues', 'someOtters')) { $values = []; foreach ($value['someOtters'] ?? [] as $key => $value) { $values[$key] = $value; } $constructarg = $values ?? \AutoMapper\MapperContext::getConstructorArgument($context, 'ConstructorWithDefaultValues', 'someOtters'); } else { $values = []; foreach ($value['someOtters'] ?? [] as $key => $value) { $values[$key] = $value; } $constructarg = count($values) > 0 ? $values : array(); } ``` After: ```PHP if (\AutoMapper\MapperContext::hasConstructorArgument($context, 'ConstructorWithDefaultValues', 'someOtters')) { $values = []; foreach ($value['someOtters'] ?? [] as $key => $value) { $values[$key] = $value; } $constructarg = count($values) > 0 ? $values : \AutoMapper\MapperContext::getConstructorArgument($context, 'ConstructorWithDefaultValues', 'someOtters'); } else { $values = []; foreach ($value['someOtters'] ?? [] as $key => $value) { $values[$key] = $value; } $constructarg = count($values) > 0 ? $values : array(); } ```
- Loading branch information
Showing
3 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters