Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113895 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10106 invoked from network); 1 Apr 2021 08:52:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Apr 2021 08:52:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DDD051804E2 for ; Thu, 1 Apr 2021 01:50:38 -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, 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-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 01:50:38 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id q29so1704421lfb.4 for ; Thu, 01 Apr 2021 01:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eMGdSAYcmR4+gjLdLQe439lpKq1EE+pAdE/ghJas/H0=; b=Auxz4KRMqiDekwkHL/69fIAHi85L/98D62CZ35B9j61LC7CMEe5h7TjHPkofYtZ2xr I9DIdoW9kO1AQ0aeGuR+PM1qqaHQ/nNYWP9yK2YPDgO3uXGVLbyiB7IBLCwo7meHstCY PISaQE4xS7B7AqwooRWqDrA1N1fn5/F7DhSGE1681emOXUHZpdkNIGaqChHSg3AWw7mi 7n1MIjcu6QPlzVx/8sSD8nCbBF302iHDo32OPbl4cwXjkK5M+TNKQPPqTkaMMh3VGbvd QcfBgZLhMYZrZYjECFLa4UYcHWlFQ2yrgjJ9fCvLMXOGpE26hlwfOE13AoVXzXb9rCUL jp0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eMGdSAYcmR4+gjLdLQe439lpKq1EE+pAdE/ghJas/H0=; b=Aa8ztIs/0XXv44R88iK1ZsIaCmcM9fjokU3A8aPDiIxWKxXvt4DgVp9gpK+qfO1ee4 gTf/CLjWrq5Enqs+DZ7gVLWBQM6pvRf+EB04B9LiyDCDCCnyEVyrx82Hw/nKIO0KXRlE hyM4eJ4YVMGxWJAfVHectI5fm/Y4kpwFMA7fz1DjYN6o7kTOW9xP1GdLt0dxuPdWXAcB KQHl1AdtIAMtNhI/yoRTVF3KaALhaPcwRWy9rT6Y0cxVN5RX0R94hfJXWtDQtFoZaSpa z0VAAotx2o7EgLnMXcw1RV6PDGW931xgBUpY1ioiQXoOLJLjjjB8+tkOWkyCndsjNJNe 3uJw== X-Gm-Message-State: AOAM531nq+XJlqc9raFZwbUQaPr5ETPq+ANQkU00SjM2pyTrzqJrNBhM l5qJfvkEB2NYborzcLbT+96MQ6b22JlvVLm5TmQ= X-Google-Smtp-Source: ABdhPJwJTDyLoDziNz1bW8uS584Z58+BeIY2LgdGIhPLS/g96OTPsmPp/Nayy3YU3+1iUFXzAkONhbo0OpNkcajaSuo= X-Received: by 2002:a05:6512:3ba9:: with SMTP id g41mr4615760lfv.421.1617267037095; Thu, 01 Apr 2021 01:50:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:5f8f:0:0:0:0:0 with HTTP; Thu, 1 Apr 2021 01:50:36 -0700 (PDT) In-Reply-To: References: Date: Thu, 1 Apr 2021 10:50:36 +0200 Message-ID: To: Arnold Daniels Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Why is assert limited to a debugging feature only? From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 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.php)) > 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 can 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=spike-organic-signature&_ts=yux2k) [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