Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5b2634f

Browse filesBrowse files
maciekpaprockinicolas-grekas
authored andcommitted
added earlier skip to allow if=false when using source mapping
1 parent 9ec163b commit 5b2634f
Copy full SHA for 5b2634f

File tree

Expand file treeCollapse file tree

2 files changed

+7
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-5
lines changed

‎src/Symfony/Component/ObjectMapper/ObjectMapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ObjectMapper/ObjectMapper.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ public function map(object $source, object|string|null $target = null): object
122122
$sourcePropertyName = $mapping->source;
123123
}
124124

125-
$value = $this->getRawValue($source, $sourcePropertyName);
126-
if (($if = $mapping->if) && ($fn = $this->getCallable($if, $this->conditionCallableLocator)) && !$this->call($fn, $value, $source, $mappedTarget)) {
125+
if (false === $if = $mapping->if) {
127126
continue;
128127
}
129128

130-
if (false === $if) {
129+
$value = $this->getRawValue($source, $sourcePropertyName);
130+
if ($if && ($fn = $this->getCallable($if, $this->conditionCallableLocator)) && !$this->call($fn, $value, $source, $mappedTarget)) {
131131
continue;
132132
}
133133

‎src/Symfony/Component/ObjectMapper/Tests/Fixtures/HydrateObject/SourceOnly.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ObjectMapper/Tests/Fixtures/HydrateObject/SourceOnly.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
class SourceOnly
1717
{
18-
public function __construct(#[Map(source: 'name')] public string $mappedName)
19-
{
18+
public function __construct(
19+
#[Map(source: 'name')] public string $mappedName,
20+
#[Map(if: false)] public ?string $mappedDescription = null
21+
) {
2022
}
2123
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.