Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107047 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20209 invoked from network); 13 Sep 2019 09:59:15 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 13 Sep 2019 09:59:15 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 36A782D200C for ; Fri, 13 Sep 2019 00:35:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Fri, 13 Sep 2019 00:35:20 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id q21so17540676pfn.11 for ; Fri, 13 Sep 2019 00:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=gedN3XXvIbKN3TRu80Y35jV5xy20ldYmptYJQ9+2UKY=; b=EHf8bnT0dVsET/vtQAN2qTY/6cSBXuKPu9Y58VZQ+N/O4DL17XzPLSUxN21CPUWi2A vWAzW+IwJoh/rRIXPkDcY9Ew+0tiYAcRa2PAnw76jRlQpHA/raoamXDvHpAbuS8JOa3G USbsQnM/BYydsn+/Ad800gFugNGJC07TMrj/doZAs95Nl97rBNi2gV4AotHXhtsBlMmq cw3T9h0RoGjZFbjQ4TZ8BTN10VHE7+5Mzcok5qlClLBCI1CTL2URtXFEIk9Mt/kXJ5fc X87AW8ukF0+XVt8DLlSk0knrm62PVzoYUrjYyUMAnBi7ZUfZo9GCtQU0xebptXfB1N6y HVhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=gedN3XXvIbKN3TRu80Y35jV5xy20ldYmptYJQ9+2UKY=; b=lba/tM61bFScO++9CfbnJEY9x6VIGEE5qzVK+7Omv5Rs+tC2TOpOZkOk1e1NBdI7gy d91F5wZOOj5LHP1SaQ+56ukMHUsdV/oZH15o4MQsIKsQP16i5lr9fWDLn6s935rfAwNf Un4cwh84dM//BPj0vB4PpgMvgigHtujXoFXid68UCtp3BaD4drKTVqMAgY3Oh23YLRa5 cqVA7uawdhuQgAL69mCkO44lVjySj+P1Yfy9bqQtLXUXRc6KCDe41pHNvTHVqUPIxrgD KDsb22hBSiADZpvXBYHb00+MOA2P2XZfYGysJG0RIZQnVxShNfXXIePiqDY23C+p2OJ0 WKcQ== X-Gm-Message-State: APjAAAXH4e227GUoIF+aclQ2XXJ9ole3VXmuyu3sP/BPJgKIC8I9crsz ida0o4uT2ibdXfg1N5o9wtmIaA== X-Google-Smtp-Source: APXvYqyH7j+svwpkQ2arjGN9YnwpkfQ0BRl/9eKuzmJgkGWGnySnUwvw9ro93V3ia+Ltm5wfYuLclg== X-Received: by 2002:a62:8209:: with SMTP id w9mr17214387pfd.112.1568360119576; Fri, 13 Sep 2019 00:35:19 -0700 (PDT) Received: from [192.168.202.38] (50-252-183-45-static.hfc.comcastbusiness.net. [50.252.183.45]) by smtp.gmail.com with ESMTPSA id z23sm29322202pgi.78.2019.09.13.00.35.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 00:35:19 -0700 (PDT) Message-ID: <3CA484B0-BCA3-4A2B-B2A6-8B845F9C462B@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_2565456E-7977-4CAB-B62C-D49C647687C5" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Fri, 13 Sep 2019 00:35:17 -0700 In-Reply-To: <74C03BB1-28DF-4694-A91D-2516C545F8B2@gmail.com> Cc: =?utf-8?Q?Micha=C5=82_Brzuchalski?= , PHP Internals List To: Claude Pache References: <74C03BB1-28DF-4694-A91D-2516C545F8B2@gmail.com> X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Object Initializer From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_2565456E-7977-4CAB-B62C-D49C647687C5 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > That said, I generally use arrays rather than DTO objects I too have often used arrays. But then I have always been rigorous to = ensure that variables and array elements are initialized before use, and = fortunately I do not have a lot of typos in code I write. However I recently took on a large PHP app to refactor where the = previous developers had used arrays profusely with very little = pre-initialization. So I started to add in all initialization and = checking to be certain variables had been initialized and realized it = was an overwhelming task.=20 I changed course and am now replacing all all arrays that are emulating = a struct (vs a collection) to instances of declared classes and it has = made a major improvement in my ability to refactor without bloating the = code to 2-3x the original size. I has also allowed me to consolidate = lots of repeated code in one place in methods and constructors. Given that experience and knowing that using "args" for optional = parameters means my function signatures are much less likely to change, = it would be super helpful if I could do so with type-checked object = initializers instead of array literals. -Mike= --Apple-Mail=_2565456E-7977-4CAB-B62C-D49C647687C5--