Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92580 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18340 invoked from network); 20 Apr 2016 21:04:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Apr 2016 21:04:10 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.48 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:33781] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/F8-14036-9CEE7175 for ; Wed, 20 Apr 2016 17:04:09 -0400 Received: by mail-pa0-f48.google.com with SMTP id zm5so21370146pac.0 for ; Wed, 20 Apr 2016 14:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=fGX4S+Lpa48ify7K4G6ZwvGLoE5QXRo57FdHC5+dgV4=; b=orS1MiKzZ/cH9fPxRE8YFJ1JVpVksx9G3G1WO9jik+zF12GLrp9CgYZX01EZath32q 8lCCpLzIx7BC7ugHMMvUUFowV8NSVHUa30UDu2oAisnfTC3RJuqF4MRxb59t7Cped6ev CMwefhlwJ6+Kh+1IFS5OX0UlKH87sfDasvKwHjk+pq+vU1B4nwNfTAKH6eSzZm3vhLx6 MQptgVxTlyaBmsCCYMmb6x9fXesNGuOo+Dlnj2ZNKN3DasZ3cKsz7S/9UAix3Hy0iR55 NO/F53IurVDLwHvMcRDqQ1AuLRCpqz58iQKTt4kpFNAy0HNgBGNtfLYFOLtB18AHj37F OuBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=fGX4S+Lpa48ify7K4G6ZwvGLoE5QXRo57FdHC5+dgV4=; b=U1Z8bZGb28KOMDs2jxFc0Mp7mOfmAFUzpeLF6URbHr7v2YR55INHxH+ZzLFrNTBlX+ tQCgcRLmE/f/IxT7hNr43eBcZVfbcxNorwHH+PaNwlm1Dr7w71krz43GJdOH7l9D9rzR el8UNejzD0xtUqWdpPyELaRXNZxuDU9asbmH70rwsAJ/Unqv63mcKj4XsmNDLkULGCz1 hw7LcK+BCOgRcdcHcMxWn0sPeHfGDlgnBU+dAOMSGKvgLu3sKqW5lAvjlVnq3Ig8jckB MvXo8hL/kkEFO9XbCsolZPd8IQmwuMhCqcd+fwWb65AAcgJdoTxQkhUqvYAMewWO6fBw nWxQ== X-Gm-Message-State: AOPr4FXQQipj43E/H+FMlZphwwOkq+HD4ITBszIQoZal/eiteeCq9hdv/xCLQ+1hZ09mnA== X-Received: by 10.66.140.105 with SMTP id rf9mr15255752pab.117.1461186246769; Wed, 20 Apr 2016 14:04:06 -0700 (PDT) Received: from Stas-Air.local (76-220-46-95.lightspeed.sntcca.sbcglobal.net. [76.220.46.95]) by smtp.gmail.com with ESMTPSA id o7sm100366206pfa.37.2016.04.20.14.04.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2016 14:04:05 -0700 (PDT) To: "guilhermeblanco@gmail.com" References: <5717D70E.5010706@lsces.co.uk> <5717E02C.9030505@gmail.com> Cc: internals Message-ID: <5717EEBD.80303@gmail.com> Date: Wed, 20 Apr 2016 14:03:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Quick sanity check ... From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > The question here is how type strictness would benefit the language. > I agree with you on most parts. But still... if the class was declared > like this: > > class CancelOutdatedOrdersDTO { > public int $olderThan; > } > > Wouldn't that be solved entirely? Code would crash (through a No of course not. The specific instance of error you had *this time* may be solved. The problem won't be. You still have to deal with: - How this object is initialized? How you ensure it *is* initialized and that initialization is correct (0 is perfectly valid int)? - How this object is unserialized and what if unserialized data has non-integer or 0 or __wakeup has a bug? - What if some code just writes 0 into $olderThan - you declared it as public so anybody could mess with it? - What if some code mixes signed and unsigned and you get negative number instead of positive? - What if this code runs on 32-bit but receives 64-bit value and truncates it? And so on, and so forth, I probably missed more possibilities than I mentioned. Declaring a type does not magically free one from correct design and testing, and typed programs have bugs as much as non-typed ones (maybe slightly different ones). Actually, one of the harms relying on it would be the same problem safe_mode had - it's full of holes, it's not safe and it creates wrong expectations. If you just write "int" and expect your problems to magically go away - you're in for big and bad surprises. -- Stas Malyshev smalyshev@gmail.com