Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84084 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41186 invoked from network); 28 Feb 2015 19:37:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2015 19:37:02 -0000 Authentication-Results: pb1.pair.com header.from=cryptocompress@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cryptocompress@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 74.125.82.172 as permitted sender) X-PHP-List-Original-Sender: cryptocompress@googlemail.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:33260] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 93/00-40829-CD812F45 for ; Sat, 28 Feb 2015 14:37:01 -0500 Received: by wevk48 with SMTP id k48so26236744wev.0 for ; Sat, 28 Feb 2015 11:36:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=uDs5f87AVdLsv+n9Ls4OrQxVc8LYeQnYeyyo8TVW/Qs=; b=ldeRRNVdsE7mUy15KXqL0RP3jjzz7AQaTVhAd1yZhlE5Ro2ZXiJYbOhLqtlfP8ESV9 GOEEPPqv8PbHo3x00TbX78wpz1EMupv1anqibDQgeV/poOr7P7l+ibmhzuqg1GODBoKA vnhhIjDguxdb2TlonPjaJzNYuW4O/GUpyQ/u/OmDT/gxOMdiMK4q8D4DfOzSdibrjDid LQMnMrmAT9xEwHZse3kREspCZWP5M7OceBl4cmXq6fQzN/+u6BM5fcDSGwndiuLxqolJ 6ghqmpMF+ZDNTmOC65b70eB6Kp8Pv/qTXh27xGWb7UVLqS8IHswbwQeRUZD5sjjsLByK A/sQ== X-Received: by 10.180.87.169 with SMTP id az9mr19564312wib.72.1425152217242; Sat, 28 Feb 2015 11:36:57 -0800 (PST) Received: from [192.168.1.115] (mnch-5d85f138.pool.mediaWays.net. [93.133.241.56]) by mx.google.com with ESMTPSA id vh8sm11429304wjc.12.2015.02.28.11.36.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Feb 2015 11:36:56 -0800 (PST) Message-ID: <54F218D6.6080603@googlemail.com> Date: Sat, 28 Feb 2015 20:36:54 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Patrick Schaaf CC: PHP Developers Mailing List References: <54E5F77D.9090406@fischer.name> <54E6F48A.9040906@fischer.name> <54E72FE7.9030803@googlemail.com> <54E7312D.9090404@googlemail.com> <54E73E70.5020403@googlemail.com> <54F209B9.5020200@googlemail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------070807020206030509070603" Subject: Re: [PHP-DEV] [VOTE] Expectations From: cryptocompress@googlemail.com (Crypto Compress) --------------070807020206030509070603 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Am 28.02.2015 um 20:08 schrieb Patrick Schaaf: > > > Am 28.02.2015 19:32 schrieb "Crypto Compress" > >: > > > > class BankAccount { > > function Add($amount) { > > assert($amount > 0); > > // ... code block ... > > } > > } > > > > Now the programmer implementing "code block" to gracefully handle > $amount > 0 has a problem. There is no way to (Unit)test failing path > on development machine. Code after assertion is never called for > failing contitions. What to do? > > Put the assert AFTER handling the always-to-be-done validation, of > course. Doesn't make sense otherwise. > > Patrick > if ($amount > 0) { ...code block... } // else { throw new WrongAmountEx(); // } Frankly i can't see any point in using assertion after checked expression thus duplicate the expression. It's simple a bug. As situation is clearly wrong, throw/exit/die and change code flow as desired. This is not the "conditionally unreachable code" case i argue about. --------------070807020206030509070603--