Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68435 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99942 invoked from network); 8 Aug 2013 11:11:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2013 11:11:51 -0000 Authentication-Results: pb1.pair.com header.from=martin.keckeis1@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=martin.keckeis1@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.43 as permitted sender) X-PHP-List-Original-Sender: martin.keckeis1@gmail.com X-Host-Fingerprint: 209.85.219.43 mail-oa0-f43.google.com Received: from [209.85.219.43] ([209.85.219.43:45502] helo=mail-oa0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/C1-06453-7FC73025 for ; Thu, 08 Aug 2013 07:11:51 -0400 Received: by mail-oa0-f43.google.com with SMTP id i10so5038736oag.2 for ; Thu, 08 Aug 2013 04:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=XYgJRHKepdxL7EjjPVffwk0sNIiSNLUF3XEd5rrWlUc=; b=t+0B3UuBX5Nk0eCy70W8I8UHAEsgefQ5vu1viPHpSvXwcKr4r6cCz2ryWrRldJp5K+ BOn1p+6q3mSMv6ytqpCKHbnnZJ64QMTS+FWHvpOZDN/LAEtNEy5z5im3ixDTMC4L99sf 66cRFPG6VJgIRUInb+JqW9GgQthfHyQ8Fxz9qVZJvFn8CbeUz5TOI4iVuaT7pZUZnh9q s4WKO9PVqVF6k/NrAavjM7iGg+YgPJKv+gur6STzBLjjVkA4cuja7q2lQkSRhUGHkKjq wqs5uZStsoQn9qoCTk0G6XZJizBEuHoGYMkiyFuSJVJKs4P0v/gFl6qMzRogoHxjH+ee cMpw== MIME-Version: 1.0 X-Received: by 10.60.115.231 with SMTP id jr7mr3974490oeb.16.1375960308801; Thu, 08 Aug 2013 04:11:48 -0700 (PDT) Received: by 10.182.26.112 with HTTP; Thu, 8 Aug 2013 04:11:48 -0700 (PDT) Received: by 10.182.26.112 with HTTP; Thu, 8 Aug 2013 04:11:48 -0700 (PDT) In-Reply-To: <52037411.7070406@seld.be> References: <52037411.7070406@seld.be> Date: Thu, 8 Aug 2013 13:11:48 +0200 Message-ID: To: Jordi Boggiano Cc: PHP internals Content-Type: multipart/alternative; boundary=089e01161a906e694504e36db987 Subject: Re: [PHP-DEV] RFC: constructor argument promotion From: martin.keckeis1@gmail.com (Martin Keckeis) --089e01161a906e694504e36db987 Content-Type: text/plain; charset=UTF-8 Am 08.08.2013 12:34 schrieb "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. The syntax itself i feel is self explaining. You read it and you know whats going on. But somehow i feel this is "wrong". Declaring visibility directly in the arguments? This looks very scary to me. (Maybe only because i've never seen it before...) Other reasons against: Phpdoc generator break Code completion break If constructor is not at the beginning never see a var declaration Auto generation of set/get can be achieved with IDE..so its not much work --089e01161a906e694504e36db987--