Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127860 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 069881A00BC for ; Thu, 3 Jul 2025 14:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751553860; bh=9LgYRyrCBi1bJuHYdXlVJ70jEBUNmt1AGlGplyfkHf4=; h=References:In-Reply-To:From:Date:Subject:To:From; b=HVPyA2yake+SlR+VVkBby/Tg0VLlDFGVda4McbBInxPI4KyIotNkwjil/yCWmsQXy vCDx/CZUiZgcMWT+/e/WH33G7shYGUti5erJeo5dBc0w95eKC06xp7RtKuR3f7rbmU c1e4XCZ35LH+YNrjid3813xcmUKI+WtvTABRsfLufkJew5LZ1XjpV+nC9T6CmSbarA x/Qzb+qfugND+xHuQ3AydKwhPLPNoB0i3ZcCMqO65Tz78dHa2jX/Nigfth+5If9Duz wHIzPsKz3jPZIOunfsxgeBmEqHZGHbBMkomRZYVp2oRy21wV8pcirlincbpKRdS2XV eMma/V6MX69ew== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9AE991801EA for ; Thu, 3 Jul 2025 14:44:19 +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=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 ; Thu, 3 Jul 2025 14:44:19 +0000 (UTC) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-6facba680a1so71991736d6.3 for ; Thu, 03 Jul 2025 07:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751553971; x=1752158771; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Wtou3rLjJy2D1IhjINloNoRnnsAUBJWplhdEh3WFoig=; b=DD13FzeL22KOn/pmzaIrsPi/LzmFzw/K/BtC0UowaikcWXWggO4vzVqglQfnmhfoC0 nGbMM4IH4kSEnkkJdqH+LulswXIu8trvzvFNto8TvidhwrpkPIWNteX16ZqBUrKGG0eq wYySiRJAq2B4lPZR/CAMDGqVMnqcsFRu1QC71pFHnb6ISBvuP6eLnS4NW2y9600kYS5f 2/DPAx0j/LnDVmMGFvadbOKhtwE/PWcCj46Hpw0q6+lmgPJfnnY/R7SR52VC/fPGmKSl 5AHuJRrk3RsW4t56VOVBvBzPZKoIU0iBVRGQCJae2BDlOwdC6bb72ca36Aa1cQwNpT8U UMgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751553971; x=1752158771; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wtou3rLjJy2D1IhjINloNoRnnsAUBJWplhdEh3WFoig=; b=oSYVut9XcRLvRogP/cGfXQ2ic1bG/dHUCzoUGjAXRx2b1z47t3sm+V8hNccVQlf6TJ qoUYWs1tHxHXmkwyeetrC7AG4Co28OhgKH1XJRBh/aeIRoGeiRfarVzANCRlCvEhsDhV 3sTCrcSY90gSvsOIR61E4FA6yftgv4bnx+sSqYJ/rQGerHZ8ML+zW0be1BX0RkHGyzrw HyIach3nGR6aMHYDcD0bbZofW7sGMIcWLCBdohv9uiyez/hW0VE4V12JU15U6UG2TH+z NG79V2qyYnGiaVoLNC4KJAKRbnqapF6QxUpPMHcRoufyjQA4kXmO/ejsaa4WntGhc/14 ZhMQ== X-Gm-Message-State: AOJu0Yyc4Pq27IRaO2ybZGftCEhPg7dwdiPuL+RKkSKvmtt0RJrPPz2b 6mi8zatmmUi2H54t6g+oWkK3yt/9rqJcaMfjLP5Bb+l07eG3XsJtFRs7p1LxioJWcgTMmEITJqm qXa9PhIiCVHlnGAyPgFPKRGSNpOWhxog4QNWLFv86xg== X-Gm-Gg: ASbGncu4s5EAo5rJJIp9/KbjrrMzORY/+C8uJ2+vYvMjjG275Ilf9uBxGSYK5sQeF7p KVpNLCi/BMl3wbi1P2HdM6li2Q6IjDMMdLfCuyDpVfzgTvJnV2/btisoel08mDQHYenFrkTmQRm 2NuouyI8OmL+tnq54+bfT9vYLwHS1491FTisKhdHr1K1O7MSgy3wvf/MHZQpM+zEyARHo6DihyL H5omg== X-Google-Smtp-Source: AGHT+IG5LddjdCUhNy/vIfatwzkON5f0rdOfa6azc56QGFBg8FxxVTEg0hy0nfv8Cnt3g+fK6LOpLCHO/G0mxEHFiCA= X-Received: by 2002:ad4:5be4:0:b0:6fd:76c2:a2fd with SMTP id 6a1803df08f44-702b1a3e745mr103822896d6.4.1751553970578; Thu, 03 Jul 2025 07:46:10 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 3 Jul 2025 16:45:59 +0200 X-Gm-Features: Ac12FXx5ZuCGFQ-ptICU9ia6Amx5wwOx0hj_OW4ff0MS6onu04nzhntEFatYTkg Message-ID: Subject: Re: [PHP-DEV] [RFC] Deprecations for PHP 8.5 To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi everyone On Wed, Jul 2, 2025 at 9:58=E2=80=AFPM Gina P. Banyard = wrote: > > It is this time of year again where we proposed a list of deprecations to= add in PHP 8.5: > > https://wiki.php.net/rfc/deprecations_php_8_5 Thanks for the bulk RFC. Some thoughts. > Deprecate __construct() and __destruct() in interfaces While __construct() is tied to the new expression (at least unless instantiated through ReflectionClass::newInstanceWithoutConstructor()), factories creating instances from class names may still need to check for constructor compatibility. This is much easier achieved through an interface than it is through reflection. With an interface: interface I { public function __construct(string $a, string $b); } function some_factory(string $class) { if (!is_a($class, I::class)) { throw new InvalidArgumentException(); } return new $class('foo', 'bar'); } Without an interface: function some_factory(string $class) { $reflection =3D new ReflectionClass($class); $constructor =3D $reflection->getConstructor(); if (!$constructor || !$constructor->isPublic()) { throw new InvalidArgumentException(); } $params =3D $constructor->getParameters(); if (count($params) !=3D=3D 2 || $params[0]->getType()->getName() !=3D=3D 'string' || $params[1]->getType()->getName() !=3D=3D 'string') { throw new InvalidArgumentException(); } return $class('foo', ['bar']); } This implementation is much more complex, and incorrect in multiple ways. 1. We could have more than 2 params, with them being optional. 2. We could use variadics, i.e. function __construct(string ...$s), which is completely valid. 3. Since parameter types are contravariant, they may be substituted with union types, mixed, or just completely omitted. Also note that while LSP for __construct() is not enforced for class inheritance, it is for interfaces, even across multiple class hierarchy levels. Maybe there is some issue I'm missing. But if not, I'm not in favor of deprecating/dropping this feature. > Deprecate using values of type null and bool as array offsets and when ca= lling array_key_exists() The introduction section also lists float as a type to be deprecated in array offsets: > Deprecate using values of type null, bool, and float as array offsets and= when calling array_key_exists() Floats used as array offsets that lose precision already emit a warning. Can you confirm that floats used as array offsets that do not lose precision will not start emitting a deprecation? > Deprecate ReflectionClass::getConstant() for missing constants I don't have strong opinions on this change. However, ReflectionProperty::getDefaultValue() suffers from a very similar issue, except that it returns null rather than false (https://3v4l.org/G2R3l). It would make sense to avoid more inconsistencies. For example, ReflectionParameter::getDefaultValue() does throw if the parameter has no default value. > Deprecate ArrayObject and ArrayIterator with objects Just to add another issue to the list: It can also change readonly properties of internal classes that the engine does not expect to ever change. For example, Enum::$name and Enum::$value. This can break internal logic assumptions (e.g. hard-coded switch cases to handle internal enums by name) and cause memory corruption. The same goes for non-readonly properties guarded with the internal equivalent of __set(). > Deprecate passing spl_autoload_call() to spl_autoload_unregister() Is such a check actually useful? We can prevent spl_autoload_unregister(spl_autoload_call(...)), but we can't prevent spl_autoload_unregister(fn($c) =3D> spl_autoload_call($c)). It seems very unlikely for this to happen accidentally, and excluding all functions that don't make sense to pass is not feasible for obvious reasons. But I don't care too much. Ilija