Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114622 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8022 invoked from network); 26 May 2021 17:44:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 May 2021 17:44:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9420E1804D8 for ; Wed, 26 May 2021 10:56:01 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 26 May 2021 10:56:01 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id q5so2044824wrs.4 for ; Wed, 26 May 2021 10:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=Ea8dR9lSr0cgZNv8Ob2nBtIO4EW/hKnCkhaMycM054Q=; b=NPTtS23EfPoUbBFVayz6xapUU6T8e/oDwIw6zMICBeStxkrCGvzdI85HC5Al51Ut9K 55zXNGPT0B24PIUUsO1Js9F3BI1vluWoJJJJZR469QgqVRNDPbgeQyuERm3QTggsURUj JH9KMb22xQx8d8xc5/o/2FBFKMxazNU8czumMlEuYJOD8Tyz5gYkNA9gF+hpbjUOL6S8 tUxAG5gc36dt3LKQUX7P5ARPvhsWjMLFI9EtjRmiE1HjJXuPr3FWNZ3C2YH4CeoX9nAg c1oqcDSmXUg5Cv1kXpMczkIgvCMZLjeMJcVWEM5Ngcs3Tpk/xg6v+qcmbfkEGarycU4J 7q5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Ea8dR9lSr0cgZNv8Ob2nBtIO4EW/hKnCkhaMycM054Q=; b=nnPANrN9B9wmJutfksZNcHAoh6aWzvlL5rexFQFig6aFUVg/OrXYxuxiVHOtclHYd/ lKdlXCQeGN0ZPOf3ArEFz9NpfO0EjCCmfovDoxTFBlhvmyD5/7Fgpnltf+5j2A64rTKi HWZAFEBBBA5nSQgIQX5oeaTvYaOBainGI1mBehdG356uOMshOdDAGXKofUzazXgsfJLw ST0D5brIlFhpy/quSBFnB1PJ01ABXueTt7GpvWYXFR/SwBHI7vvi6a6CfFEKqPwWbAGE he74gh+eFcNajtVvzS4tWMbEqMM20kuuD3w58oKxIfpNGryiuJ++972UgiEs3rXkX+Yp mvlQ== X-Gm-Message-State: AOAM5334PRmrwBYeyoN5OJlySagIYCaz1++U2utn4efnQEt393uw3mHu faf32e6Njyq7ohG+qhqBcHcKn3ciY+I= X-Google-Smtp-Source: ABdhPJyA4RG8zDQn9nLbEYiBh+9RtkLO3xaXVSroAW9VTqjJitz+zT7WgbXuf6bwYTvwxYfWkmtN8w== X-Received: by 2002:adf:a2d1:: with SMTP id t17mr18144798wra.367.1622051760040; Wed, 26 May 2021 10:56:00 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id s7sm7201140wmh.35.2021.05.26.10.55.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 May 2021 10:55:59 -0700 (PDT) To: internals@lists.php.net References: <80fb5a8e-d770-49fd-45d5-ea6f4b004513@gmail.com> <2874cf7c-e55d-4100-bb01-af11a5ab6e87@www.fastmail.com> Message-ID: <66bfcb0f-a911-07eb-54ea-dc21f2d19da1@gmail.com> Date: Wed, 26 May 2021 18:55:59 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] Consensus Gathering: is_initialized From: rowan.collins@gmail.com (Rowan Tommins) On 26/05/2021 17:20, Guilliam Xavier wrote: > I think you said the word: serialization. And especially*deserialization*, > e.g. from a JSON payload into a typed DTO*without* calling the constructor > (then the DTO is passed through validation, which must handle uninitialized > typed properties "gracefully"). Would is_initialized() actually be all that useful there though? - If you're iterating the properties dynamically, you'll probably be using the reflection API already - If you're listing them manually, you can validate the input rather than the output, which you'd have to do if there's any mapping of names or types anyway It's also worth noting that If the property is not nullable, you can use isset() to tell if it's been initialised; and if it is nullable, you probably want it to default to null anyway. A separate function is only needed if you've decided to use the uninitialised state as an extra "value", distinct from null. Regards, -- Rowan Tommins [IMSoP]