Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81774 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41552 invoked from network); 4 Feb 2015 07:11:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 07:11:34 -0000 Authentication-Results: pb1.pair.com header.from=francois@tekwire.net; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=francois@tekwire.net; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain tekwire.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@tekwire.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:27132] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/07-20608-426C1D45 for ; Wed, 04 Feb 2015 02:11:33 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 627D94B023F; Wed, 4 Feb 2015 08:08:14 +0100 (CET) Reply-To: To: "'Dmitry Stogov'" , "'Yasuo Ohgaki'" , "'Joe Watkins'" Cc: "'PHP Internals'" , "'Andrea Faulds'" , "'Nikita Popov'" References: In-Reply-To: Date: Wed, 4 Feb 2015 08:11:24 +0100 Message-ID: <00c101d04049$ca411ec0$5ec35c40$@tekwire.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQI+MKsMv6zrm7KCv5jpZIs/BqhffwHJ9dvJAVdrBXib6x3c0A== Content-Language: fr X-Antivirus: avast! (VPS 150203-1, 03/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] What do we need strict scalar type hints for? From: francois@tekwire.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) > De : Dmitry Stogov [mailto:dmitry@zend.com] > Hi Yasuo, >=20 > You probably talk about https://wiki.php.net/rfc/expectations > I wasn't the author of idea, I just helped with thoughts and = implantation. > I think it may be useful for PHP7. In accordance with Yasuo's suggestions, couldn't we consider assertions = as part of a future implementation of the wider 'design by contract' = concept ? DbC could handle : - function inputs : 'smart' built-in arguments types (keeping loose = typing), constraints on possible values - function output : accepted return types/values - assertions anywhere in the code Function input/output validation would be done using built-in 'smart' = types ('string', 'numeric', 'integer', etc), and, optionally, = 'validator' functions. These could validate any aspect about = argument/return type and value. The key point with DbC (as well as = assertions) is that, as there's no constraint on performance, validation = can be very precise and can run in userland code. For function input/output validation, I would extend the phpdoc syntax = (keeping compatibility with existing comments). Another suggestion for assertions : if we hide it in comments (something = unusual like '//@@assert(...)'), we probably don't need to define an = opcode and it can be implemented as a standard function. The question of whether DbC should replace or just supplement arg/return = typing remains open :). What I suggest, if you agree, is that, even if we don't implement the = whole DbC concept now, we could already consider assertions as being = part of it, and rename zend.assertions to zend.dbc, assert.exceptions to = dbc.exceptions, and AssertException to DbcException. Regards Fran=C3=A7ois