Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104257 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45867 invoked from network); 6 Feb 2019 20:56:47 -0000 Received: from unknown (HELO mail-it1-f179.google.com) (209.85.166.179) by pb1.pair.com with SMTP; 6 Feb 2019 20:56:47 -0000 Received: by mail-it1-f179.google.com with SMTP id g85so8047335ita.3 for ; Wed, 06 Feb 2019 09:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hR5z/fsDzmQE+dRpNFLeLd7xa2t7gv7SA+wVLoBfXDI=; b=puDwW1o2C5LuU8tMYarXkEvgn+ZV2wlHcj89L6TMzPRz+qG1avCMzOT6Y6V/UqYrjv oyflSWWm0a/TpXCckiO8fMdMs9zUsN065CXCJpSuaqUdYi0tjAeTPFE9jr30OEs+dYlG M66ZkWb0c97jBdvfBKBICvm3ZP3LUPOTpshL7BV7Ot0M/X+1LdGoiCPN/MkqWp56tYoy K6QwS8UrnMON94KEJ9uLnFNtuG5qrfp8kMQqaEHJrLpgMjEQlPBvKkNX+UNj50KBdZkn JOOyZ8IF0ftUQtsIEDyuqsXAtPzrGmqEdKIHP5Nuxc3DUrSoLz4CIBBif3zcMY3Qis0T Np9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hR5z/fsDzmQE+dRpNFLeLd7xa2t7gv7SA+wVLoBfXDI=; b=plnJntKh3on6Pxi227rAXmX8IQ2aBJmNa2g5ATy4JjqM8QQnGXw6QwvrnbUf+ZcJ70 Py9XAdNcsq/IE2ULIVnkjtJdHGBwferI2T1x1n97iQu3aGuyI78OgaSvksi2hvtoy0FC z6LLlVHeVapx/5BmHfXdqZ2LIjV1su3nyo1nffvH6320IgzoKnlItAdSLylqIC2+XDqu TgS4X3TinLMUsZMNyfBCwA9v41+SB/45ScBR8qFrQfnkwJ+FGuT2zL1KCNH82GX+/e0C nsZapFCqMWOtVCOtYKsawmq6sZMlKx/gZIpu4Q51d7hakkU4eVaZgi/8HnQSjwBQg07s 2YsA== X-Gm-Message-State: AHQUAuZSct/Bc3MJIVWNTBNLXlmu5Qzi1Z6GfhN5DY8RaizkKMVU9YXs 6rTTM5s7u+h3VBH1D1sEic4xZwDRZ+Om5Kxi4P0= X-Google-Smtp-Source: AHgI3IaEgNQZTHWTQ6qCn8IhTMHraHE9yIn290JwRUiTFSQJe8FL1apUxmsXwkJPEoJSYn0fV+ryGsYQP/uAeZJK89w= X-Received: by 2002:a5d:8ac6:: with SMTP id e6mr5544370iot.235.1549474693456; Wed, 06 Feb 2019 09:38:13 -0800 (PST) MIME-Version: 1.0 References: <595b374c-bc4f-9b8a-0013-6485abbfb477@php.net> <41D0A782-E4E2-4B98-9C5D-174143DE9A76@gmail.com> In-Reply-To: Date: Wed, 6 Feb 2019 17:38:01 +0000 Message-ID: To: Benjamin Morel Cc: Marco Pivetta , Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="000000000000b1262505813d308b" Subject: Re: [PHP-DEV] Re: [RFC] [VOTE] Typed properties v2 From: rowan.collins@gmail.com (Rowan Collins) --000000000000b1262505813d308b Content-Type: text/plain; charset="UTF-8" On Wed, 6 Feb 2019 at 15:21, Benjamin Morel wrote: > You're right, in most of the cases properties SHOULD be set by the > constructor. I do find the current behaviour interesting, however, from a > data mapper point of view: you might want to retrieve a partial object from > the database, and get an Error if you accidentally access an uninitialized > property, as opposed to the pre-typed properties era, where you would get > null and the "error" would be silenced. > The problem with that is, the code doing the partial loading might be thousands of lines from the code "accidentally" accessing the property. If, for example, a User class supported partial loading of this sort, any function that takes a User would have to handle the possibility that what was actually passed was a partial User. If an error was raised, it would require tracing back through the code to work out where the conversion from partial to full object should have happened. A cleaner implementation would have PartialUser as a different type, which could not be passed to a function expecting a User; it would then be clear that a specific code needed to perform a conversion to fetch the rest of the data, e.g. function getUserFromPartial(PartialUser $partial): User In other words, if the definition of User includes a non-nullable property $name, then any object that doesn't have a value for $name is not actually a User object. Regards, -- Rowan Collins [IMSoP] --000000000000b1262505813d308b--