Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81959 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55751 invoked from network); 5 Feb 2015 19:15:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 19:15:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.176 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.176 mail-vc0-f176.google.com Received: from [209.85.220.176] ([209.85.220.176:46123] helo=mail-vc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/89-27691-351C3D45 for ; Thu, 05 Feb 2015 14:15:36 -0500 Received: by mail-vc0-f176.google.com with SMTP id kv7so3406097vcb.7 for ; Thu, 05 Feb 2015 11:15:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ti4UeGl5v0fyHjwMAAroN9k52yR08zdlHEUBPmzVzAA=; b=FAUob9X5lJWL5LDbdyCzyJ9Jh8nH8QAPmZ6iLVbYDsPUSruvKbdHahKjzJSLcVJOLs ReFPHbQ77h4op4c5JqE22I+kHAak5sgunfslOMTdTpjk9HxCcuVEXDWoUsDFi/bYvYwO e5X13OrrJuUBLW4ND+SDPWE3qMLWqdDfKAQkIuQwNDINMUGrRW1BFx8Ux8hcJRrOqAoa q4t2S+fTuecQEVC3wauUb9fUV8B2R192HSZd4VlYPng5QhPZt4IeZzD+t9n/odxnYKEY AebbbNOXz1HzVQ+6n1eVdhShdWO56WU0mej8s1xBN4hQiH7CcuqesN3k9+HZWk4rveuO vodQ== X-Gm-Message-State: ALoCoQmHYOBMlN554SYi4B2oW+/ESaNW0oyT4QBF1nv/qil97PNdmcAn+42gi4rvawYH9krOW+cbz11oP/QoZvLLFcalLmIO/sk7xySppX+bSzm3ZVFDjAdBIEhaiBTkSfirSJ1XjkTPc6baC6dzgV17bUQJrgPcng== MIME-Version: 1.0 X-Received: by 10.220.5.195 with SMTP id 3mr3664362vcw.21.1423163727978; Thu, 05 Feb 2015 11:15:27 -0800 (PST) Received: by 10.52.74.73 with HTTP; Thu, 5 Feb 2015 11:15:27 -0800 (PST) In-Reply-To: <5EFCBA22-D032-4444-8E11-F44FA07A722A@ajf.me> References: <00c101d04049$ca411ec0$5ec35c40$@tekwire.net> <54D1CA7C.8060204@php.net> <54D1E6EC.7060702@php.net> <54D2B3FA.6020900@gmail.com> <5EFCBA22-D032-4444-8E11-F44FA07A722A@ajf.me> Date: Thu, 5 Feb 2015 23:15:27 +0400 Message-ID: To: Andrea Faulds Cc: Stanislav Malyshev , Sebastian Bergmann , PHP Internals Content-Type: multipart/alternative; boundary=001a11c3ef8076af4c050e5c202e Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: dmitry@zend.com (Dmitry Stogov) --001a11c3ef8076af4c050e5c202e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Feb 5, 2015 at 9:50 PM, Andrea Faulds wrote: > Hi, > > > On 5 Feb 2015, at 06:52, Dmitry Stogov wrote: > > > > I completely agree. > > Strict typing doesn't fit into PHP. It was already told thousand times. > > Seems to work rather well in practice, so long as it=E2=80=99s optional. > "works" and "fits" are different. > > Also, the only really useful case for "strict typing" is the ability to > catch mistakes in user apps. > > However, this ability is really limited. Implementing "Design by > Contact" approach may be much smarter. > > It=E2=80=99s not that limited. I caught two different bugs in my app simp= ly by > adding strict types. > > Strict typing, crucially, allows the catching of errors ahead of time, > too. You can=E2=80=99t do that with weak typing, because it depends on th= e value, > not the type. And you don=E2=80=99t know the value from reading the sourc= e code. > Strict type hinting may help catching problems only at run-time. In PHP you almost never can do something ahead of time, because of run-time binding. You may only guess, analyzing the whole projects and performing type inference. Thanks. Dmitry. > > -- > Andrea Faulds > http://ajf.me/ > > > > > --001a11c3ef8076af4c050e5c202e--