Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65077 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61465 invoked from network); 22 Jan 2013 11:57:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2013 11:57:04 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.174 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.210.174 mail-ia0-f174.google.com Received: from [209.85.210.174] ([209.85.210.174:61425] helo=mail-ia0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/C4-28294-F8E7EF05 for ; Tue, 22 Jan 2013 06:57:03 -0500 Received: by mail-ia0-f174.google.com with SMTP id o25so3217984iad.33 for ; Tue, 22 Jan 2013 03:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:reply-to:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=DK5zVi+PilWX2hBCnDjWpc7AYVR7OvT2G7X2ahf2EPU=; b=NOii724ZR+QoBOU5Wy+09kS5Z2u7OVZJCnDHfdctCqD230dwclHFU8N/rRucpgFNfd gy6BeffqNTODOv338wkwyEqT2rFaOUnDXoO3MScs+l9AdvZJxDEYSg1dQ1VsFIwgcynh 5/tol5eSgbfxkJygwUY1Gw0IcCmfVgIhAhqT+iZiBPUNvWuOGZS4QNi+XLLXQ6DX1cUY l9UwhXV7OrYXJSg/KThqDQQmbMMFDQBXgKkJ0J0pEeHk6qOXCXOjQ91tdIaimpopBGZ2 2kGI+lFcCwa+cmgTC/IaD7d3+PYi6jaCRQXIk/v+APNjcOFPUa9SqFgU62+cgjUrTwdZ Eg4g== X-Received: by 10.42.93.147 with SMTP id x19mr14215460icm.42.1358855821308; Tue, 22 Jan 2013 03:57:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.159.7 with HTTP; Tue, 22 Jan 2013 03:56:41 -0800 (PST) Reply-To: RQuadling@GMail.com In-Reply-To: <50FE4A9C.5080901@toolpark.com> References: <50FE4A9C.5080901@toolpark.com> Date: Tue, 22 Jan 2013 11:56:41 +0000 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [VOTE] Alternative typehinting syntax for accessors From: rquadling@gmail.com (Richard Quadling) On 22 January 2013 08:15, Lars Schultz wrote: > Am 22.01.2013 09:07, schrieb Nikita Popov: > >> It's not just about the lines of code. It's about having a more readable >> and more intuitive syntax. Am I the only one who thinks that "public $date >> { get; set(DateTime $date); }" looks pretty ugly/unclear compared to >> "public DateTime $date;"? > > > FWIW: I agree;) If accessors get through, I'd rather have this alternate > syntax. The other looks like a typo. I don't get to vote though... I'm not an expert, so I may be getting the wrong end of the stick. If you type hint the property, you cannot supply anything but that type when you set it? Where as, if you type hint the set parameter, you can supply that type, and have the set method extract/perform whatever is required and assign that result to the local property, which may be of a different type. I would assume that the property has it's own docblock to reflect the stored type. Of course, I certainly see a bad case of confusion being presented here if the stored type and the set type are different. And it would seem that type hinting the property would solve this, but you know developers will always want to get around blocks, is there any sensible use case for having type hinted set() parameter as well as type hinted property? Richard. -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY