Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62176 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11722 invoked from network); 15 Aug 2012 09:26:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 09:26:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; 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-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:62535] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/53-30529-25B6B205 for ; Wed, 15 Aug 2012 05:26:43 -0400 Received: by lahl5 with SMTP id l5so746595lah.29 for ; Wed, 15 Aug 2012 02:26:39 -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=ADwLw1T2PaBF7YlSmzkewDqabj67BgqCodjKH3+08aM=; b=Gs5S/Ahjw6nXOllDaleHKTx/EzJIyIlNWr2J068Hsajuad2fDV+CKoLXXvewSwynch RsodUvdJ2V9VhY3s1g0/dH3ugzYHQo9lpOkVLiHo9maNx/FS6NrOFllB4MKXKJswb/vP TEekBnm6sa+KkWdvKXebT39zr/09+r26kAyR4DXBH1I+Qz3sJMxDQaNKK45YM+brB13F CIiNPJQ3FJ13y1/HlCk6qWpnLCVbSzWBOyI5z2SB/iz/tmL+GSwMzE4fw65HEP3wMb+I arMmXk10CF6geortwFgCXuf04Y+JvtVyN9mdzj8qA6O+cLXKxKi62/Up9vuSe2jQHKn3 Z2jA== MIME-Version: 1.0 Received: by 10.152.144.168 with SMTP id sn8mr3029722lab.1.1345022799613; Wed, 15 Aug 2012 02:26:39 -0700 (PDT) Received: by 10.152.122.51 with HTTP; Wed, 15 Aug 2012 02:26:39 -0700 (PDT) In-Reply-To: <1583D6716BFA4BF985E795A1363F465E@pc> References: <502A86AA.2030203@sugarcrm.com> <502B57AE.4070801@sugarcrm.com> <502B5C7F.1070708@sugarcrm.com> <6D84602D0F514FA3B82C11DBAF58AA53@pc> <502B5F8A.5000500@sugarcrm.com> <6281E4639C7248488268ACED88B86B7D@pc> <502B669E.7040702@sugarcrm.com> <1583D6716BFA4BF985E795A1363F465E@pc> Date: Wed, 15 Aug 2012 11:26:39 +0200 Message-ID: To: Stan Vass Cc: Stas Malyshev , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces From: nikita.ppv@gmail.com (Nikita Popov) On Wed, Aug 15, 2012 at 11:17 AM, Stan Vass wrote: > You're 10 years too late to argue the merits of typehints in PHP. > > I am not proposing the introduction of typehints. I'm just saying "we have > the option to use them in arguments, let's have the options inline too." > This way we can validate expressions and structures we can't today, in a > minimal, readable, consistent, easy to maintain way. Stas already pointed out that parameter typehints allow you to define the interface for your method. Return typehints would server a similar purpose and as such I'd consider them useful. But "variable" typehints don't serve any such purpose. Actually, one could even say that they don't serve *any* purpose, short of providing the IDE with type information, because your code would work just as well even without the type check. If the type were wrong, it would just throw a fatal error when trying to do something with it (like invoking a method that does not exist). And if the sole purpose is type hinting for the IDE, then I don't see what's wrong with the established system of PHPDoc comments. They seem to serve the same purpose, don't they? Nikita