Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121638 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22242 invoked from network); 10 Nov 2023 12:07:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Nov 2023 12:07:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0D1AF180211 for ; Fri, 10 Nov 2023 04:07:48 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15576 212.103.64.0/19 X-Spam-Virus: No X-Envelope-From: Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 10 Nov 2023 04:07:47 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 6E1B0302338F for ; Fri, 10 Nov 2023 13:07:45 +0100 (CET) Authentication-Results: ext-mx-out013.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :mime-version:date:date:message-id:received:received:received; s=dkim20160331; t=1699618062; x=1701432463; bh=7fNROmW51TlWeMtf l+CaQ8oi0Fod17ygD7SnMrOvJ4w=; b=xRN2s3SL0cEdF2UlvR8BSLTwY5JpC8Qv 7RH1Hu7ZMcoe9Lp0wfd2cDD4cUgf6kcA30wGpf12pzDAcQsCr083mQa7nFsA++YQ 6pgWXZ0dqjo2Y6eOYeq3M9DTT3ZnIZCeTmbFu297J8XB1l3pRAsE7IjYx5DKwCvk /gOn+17lxkKQyfmjSZfELWdkJ64omWXlJFKiemy4dz1bw1MoD2y97KB3ctaaKlGH YwyS6UL0Sw/3iF424vr8Vplr1WzYgOozYLNlKi1OMsPQW9IwaeGJt+EHmOOvXjKC hVQzD2rbxf/MC3tVMK7IjSa9jL/PJHZYW5oefYYnga28tzTAAfAI/mhFfpPPYbaX i7FAPVttvX/c08udGKOJspgyGoYFlO6W+GDW4tnMSEPKjRKW8qBFVhFdoq5eC/tA imDWXSheKzFSjUAFapRCXevav0F4Qp1fSNVA9+TP/sIqyMoTHjIyiJnAA7cEJ8H9 G+jVW8pfFiNktSGgn7A9pID+WokrOTiftmIzJvHiA6F6vzhZqUELooNkP5mKpIO1 P4dILR2wKH0gRbD9XvCMKTCkWPmf8UXucLWIwTziklMHBnFSISzvc7Kui+z8zZNh KlWxjcNPb1OSCzebFekZ8MmSrI9k+Uy06EFmWWAFgNK/67rFcfE6izMuvQf9tZKX 4KJxl+yTbmk= X-Virus-Scanned: amavis at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id zhipBiN7PTkO for ; Fri, 10 Nov 2023 13:07:42 +0100 (CET) Received: from int-mx011.mykolab.com (unknown [10.9.13.11]) by mx.kolabnow.com (Postfix) with ESMTPS id 59BE6302338B for ; Fri, 10 Nov 2023 13:07:41 +0100 (CET) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx011.mykolab.com (Postfix) with ESMTPS id B87DF30DA2C9 for ; Fri, 10 Nov 2023 13:07:41 +0100 (CET) Message-ID: Date: Fri, 10 Nov 2023 13:07:40 +0100 MIME-Version: 1.0 To: internals@lists.php.net References: <5144806E-E21F-4AF8-B9A2-0161561A6B9E@craigfrancis.co.uk> <1A044D32-019A-4152-A3C0-3F393974AC3B@craigfrancis.co.uk> Content-Language: en-US Autocrypt: addr=alec@alec.pl; keydata= xsBNBEy9TtkBCAC4ef0IJaqTDQNQZ5CPrHvNs5kcACvtffwydrTcRJ28dHwjZD8daSxfVYEo acyARevTOvsp36Vgq8Yt7ATu6y7MPBaPj9Lq0kwX7HM8QDn8jTfufAgMjxcw5bD+JNR5+8G9 hUF3F35gVuAd471hS+QB/Ug/PezcNx9H5yFUMuvrO3ybyIDhw5qJI2RoJMjMr5DPKUG7z810 1e/NW7y9FfHq+Ony7A70w+vcfv1L+LLX5gfrpKI3m0zKm7cj1vyxZfC9RijIzWZN3GgExexI KJdbkcg9F/zigKo72TJhgvjy6YZP03HmWZVcpsd3aIT3Tweg0cCivaKVBNcFR1oda6XvABEB AAHNFkEuTC5FLkMgPGFsZWNAYWxlYy5wbD7CwHsEEwECACUCGyMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheABQJMvVAwAhkBAAoJEL7mdKAZNZ3BEhkH/1eAuCOSXsWg8YwZzmABoKKZfNpJ Z3QTwAMxXyCPjJMwLMLHsrVO+VbGupFcIW/q/3bvt1r8LwPB73rg0TFiHoYzeQzdnOVYFW7w OYz9BDVjLE4goDk6xN5Nj1CpBMXzQFdr3HVKyuRK1CLd9p13CofiBlLsQ4JqtosnlvSCEjTL yIajACU3kY2je1e58N5VHzZ+VMeg2xbuQJ3q1iTkYggZ+xRC1muw4Xgt2vxgfWjn7u3dmjYM T3H2WFprLZwliejHgzhWdYABdyCU5VuGCLOV+xk2UCADya0hvVVIezA/4YG3w01yjsljRrKy HFJUqw+MqagA6dsfflZSvmROKMbOwE0ETL1O2QEIANHbid+rMQ/IX0/UyVtnLWunDEg6Yl2B twHTecZ4Ym3tBxc1sbPDoYpY0DZ86gYi9DCbolrdjnrRK9ldYItVJ8rJUkEIDz/2yhjcr3s3 p2SyI94bocoG0WW+VRlssJMxTB2ihblihkY5HqT+9PgOFxnpSqz1ksTaI3JOVcokidhoB7MJ muyb28rNtZCJP7upRUwBSoZfHiL83w3Ad1Fn49QVO7kshH11lNyJ9jB17BTl1I0sj7RPqAor JcMxsSOJXW71ZcipXWym+GacY/qziQw7bT9CQYSmr4SiRV7GahD91enDkdv+pUAnb8NEifQ1 LT26XcL6Ng9EbG5AT4qI46kAEQEAAcLAXwQYAQIACQUCTL1O2QIbDAAKCRC+5nSgGTWdwe2T CACaux3lHitD8IIO5fy6RxPqym6vMlKiN0IyilahtJ0A2htNqwbFb6TukpzKw04DGSPEOGPa o4hdsLtQtqAPwqrR+FGJDc6V/jD0rPjThC3NcvkJuoi622ZLCsi8TAL5kBmF2NYd7ejszB31 5EzvpXSeES8+9pv6yshzUborEg9QKhPxW0yvrdj2OwFUlRr6/jLpKmMLzSx5F0yEg10urvfe 9Sttk5TVzHycOa1nKSzj79F1jXTl/mji/i082s1nlwb8d6LNVrm0e1tGMxSk/WpghFVVSm4O MvUvMkEEDkwGsm+mPcmX4UPcvq/wU3hGhDeVlpkfVTJQGvDbEUzTXbz6 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Passing null to parameter From: alec@alec.pl (Aleksander Machniak) On 10.11.2023 12:11, Kamil Tekiela wrote: > function abc(string|int $p) {} > abc(null); > > What should null be converted into and why? If you as a developer know then > you can cast the argument to an appropriate type but on the language level, > it's not really possible. > > So, in conclusion, we are not supporting you because we are stubborn or > that we want to force strict types, but because resolving this problem in a > way you want is extremely difficult and borderline impossible. Then throw an error when it is not possible, but in most cases it will be, I assume. Why strtoupper(0) works but strtoupper(null) throws a warning? The argument is defined as string, so the former should be a warning too, if we were to be consistent. It's a rethorical question, I know arguments of both sides. As OP, I think that this behavior should be controlled by strict types. I.e. in strict_types=1 throw an error, in strict_types=0 use null coercion if possible (w/o warnings). Of course, the inconsistency/confusion can be fixed in different ways, but what's proposed here is best for BC reasons, imo. Other options would make the language more strict. That being said, I'm also aware that currently, most likely, none of such proposals would get 2/3 of votes. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.com