Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96602 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76118 invoked from network); 24 Oct 2016 17:12:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2016 17:12:37 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.86 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.86 mx105.easyname.com Received: from [77.244.243.86] ([77.244.243.86:60388] helo=mx207.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/70-07271-3014E085 for ; Mon, 24 Oct 2016 13:12:37 -0400 Received: from cable-81-173-132-21.netcologne.de ([81.173.132.21] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1byinY-0007Xx-Uk; Mon, 24 Oct 2016 17:12:33 +0000 Reply-To: internals@lists.php.net References: To: David Rodrigues , PHP Internals Message-ID: <93e54a0c-5bda-f21f-2637-765a32a1aba3@fleshgrinder.com> Date: Mon, 24 Oct 2016 19:12:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Debugging with zero cost in production From: php@fleshgrinder.com (Fleshgrinder) On 10/24/2016 7:10 PM, David Rodrigues wrote: > Hello, folks. > > I'm thinking about a debug function to allow us to create "zero cost > declarations" in production code, as assert() does. > > From what I understand, if I have something like assert(method()), > method() will not be called in production, only in development. > > This behaviour is great because we can help the PHPUnit, for instance, > to capture messages in specific places to check if some process have > generated the correct value without test it alone. > > For instance: > > // On test()'ed method: > debug(TestStack::put($varValue)); > > // On test method: > test(); > static::assertSame(123, TestStack::pop()); > > How it should be a debug code, should be important that it not be > generated and executed in production. > > Could I use assert() to do that, in all case? Then I could consider it > as "already implemented". > > Bye! > You can already use assert in exactly this manner. -- Richard "Fleshgrinder" Fussenegger