Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68432 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94307 invoked from network); 8 Aug 2013 10:34:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2013 10:34:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 74.125.83.45 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 74.125.83.45 mail-ee0-f45.google.com Received: from [74.125.83.45] ([74.125.83.45:39953] helo=mail-ee0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/90-06453-91473025 for ; Thu, 08 Aug 2013 06:34:04 -0400 Received: by mail-ee0-f45.google.com with SMTP id c50so1422492eek.32 for ; Thu, 08 Aug 2013 03:33:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=NsgndkbfQN9HTUy9VGC4WNoqmdITsqOVceoTNyWYY3M=; b=nk0NTsJCUeawvbwj4kf5kKJ7m+7zPfTPeYEayApem9MuRRAPbHktkACof4nw6yg3Ov 0ta096NJ328bZ4NfPqo6dbzl9hOUMp9f8WniSnExbKdZgfElJAnlEhN2un0RfuvVjnzX YxQTskjRBHVQzjhYZ0OQEfqTT3iNMyOYhTgTyYtbmPNVxBQOWwbBqZOBVshk/9EAxQ7+ /cf48cfJ7HHszK/pqOsMhMLddBK1JbGpd8iVlJQwwqyuloT+6OPZ437hdyZbz5UPn/as 62mzb9SYZd6043GMuGtm21eQLYCmveLE9C1EJVYN5/GlsfEBUFnzUWyELTGILBGnlNad Hb8w== X-Gm-Message-State: ALoCoQn0KVslbARqcB4lepaz7QBSW/Hwv5bGKQqEx3+EBgm1+tWDON31kPkv3yJ8mEnv94QY7w17 X-Received: by 10.14.211.134 with SMTP id w6mr7641352eeo.26.1375958038820; Thu, 08 Aug 2013 03:33:58 -0700 (PDT) Received: from [192.168.1.37] (77-56-98-127.dclient.hispeed.ch. [77.56.98.127]) by mx.google.com with ESMTPSA id bq1sm17986135eeb.9.2013.08.08.03.33.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 03:33:57 -0700 (PDT) Message-ID: <52037411.7070406@seld.be> Date: Thu, 08 Aug 2013 12:33:53 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: constructor argument promotion From: j.boggiano@seld.be (Jordi Boggiano) On 08.08.2013 10:34, Leigh wrote: > I'm not sure what problem this is really trying to solve, the boilerplate > code you mention is very explicit and it is very clear to the reader what > is being done. Each property documented with its type, purpose and > visibility in a common place for easy reference (at the top of the class). > Each property that takes a value from the constructor assigned in the > constructor. Very clear. I for one am pretty tired of writing this boilerplate in every second class I write. Using dependency injection you end up having to write a LOT of those usually, and constructors typically only contain assignments. Adding a property means: declaring the property, adding the ctor arg, adding the assignment in the ctor. You have to write the property name 4 times. With this RFC in it'd come down to writing it once, and would avoid having undeclared properties because someone forgot. I am very supportive the idea, although I see that it could be confusing to some. Maybe the syntax needs to change, but the overall change is much welcome. Cheers -- Jordi Boggiano @seldaek - http://nelm.io/jordi