Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127544 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 DECB41A00BC for ; Mon, 2 Jun 2025 23:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748907856; bh=H/ngvNj59J8BRCXn//qfOY0/oHwIF7/bmE7AjJU7c/4=; h=References:In-Reply-To:From:Date:Subject:To:From; b=YZ++3v/4g7YLiv7jLpJJAqgMt88rbTICHSA7mKlN5+yxQqKNndb1XBDu7XL+ByY3D 2bVM/lZkGSjnHPMP3yWKS+PJ2mWDJd9G4s6AzzmcHNc7ZIm8WSt9eQe3H+inYLvduJ ekGxNBsHnEvonbzhwhGTj2fevCbtYr2k4fCupjzstKqnN2CDldZ9zY2l6og6bGs1JN S7hMvHUh2nOd6jaVJtzZhJPbdoAm5PKm4JErJ5dm66L3jt51gKKKYb4g3S+/rLvi6F jcTLj80xuh3bLR8ZwwjFTGrBIwGLxVflcB1LswttOV7o/QLxf5OJIDlq+UCWr5Omxt EmKRq/CTVwqeA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 708E1180081 for ; Mon, 2 Jun 2025 23:44:15 +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.4 required=5.0 tests=BAYES_50,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-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 ; Mon, 2 Jun 2025 23:44:15 +0000 (UTC) Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6fad79433bbso29454946d6.0 for ; Mon, 02 Jun 2025 16:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748907978; x=1749512778; 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=xLtydCuEils9qbPn8NI8rRZlEqt7YqK3UsGVxno6DT4=; b=kvrnlxPsrXk84+rOs/5bf7QRQBB40e7teiSuS5xwFVExWYCnpXAFtyYkJtx+1vNnC7 lC5TTCYccDvrpK81oBGtS6nfiXcpCzB9tjTp9igQ65LhnPJATh1Ur56bfvZsRvcnJqbV 5lFY8WTd9sr/9a1Pyd5jb/TD2QSxCv1iK69FqHuBdkQajwgRbK3tKD1oolobEhuaeRkh vHvjt4p1p47aT3LspAz3Ltm8mBA6TT4PGIWieLXlsCoV0V0gi0wEmaQAHZQy+Fc/9eFt qXTz3Pe+uWPJoQjh2MRaVH3inv+HrduG50V6uuacPGKpK/2YrDvmSoUgaEEKIrKO26Lp a+wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748907978; x=1749512778; 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=xLtydCuEils9qbPn8NI8rRZlEqt7YqK3UsGVxno6DT4=; b=qFP2ILAGcDQe++qykaaYOxO4rTS3tvR7DasEoeCpLR25weUOZO2J38t/hFLy1QolST CrVxQTL5T3s5tJJL82ByANZ2JtilI+rJr5ua4inNToyziOWKHJ4ICeqfRYH22vsRPl8d gUnnm1ubxGsOGcp7NcWuWtko8QrcF3c23yTcKJs1ajf5P6R9FH+IrJAGO6YIjnyFwsM+ TBj3lNEi6JZN3L3Kq1kfqTF3IU/DS1GhcRFtFtVEGberFaRLlLRPA4BKk45Qe/R3C3KC CiGM9k/4Q47oaBSCTyXHvJwbP59XzgnbvhE6soTw5X34cVNJRkRsATG3Eq9l25B7y7tA AEbw== X-Gm-Message-State: AOJu0Yykk/XbeNcv1/99voxseBrP+Q5ybmMkoz5ZLHrSdn3G6zZp1wlI 1XkFbY25N9AoZN+WRsLFYKgzrBhuPQj53cbhJt0zeMcbpCBoW4okUbGXn3jdVn1FKXm+oZEmnX1 G5IHYalwPIRA4uZQFzZpfThxkmcVFsQzmEiW4IpAGMQ== X-Gm-Gg: ASbGnctOAzVCYmuH5iADMKUc4lDzmHK43IztvyqPOiD995jlhQQQhkYmSVZacXDml1r MHqssdEGzBsJ8FDPgjwhSKBIq6MKEL7ymI3lGbeO4OyIC3PAxaVMeof9QXgwgJkggBNSW7jh1Vg oUUb/jgHLkdZ7CbIZTc0DAi5d9C6M7VC45gm5p/k/pnUCyHkrBJ77z6nupr53pspOB2o+mRR75t MJCWA== X-Google-Smtp-Source: AGHT+IHHCGX8vT8j4D4HBd97QYO36sKNyIfyOuRfPL0+/TAFUYZ0XeJJ9b64w410qyN5zalAixtzky9OTyctzujAHB4= X-Received: by 2002:ad4:5c48:0:b0:6f9:2c6d:8568 with SMTP id 6a1803df08f44-6fad91623damr152435136d6.40.1748907978548; Mon, 02 Jun 2025 16:46:18 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <6Z2Ysh6MjYp1nyzuB0bTPJc5srObIcMRqt731JaQeXUJk1f_V_Yo2nRn8WvjI7er7pp7pIUE6WYl5pRwvYrtcrd07nCutyAqKPSsZHmrS-Y=@gpb.moe> In-Reply-To: <6Z2Ysh6MjYp1nyzuB0bTPJc5srObIcMRqt731JaQeXUJk1f_V_Yo2nRn8WvjI7er7pp7pIUE6WYl5pRwvYrtcrd07nCutyAqKPSsZHmrS-Y=@gpb.moe> Date: Tue, 3 Jun 2025 01:46:07 +0200 X-Gm-Features: AX0GCFsht6c7kSTRI22_gnjt4vXuH_ppO-SxCVcMkLDVvbiXMeibpRgjMba5Ze0 Message-ID: Subject: Re: [PHP-DEV] [RFC] Transform void into an alias for null To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Gina On Mon, Jun 2, 2025 at 6:28=E2=80=AFPM Gina P. Banyard = wrote: > > RFC: https://wiki.php.net/rfc/void-as-null After a read, I think I fundamentally disagree with the proposal. It says (regarding the status-quo): > * void is not a subtype of a function with a mixed return type This is laid out as a downside, but I don't think it is. Consider this example under the specified behavior: interface MapInterface { public function set(string $key, mixed $value): void; } class Map implements MapInterface { public function set(string $key, mixed $value): void { // Store the key/value pair _somehow_ } } Let's assume the return type `MapInterface::set()` `mixed` instead, where the intention is for `set()` to return the previous value, or `null` if there was none. This change will go completely unnoticed by `Map::set()`, because `void` is now just `null`, which is a subtype of `mixed`. This is a bug that would previously have been caught, notifying you that you're supposed to return _something_. Similarly, the code `function foo(): void { return null; }` is now proposed to be valid, and I assume the inverse for `void`/`return;` is also true. In this example, we now update `Map::set()` to the new return type. class Map implements MapInterface { public function set(string $key, mixed $value): mixed { $oldValue =3D /* Fetch old value _somehow_ */; // Store the key/value pair _somehow_ if (!$this->observers) { return; // This line was here before. } $this->observers->notify($key, $oldValue, $value); return $oldValue; } } Good examples are hard, but imagine `Map::set()` would allow notifying a list of observers about changes to the map. Previously, the `return;` would have prevented an erroneous call to `notify()` on `null`. However, now it is missing the returning of `$oldValue`. This is another bug that would previously have been caught. In fact, even a missing trailing `return $something;` would not be caught anymore. IMO, these checks are useful enough not to be removed. Please let me know if I'm missing anything. Ilija