Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62175 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10143 invoked from network); 15 Aug 2012 09:17:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 09:17:55 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 209.85.215.170 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:51093] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/F2-30529-1496B205 for ; Wed, 15 Aug 2012 05:17:54 -0400 Received: by eaao11 with SMTP id o11so384177eaa.29 for ; Wed, 15 Aug 2012 02:17:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:from:to:cc:references:subject:date:mime-version :content-type:content-transfer-encoding:x-priority:x-msmail-priority :x-mailer:x-mimeole:x-gm-message-state; bh=uVgvD+ser98L76lfgFVcfogLLLu8R9ExdSv3aJg5q1U=; b=j+XPBmIMP+BIvth4FVJ/eH7s+d6SEv3ki+j+FG3RZugZzQGYvM2EzvJg5h4uuPkLY8 Q/Psc6O6MPa3Oewt26UW8C1NDI9N1pTmCsJQucDM6OkmAkm3UqaPiAWJGN2RrPn6k6bM NtI4F2xhoKqmNpv3cuZqMaTIoc+wRFdXi7V3P23XAVXZyz+mnsMuhU11Ncr81Msm9mLg yEcjHjar8sDPe9gAaS/qvaIEarNaP5chy/ZBuLfGIgBal6mF87nopGU3LjgGtBZ8x2nx 9K4JGoIDaj5To9r8XCbMzJSrnKNvXyH+S0r+k6jr2D0RwqSGFVT0xSCx+5eVjjz5HD/G KRYA== Received: by 10.14.218.134 with SMTP id k6mr19347354eep.14.1345022271345; Wed, 15 Aug 2012 02:17:51 -0700 (PDT) Received: from pc (95-42-66-13.btc-net.bg. [95.42.66.13]) by mx.google.com with ESMTPS id 9sm2423232eei.12.2012.08.15.02.17.49 (version=SSLv3 cipher=OTHER); Wed, 15 Aug 2012 02:17:50 -0700 (PDT) Message-ID: <1583D6716BFA4BF985E795A1363F465E@pc> To: "Stas Malyshev" Cc: 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> Date: Wed, 15 Aug 2012 12:17:46 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Gm-Message-State: ALoCoQlABfZqbIkfG2D3hts4VoUvHTq8diEXjI/9dTkCdPSu05go0sIpEr4ciRQ+zcukqudInJha Subject: Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces From: sv_forums@fmethod.com ("Stan Vass") > Hi! > >> All right, your method accepts an array of objects, instances of Foo. How >> do >> you enforce this contract? > > You are trying to re-invent generics/parametrized types and bolt it onto > PHP. I still don't think it is a good idea - PHP is not a statically > typed language. Just check you array elements if you need. 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. > By "peppering" here you mean one if. Yes, this is my proposal - if you > need to do a check - do a check. Yes, exactly: one if. For your entire codebase that has one single assignment in it. Or one foreach. Pick one or the other, but not both, otherwise they become two ifs, and that invalidated your argument. >> The same applies to typehints, so make up your mind. > > No it does not. But this is exactly why I think one of the problems with > strict typing in arguments is - because people take it and starting to > use it as a legitimation of turning PHP into weird hybrid of dynamically > typed language with random islands of static typing popping in random > places. I still do not think it is a good idea. Saying "weird hybrid random islands popping random" doesn't make simple type validation hints any more awkward than they were yesterday before I posted this thread, Stas. Stan