Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65061 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96964 invoked from network); 21 Jan 2013 22:59:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2013 22:59:57 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:48924] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/01-20901-C68CDF05 for ; Mon, 21 Jan 2013 17:59:56 -0500 Received: by mail-la0-f42.google.com with SMTP id fe20so6809571lab.29 for ; Mon, 21 Jan 2013 14:59:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=Km5TJXiqeNuIma//VfXvvBK3st1YQseFrCPTQpwGsqo=; b=y1bHXJGdCDuKgAuX5EeQwC5YHl03zyCsnJMXUvvv9Dw449niTW2jVxAXwRMII8uTu0 uL9rBzJpQMXvMAsA64b8PP40iwW8Whv51052Bx1X62m4IvJKg7tRgizYUvGcYxQ4KCwn nkYGetr7oTYkAgRSkCUIKjYkduupxZwgjThKyYRpX5RrMWbF1tm4eZU9WT/yuM30ELIy rLitCw0wgZ5MV12nL6DLBTtuDQP7Equt7lD+gsTrEANDKPEoBQGckhp4iy5cTaXhMTfi DxPK/wTXJgf0kIwZcxZLhcrStIS6uFKa2Yjm6Fts38mHfL4eFTIlFvPWP8RWpjXOKmKh OfRg== MIME-Version: 1.0 X-Received: by 10.152.105.203 with SMTP id go11mr18958853lab.53.1358809192991; Mon, 21 Jan 2013 14:59:52 -0800 (PST) Received: by 10.112.138.131 with HTTP; Mon, 21 Jan 2013 14:59:52 -0800 (PST) In-Reply-To: <50FDC733.209@googlemail.com> References: <50FDC733.209@googlemail.com> Date: Mon, 21 Jan 2013 23:59:52 +0100 Message-ID: To: Crypto Compress Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d04083e33440c8704d3d46b01 Subject: Re: [PHP-DEV] [VOTE] Alternative typehinting syntax for accessors From: nikita.ppv@gmail.com (Nikita Popov) --f46d04083e33440c8704d3d46b01 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jan 21, 2013 at 11:54 PM, Crypto Compress < cryptocompress@googlemail.com> wrote: > Hello Nikita, > > for me this "maybe-of-type"-typehinting is a small progression in the right > direction. > > But "Default values and nullability" would break existing code as you need > to add a default null at "design-time" (BC break): > > class C { > public $a; // public string $a = null; > public $b; // public string $b = null; > public function __construct($a, $b) { > $this->a = $a; > $this->b = $b; > } > } > > // test only a > $c = new C("foo", null); > var_dump($c->a === "foo"); > > // test only b > $c = new C(null, "foo"); > var_dump($c->b === "foo"); > ?> > > http://3v4l.org/4oi9k > > cryptocompress > Sorry if it wasn't clear: The nullability stuff only applies if a typehint is used. If no typehint is used, then you can freely assign null, regardless of whether or not you have the "= null" in the declaration (no typehint = everything's valid). "public $foo;" will continue to behave exactly the same way it did before :) Nikita --f46d04083e33440c8704d3d46b01--