Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49357 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62761 invoked from network); 11 Aug 2010 17:12:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2010 17:12:09 -0000 Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 209.85.210.42 mail-pz0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:52274] helo=mail-pz0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/6B-01618-6E9D26C4 for ; Wed, 11 Aug 2010 13:12:07 -0400 Received: by pzk30 with SMTP id 30so153214pzk.29 for ; Wed, 11 Aug 2010 10:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=CufhYbeslc4SJ5BfZ7OhiuQdP9Nmzt3B85mKE0mRobM=; b=rATz3r263LqINfVtcBOqrNU7U+Ted8uWTaoQCTaUVkDSEwKRn+vRe9pG7JXx38d0Up fTnIUBw/41RClKyaBUiRsmufWvWLyXEZfn5aqLmg4pKLuP5cnQTpyCgtxEI8AULRf2Qg xpVW58zPwYfG1RtOLiMIu5gG1qkoR1l+b5+hk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=CxXXiM/lkpLxEKRwkRuP5bglvP5C+kyrhIT9wV3H8CS/cd7ufEICQDfuoD17OxW/xJ pWRYxS3z+AJCnq/29rqPnhO7kQJTTRWvwt97wmsi5FpnH8NuTRoHqoqHfppZnMfntbPS aTay0yN0CIgDJJKqnsVsZo2W9afSeSe8i8vRM= MIME-Version: 1.0 Received: by 10.142.223.14 with SMTP id v14mr16438096wfg.275.1281546720869; Wed, 11 Aug 2010 10:12:00 -0700 (PDT) Received: by 10.142.43.8 with HTTP; Wed, 11 Aug 2010 10:11:58 -0700 (PDT) In-Reply-To: References: <1281478269.6608.292.camel@guybrush> <4C61E5CA.5070604@sugarcrm.com> <4C61F3EF.5030409@sugarcrm.com> <4C6241D1.6030909@sugarcrm.com> Date: Wed, 11 Aug 2010 21:11:58 +0400 Message-ID: To: Josh Davis Cc: Stas Malyshev , Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Strict typing From: indeyets@gmail.com (Alexey Zakhlestin) On Wed, Aug 11, 2010 at 8:56 PM, Josh Davis wrote: > On 11 August 2010 08:23, Stas Malyshev wrote: > >>> I very much can, it's just not my intention. I want to be able to use >>> type hinting/type checking as a sanity check. If I write a method >>> whose signature is foo(int $n) I signal my intention to only accept >> >> Then you should use statically typed language. > > Yeah, hmm, no, and it is disingenuous of you to equate type hints to > PHP becoming statically typed. I'm sure that some people would love to > have optional static typing in parts of their code, but I like being > able to use my vars freely when I need to. Being able to enforce what > type of arguments can be passed to my functions and methods would > allow me to cut down on my parameters validation. Similarly, I like > using protected methods to prevent users [developers using the code] > from misusing them or protected properties to prevent users from > inadvertently modifying them, so that I don't have to worry about the > application being in an inconsistent state. > > PHP being dynamically typed shouldn't be an argument to prevent people > from enforcing method signatures. You're saying that PHP users should > have no control over what variable types are passed to their > functions. Did you read second RFC? The one which is about "so called" weak typehintin= g. Stas (and a lot of people on this list) prefer it. http://wiki.php.net/rfc/typecheckingstrictandweak If you did, can you tell if there is some case, when it doesn't work for yo= u? The idea is simple: 1) if variable type matches =E2=80=94 variable is passed to function 2) if variable can be safely converted to the type, which matches =E2=80=94 variable is converted and passed to the function (you still get variable of desired type) 3) if variable can not be safely converted =E2=80=94 error is raised error is E_STRICT or E_FATAL (not decided yet). anyway, you can handle it as fatal in error-handler if you need to this way you (library developer) get your desired data-types for input and users get freedom to pass numeric strings instead of numbers good for everyone --=20 Alexey Zakhlestin http://www.milkfarmsoft.com/