Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113898 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15634 invoked from network); 1 Apr 2021 09:16:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Apr 2021 09:16:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3E59A1804DD for ; Thu, 1 Apr 2021 02:14:10 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 1 Apr 2021 02:14:09 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id 12so1735345lfq.13 for ; Thu, 01 Apr 2021 02:14:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CKsvrbHZMpQqr1LvUUDbDlyySxPStGK2GCg7V02K2Wk=; b=FEbWu3s6vuscLv/xKWkQTwmMYFB0FLPqhgrK5OgcCag4geTkhGJM14lTmcBIX7VFl+ B1xLwtinLSwbpRz2SwGuImsfogvBLOaaUmF/GcnOCshyNc9qkC+YA/adn2RdzCS28XZn pKtMWY2CUJAXvzP5z6gOsppM+A+x1hjCg2kdJ27JKkg8GpsnTPfr88OgoHDZXLaYKgBJ 2keZAMM9nnNcF5X4Y4TAt2ZwStLvzN4+kVQskLFyCrbykKzFTzqOf7oWscoUzq9FAxEY eU2UoqbGf7I674GDetSHoHbhXvnzCPHu2XBGmjFVZc93GmkRGC32ji6y/wptJhlcL6dO 6jjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CKsvrbHZMpQqr1LvUUDbDlyySxPStGK2GCg7V02K2Wk=; b=V2W9n0D0kasGjZUAVvkIgPIws0ihX+Kax+3ltWz8sMAp/Kxm0evAdswS4J3Yr6uPDM /Wt3zYk5pp1mwW6ugAsgnfBA14p5CthPHklFs54JVbulpM1mf5LWPLWuTzB1PkdHOvim sj2xn7OO/BVqP2KBQNFEIm0z4+9cREGk/i0WhMv34fVqT//6EPmARYzgZZiTDo9lfUz4 MCFmQCCx6CzUvyXbnRRq4beYyo0nWcYg3/TQk174wIwqoemccTMA+PMCweYiEsu3upsT mIpVVqf/j8XxgqpZ9Bjr7QPiLSr/yFlxmLo7ckR3cjKWSBBk010FxxQNIR/TuS123/IB pJmw== X-Gm-Message-State: AOAM5329bWW0t8Yv6I3AWYRTJwYHCKHGyiNulIrrhLOz1WtUUsXwEl0V g7jjIBjvuoyMkcu9BRvOUAWXTzyC1w36alCvEg== X-Google-Smtp-Source: ABdhPJxqQgBwHGx2XdZBrNRcCKPNY76AJskjXQY9ep6oiS4GuLyNlasSs7x8IzdeWCcEGBB/ztG5F3CqotX4PyjLX5M= X-Received: by 2002:a05:6512:4c9:: with SMTP id w9mr4893746lfq.335.1617268446043; Thu, 01 Apr 2021 02:14:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 1 Apr 2021 11:13:55 +0200 Message-ID: To: =?UTF-8?Q?Olle_H=C3=A4rstedt?= Cc: Arnold Daniels , internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000003b9f5f05bee5a74f" Subject: Re: [PHP-DEV] Why is assert limited to a debugging feature only? From: guilliam.xavier@gmail.com (Guilliam Xavier) --0000000000003b9f5f05bee5a74f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 1, 2021 at 10:50 AM Olle H=C3=A4rstedt wrote: > 2021-04-01 10:24 GMT+02:00, Arnold Daniels = : > > Hi, > > > > The documentation of `assert` > > ([ > https://php.net/assert)](https://www.php.net/manual/en/function.assert.ph= p > )) > > states that's debugging only. This is further enforced by php.ini flags > to > > disable assertions in production. > > > > Why are the use cases of this feature being limited to debugging? We ca= n > see > > from the popularity of user-space assertion libraries, like > > [webmozart/asset](https://packagist.org/packages/webmozart/assert) and > > [beberlei/assert](https://packagist.org/packages/beberlei/assert), that > > there is a need for runtime assertions. > > > > [Arnold Daniels - Chat @ > > Spike](https://spikenow.com/r/a/?ref=3Dspike-organic-signature&_ts=3Dyu= x2k) > [yux2k] > > Dunno about the motivation of the implementors, but usually assertions > are used for internal invariants and mental checks while exceptions > should be used for interaction with the outside world (database > errors, user input errors etc). If you follow this, an assert error > will never be useful for a user, it will always be an "internal > error", and that's why it can (should?) be disabled in production. > > Olle > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > Hi, I agree with Olle's explanation (and am indeed using `assert()` that way). Also note that both linked libs throw `InvalidArgumentException` (subclasses of), so not the same kind of "assertions" (despite the name). Regards, --=20 Guilliam Xavier --0000000000003b9f5f05bee5a74f--