Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129783 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 7D64F1A00BC for ; Sun, 18 Jan 2026 17:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1768758959; bh=L8ZiIxNnCbJgx31klwPv7J/jvgrtlON12MUCwSw3Kmo=; h=Date:To:From:Subject:From; b=Kfm3i+q7+vj34Jh//6TS8dvJEeLaEUqUg0iPnOYiIJn7FKz0daVdOeFq99yBLNzdE OuHxkWDpWhBpFIdyhJ6s+jMCRrDeF9j/IlabFrQBVFqKf+DXRoqcogvB2aqJxYwWL6 YSSqeVjSZ9qub/GwBjf+lM8kO76tuK+KLd/J/9KNO384jDdir0V+3f5r2PjqGxaWa+ 10VqYl1xo2ovPrOX6nKVpQU+cXuTXhyXjsv1uf8A69PFLTPj9Drm6QE3FLrKYNwWiO 8AWQL/cBlasXLqM5JnjihlbELg2VwgzqJy3seNVxoxqFEP81UHHL6YSmOkSs0vCGQL 364eud8xete4g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 06DC1180074 for ; Sun, 18 Jan 2026 17:55:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_20,DKIM_INVALID, DKIM_SIGNED,DMARC_QUAR,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 18 Jan 2026 17:55:52 +0000 (UTC) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4dvLq432dxz9tgP for ; Sun, 18 Jan 2026 18:55:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mabe.berlin; s=MBO0001; t=1768758944; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2cR+mJQ7cYYmz66Co4gywrPfv6oz2xM3DzfmDjyVdnM=; b=yrAx3gQgSAnU4KJtYYqupCuYzlBrDcK59kXWkgXSFqcW8SvQ21EhAhemmZ1jo9b/ZNVa+u ZofjEkhMSVJaP+IM8LFPbi6f6XLWNE4wHOjDVlfogOlPRaWrguWgIwxKGnKbdJKex2kAby qYo3A+yq1nYGnAwqObj+OhHN28O7jSLT1K40xtKF6wraVjmDRNlVXOylJgKm8Qi51kjtpJ GDXv28BEq4529kREhvuOtpFKdRZIBIqqqHhnbKJJ2uImv2S1idzJ68Pm2nqoOE8NH5yJmH 6lj1WcZC6BojeQt04OeTV2+W+N3pXQlsAOG/OQtUvDOCUXbQ6chTAesXG0z3Mw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of marc@mabe.berlin designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=marc@mabe.berlin Message-ID: <1d5a3698-2796-4bc1-ac34-79b8dbc03e48@mabe.berlin> Date: Sun, 18 Jan 2026 18:55:43 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 To: PHP internals Content-Language: en-US Subject: [PHP-DEV] Object support in class constants Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4dvLq432dxz9tgP From: marc@mabe.berlin ("Marc B.") Hi all, Somehow I missed that objects can be used in constants `const OBJ = new stdClass();` since PHP 8.1. As this is allowed for constants, I don't understand why this is not allowed for class constants.     class Test {         public const OBJ = new stdClass(); // Fatal error: New expressions are not supported in this context     } While this works:     const OBJ = new stdClass();     class Test {         public const OBJ = OBJ; // works     } Is there are a reason for this limitation especially since "new" expression is valid for argument default values as well? Thanks, Marc