Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62173 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4057 invoked from network); 15 Aug 2012 08:43:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 08:43:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 74.125.83.42 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 74.125.83.42 mail-ee0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:51537] helo=mail-ee0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/A1-30529-8216B205 for ; Wed, 15 Aug 2012 04:43:20 -0400 Received: by eekb15 with SMTP id b15so376274eek.29 for ; Wed, 15 Aug 2012 01:43:17 -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=ydu96rxE/xK1ZqlLI/Rj859g4nJ+e0qNfwh61iBfW34=; b=DgkO2gDuoKLdhJyQgC3eL35epyyNf62yWz95EVZzZx1i9TOBlftei+sc2soV+jwago 7jyIb7aeyn1arXtFi3Hw9z9lcwgbT/QEcfG5IHzNs2PhlAAngds0he1usLT6S6Z4swuk aJpdII6Cm+iWSJdHy2qkyddp1SLu4eOR+UOVg176f1Wp7KSoGEdNSlloilZWsZF5u576 9BCBUgRX0Zpw4lhXp0rMa/qaX3dQ8Sxgzw/8rowhFyWSMEcZUuGhqn9pbZp2lvrn2K8F sJPxDbqTmmC7k7XPxi6thTkqWDn0O5oS+DSYG1CvcxQX83oR1BxasvBjI43pvt9/zPMf VeHw== Received: by 10.14.224.193 with SMTP id x41mr22180287eep.46.1345020197261; Wed, 15 Aug 2012 01:43:17 -0700 (PDT) Received: from pc (95-42-66-13.btc-net.bg. [95.42.66.13]) by mx.google.com with ESMTPS id k49sm2241366een.4.2012.08.15.01.43.15 (version=SSLv3 cipher=OTHER); Wed, 15 Aug 2012 01:43:16 -0700 (PDT) Message-ID: <6281E4639C7248488268ACED88B86B7D@pc> To: "Stas Malyshev" Cc: References: <502A86AA.2030203@sugarcrm.com> <502B57AE.4070801@sugarcrm.com> <502B5C7F.1070708@sugarcrm.com> <6D84602D0F514FA3B82C11DBAF58AA53@pc> <502B5F8A.5000500@sugarcrm.com> Date: Wed, 15 Aug 2012 11:43:13 +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: ALoCoQkOR2lT8WIYbmBA7if/5BVTvjbZB7xUEfjlUzhfekRLRD+Nb9Nu13ANghUo3aukWUNltdZP Subject: Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces From: sv_forums@fmethod.com ("Stan Vass") > Hi! > >> Let me ask you - do you think the existing PHP typehints are pointless >> too? >> Do you feel they don't give you enough flexibility? Do you feel they >> reinvented a language construct for the purpose of saving the typing of >> one >> if clause (per argument) (per method) (per class)? > > They are not pointless, but I think they are often misunderstood and not > used correctly. And they definitely lack flexibility in many cases. But > they are helpful for one important thing - defining interface between > the method and the method client. Having strictly typed variables does > not serve it, and trying to make PHP into half-baked > half-statically-typed language does not sound like a good idea to me. All right, your method accepts an array of objects, instances of Foo. How do you enforce this contract? Here's how my proposal enforces it: function foobar(array $collectionOfFoo) { foreach ($collectionOfFoo as Foo $item) { ... } } What's your proposal? From the discussion so far, I'd guess it's peppering out code with if-s with the same error written everywhere everytime we check the item in an array. > Because I don't think inventing language constructs for the purpose of > helping IDEs simulate static typing in dynamically typed language makes > much sense. The same applies to typehints, so make up your mind. Stan