Re: Debugging with zero cost in production
| From: | Fleshgrinder | Date: | Mon, 24 Oct 2016 17:12:26 +0000 |
| Subject: | Re: Debugging with zero cost in production | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96602@lists.php.net to get a copy of this message | ||
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