Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82409 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99713 invoked from network); 11 Feb 2015 03:02:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Feb 2015 03:02:31 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.46 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.46 mail-qa0-f46.google.com Received: from [209.85.216.46] ([209.85.216.46:63428] helo=mail-qa0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/00-33902-546CAD45 for ; Tue, 10 Feb 2015 22:02:29 -0500 Received: by mail-qa0-f46.google.com with SMTP id n4so768410qaq.5 for ; Tue, 10 Feb 2015 19:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=AjZTPb41vwd+vFnEx+Dy0cdHTRCHxlAtqb5Is80osWc=; b=XSA4tGkiEpz3aaa5tDTbI0KFjSew39hELPTVysabKzr7gm5tC6ki7KJodxPGAopiE4 S5PAZZlJsOMGdVcFDQBB7bZGT2pCx0jSWQ0HN0CFUP5kKloXC7HAZ3/u2j6YnMD4XAHD plc1DSL8mayTsaeLX0d3zEA+FFnQLXcT3mkQAW8kDr35VBYOHRRYyeAD0TB1wr0k9d8t JySoo/S64IFfltOK/UtpwYuzb+ApowgpXmm3tx/vEN39IU9sts+DWu69KF0DSwmvwvo2 Hj/JC/SvwGe9LFh/VDYY2bSb0GzRU/K2r8w8G2AcNva7trooK3kbmXZtN+HhK0a9IREs qrew== X-Received: by 10.140.21.229 with SMTP id 92mr57826256qgl.33.1423623746893; Tue, 10 Feb 2015 19:02:26 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.250.195 with HTTP; Tue, 10 Feb 2015 19:01:45 -0800 (PST) In-Reply-To: References: <54D7ED22.3080001@gmail.com> Date: Wed, 11 Feb 2015 12:01:45 +0900 X-Google-Sender-Auth: ybixrQMuW7AGAP1CEnuBIjpQC9Y Message-ID: To: Dmitry Stogov Cc: Joe Watkins , Patrick Schaaf , internals Content-Type: multipart/alternative; boundary=001a11c12f8cba4050050ec73b24 Subject: Re: [PHP-DEV] Design by Contract From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c12f8cba4050050ec73b24 Content-Type: text/plain; charset=UTF-8 Hi Dmitry and Joe, On Wed, Feb 11, 2015 at 6:29 AM, Yasuo Ohgaki wrote: > On Tue, Feb 10, 2015 at 8:53 PM, Dmitry Stogov wrote: > >> You are welcome to edit https://wiki.php.net/rfc/dbc2 >> It looks like we have similar views, so just make it better in a way you >> think. >> > > Looks good to me. It's much better than original. Thank you folks. > We have related issue like how internal module incorporate with DbC. > However > these could be future issues. > I would like explain one of the reason why I bring up internal module. http://php.net/manual/en/class.sessionhandlerinterface.php Session has internal interface definitions like SessionHandlerInterface { /* Methods */ abstract public bool close ( void ) abstract public bool destroy ( string $session_id ) abstract public bool gc ( string $maxlifetime ) abstract public bool open ( string $save_path , string $name ) abstract public string read ( string $session_id ) abstract public bool write ( string $session_id , string $session_data ) } but it should be like follows to be precise. SessionHandlerInterface { /* Methods */ abstract public bool close ( void ) return($ret, is_bool($ret)); abstract public bool destroy ( string $session_id ) require(strlen($session_id) > 0) return($ret, is_bool($ret)); abstract public bool gc ( string $maxlifetime ) require($maxlifetime >= 0) return($ret, is_int($ret) && $ret >= -1); abstract public bool open ( string $save_path , string $name ) require(is_string($save_path)) require(is_string($name)); return($ret, is_bool($ret)); abstract public string read ( string $session_id ) require(strlen($session_id) > 0) return($ret, is_bool($ret) || is_string($ret)); abstract public bool write ( string $session_id , string $session_data ) require(is_string($session_id) && strlen($session_id) > 0) require(is_string($session_data)) return($ret, is_bool($ret)); } This definition is more user friendly. There were too many user save handlers that do not return proper values because of current interface limitation. Scalar type and return type hint helps, but it does not cover return($ret, is_int($ret) && $ret >= -1); for example. If you think this is easy to implement and should be in the RFC, I would appreciated it and use it to raise assertion errors just like user class/interface. BTW, these restrictions are coded as error in current session module and should be checked by the module always. It's not mandatory for the RFC, but just a missing piece. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c12f8cba4050050ec73b24--