Skip to content

[ObjectMapper] skip reading uninitialized values #61233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2025

Conversation

soyuka
Copy link
Contributor

@soyuka soyuka commented Jul 24, 2025

Q A
Branch? 7.3
Bug fix? yes
Issues Fix #60786
License MIT

The mapper would read uninitialized properties, for example this would throw trying to read name:

#[Map(target: FinalInput::class)]
class PartialInput
{
    public string $uuid;
    public string $name;
    public ?string $email;
    public ?string $website;
}

$p = new PartialInput;
$p->uuid = '6a9eb6dd-c4dc-4746-bb99-f6bad716acb2';
$p->website = 'https://updated.website.com';

$mapper = new ObjectMapper();
$mapper->map($p);

@carsonbot

This comment was marked as resolved.

@mttsch
Copy link
Contributor

mttsch commented Jul 25, 2025

@soyuka As the description will be part of the commit message, there is a small typo:

$mapper->map($);

->

$mapper->map($p);

@soyuka soyuka changed the base branch from 7.4 to 7.3 July 25, 2025 06:20
@alexandre-daubois alexandre-daubois modified the milestones: 7.4, 7.3 Jul 25, 2025
Copy link
Contributor

@rvanlaak rvanlaak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm this implementation resolves our problems. Thanks for addressing our issue @soyuka 🙌

@fabpot
Copy link
Member

fabpot commented Jul 26, 2025

Thank you @soyuka.

@fabpot fabpot merged commit 51ee4ed into symfony:7.3 Jul 26, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ObjectMapper] Allow to skip mapping non-initialized source values
6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy