Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114864 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55788 invoked from network); 14 Jun 2021 14:26:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Jun 2021 14:26:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A6B38180546 for ; Mon, 14 Jun 2021 07:42:54 -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-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 ; Mon, 14 Jun 2021 07:42:54 -0700 (PDT) Received: by mail-oi1-f181.google.com with SMTP id h9so14565845oih.4 for ; Mon, 14 Jun 2021 07:42:54 -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=OwVgfyQ9Joz+VXG3KYGXee7Fj9dgL35CCfZwKaD2QGo=; b=kGcfar1hcjBcwFQp+ikJhkUzr6luSnoPHSG3ED0GfXNBPhQfsPogpTdK47Kb8gbvWK rDgPObJAAQRwaYcemR0aZM9uYHk7sUoBLj2iASR4xHfmk+XBQAIRugif3LGbcnoZtcKJ 40OipWTI6gAhWNqle0Qiad6All8SSaU4+pA2FPtyxI7VkA2qYztt/ct4M5kI9VvmFLpn u/5L901rP54N+/bHuIEIOU8zhipbAt2Q1I4p68CzNv4CwI7efjIjkDRfO6oH+lC/oLuI Kcm1VSnI7MRHHIV8XGczSJ2U7Yb/SDgvTC0SmdNhRbPYNdWty/jMJAupkRiaRR9NqIct Zx1Q== 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=OwVgfyQ9Joz+VXG3KYGXee7Fj9dgL35CCfZwKaD2QGo=; b=puzw4mLsia9yBDuPHaMxOU69GAMBbyiaGPlxeFJRLNoNAQAc1yHqIaCJ34nKKZuPTo 2caHfl1ldA7mgvKAND9Qcp3751Wh3TSMYkn3nPRXyomHYK0A9aCoFptstdBZQHwF26a2 QjSW06ZxmNDa4lrvWYesPkQqdc/YmE152Xpe+bjUURVcO07POS+2EUwZ3CiG7uS69d4n 5ijAi9nsnxaw5c/RDPYzFX3nu5SNYGlGSOtYz5CduUvQU/IYnxSZ7AJgW4AcGRzclcJP nA+QulpOjM+JOFQn+4GSxdGzUCP4tONzrqAr6/Pako72Wlt081GG4Qh8NTHP696Sg490 Jqjg== X-Gm-Message-State: AOAM532P5KiQIuK1jfJvOXZMCcd6gJSxM36/1Kl8dniN40NHYXrlDaAl nlvkAr9R/BzM0YhEYa4u20JtsXKckFTETyrBkXI= X-Google-Smtp-Source: ABdhPJxECkuFaz4Yfv1SgFXQ9tKY6WkxBVGSeokKV9Ka3cACI7HqnxgMr59ivnXPnY6L5IFLPbTriWmU1FY4cKmbHhs= X-Received: by 2002:aca:4143:: with SMTP id o64mr10488982oia.105.1623681772689; Mon, 14 Jun 2021 07:42:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 14 Jun 2021 16:42:40 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000004a1d6105c4badfb4" Subject: Re: [PHP-DEV] Allow objects in define() From: ocramius@gmail.com (Marco Pivetta) --0000000000004a1d6105c4badfb4 Content-Type: text/plain; charset="UTF-8" Hey NikiC, On Mon, Jun 14, 2021, 16:35 Nikita Popov wrote: > Hi internals, > > With the introduction of enums, it's now possible for constants to hold > objects. However, this works only when using the `const X = Y` syntax, not > when using `define('X', Y)`, which still excludes objects. > > I've submitted https://github.com/php/php-src/pull/7149 to relax the > restriction. This means that define() would accept everything apart from > recursive arrays. > > An alternative here would be to allow define() to only accept enum objects > in particular, but not other objects. I would prefer not to do that, as > such a restriction would be rather arbitrary, now that the technical work > to support objects has been done. (PS: Please keep the difference between > mutability and interior mutability in mind.) > I rarely encounter any code using `define()` for anything more than extremely minimal environment details these days, and even then, it usually leads to loading an immutable `Environment` object that is then passed through dependency injection (container or not) to runtime services. What are the possible use-cases for this, besides enumeration types? > --0000000000004a1d6105c4badfb4--