Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126054 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 qa.php.net (Postfix) with ESMTPS id 1982A1A00BD for ; Tue, 26 Nov 2024 11:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732618648; bh=v9qoXiuKT+B/yS5SBo2C4IaI/JNzH5X3yTeKkO1VZNU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=J8BxVVmrNdFbQj9oFQvk43g5H4Y8i5WVQ5+kjuMwuojCFvs21qIzumZiglrvU2+MT i7F+iFjz8BXoo7LcMSzckxivSO1zAq82U084CbH+Y6FReh4A85A5Vc5TxuGK+QHrxU xWevN6Ap9+wIJBhXG9A7Qq6RSxKsioga2OwfJIOELFYeVD5h2eTgm+tVzfabdRG/jt 6EeF+hyLekd5I1TkZeVV4VGlUm/gxK922YBgkLw9CCckxMjzW3zpWS7lkE6haoEZS3 BWVjCFreoPnxejBWGdH2n8Pmkgx1GugDohYS1goY4CMC6vjWREs4aJ2Au1JQDTvAbB X+awxZYyqBERw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6BF4F180071 for ; Tue, 26 Nov 2024 10:57:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,URIBL_SBL_A autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 ; Tue, 26 Nov 2024 10:57:26 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-21263dbbbc4so58512995ad.1 for ; Tue, 26 Nov 2024 03:00:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732618837; x=1733223637; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=v9qoXiuKT+B/yS5SBo2C4IaI/JNzH5X3yTeKkO1VZNU=; b=jsPmWliJiINazI4F7DT7EVltxf5/h8tDojvK0GX4+u6Qx9f9UGP0zptcSqrqt0GFVB NkJhW4gUiq9Hw4un1LYIAPxxtwiDDToW6HtWSTxU5wR2StqohGkQD9P1VUfPfNnGYktE bkULdBQd5ONObFXp/xQcWjKCWya5lOjRMsz7gImffDM3mlyV3HqF+yRwT5zr+Quo+vkR F5tH4n/Y35cEhyvMQFfL/uOwcxzGqQqo8BFxSQQXzaZaBIZ2nvpD1pONHPJ9xZ/wEcW0 HBDMlAy+ai4XIxlwEh/tjL6t8lRZ+k2FnT8iD2ILwKFZj2fIxf10B6W//NjmG5vqYofc I3eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732618837; x=1733223637; h=cc: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=v9qoXiuKT+B/yS5SBo2C4IaI/JNzH5X3yTeKkO1VZNU=; b=MTVfyjBUobykFjTEXi8tTHx+Fu2zhDdmJKhTWzzQAxrfC78AHg4pzzZiCxzJdVJ450 6O4YcDZJx6098F/qTTOA+AO+4TQEcQHmHLxsqwoWlwLjANW1N+hrCfSc1qLitK0GTyBw Rtt5zjWM0qtO+O1aOvyNLE7ltxAEU36y8B7yE6CWMIeIvm2gVVDT3voAULB//GcN9czp A7d7p8bUQNAeRcP3ahPu3P2YGcLAD46p5+98UtA7l6fdiXzG5DYL+diwRDt+pDsIYHXw 7hF89KpB2xR3r5cMolQtwOraGP2rXHGj2tvQ+9bPi6/n99HJ42b1ngnI0cCiyohmlLA5 ZnbA== X-Forwarded-Encrypted: i=1; AJvYcCV2iWLQveFU4C6Og0KhNVqaA2g+ihSMOSqNSCk02GpIETqfo45QKEpFxh5OYdA4ERxOueKM+yuk8yQ=@lists.php.net X-Gm-Message-State: AOJu0YzYdYYJCQsC+A0cnglXKuiWb40weOI9Ifdv+PPLqeVPmG+g8M// 6wmww/F9l9XgsMfQcJwp2ief2K7TxGIHWyjjtByo1mEpJ/g5D5gstMaz7oniwajxEfEvmlOyF3+ UaKBbxPCK6dSlgEm9F3yRiqlE6iU= X-Gm-Gg: ASbGncs/uDHtUd4V0RVTKwpGXVuR99F+WryJD4nH7kjv0Rln8CXWXKs05zZRIPZp3QQ 6AKpVGYRBFUHI8JAzHdUtxbPu9WtoWZsS X-Google-Smtp-Source: AGHT+IFRkP0uMYVib3Z36jdr44omc7BCj1I8zFidQ2SHxTw8SYDgQgCGaKgD/G1tAZt7GkeBNT60m+aFNSZ+djPQaxo= X-Received: by 2002:a17:902:cf01:b0:207:6ef:d983 with SMTP id d9443c01a7336-2129fd5c1bfmr235958635ad.39.1732618836179; Tue, 26 Nov 2024 03:00:36 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <8899a91a13c1e25a186f98661348e9c5@bastelstu.be> In-Reply-To: <8899a91a13c1e25a186f98661348e9c5@bastelstu.be> Date: Tue, 26 Nov 2024 12:00:24 +0100 Message-ID: Subject: Re: [PHP-DEV] iterator_count signature for iterables To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Eugene Sidelnyk , PHP Internals Content-Type: multipart/alternative; boundary="0000000000004308480627cec2d8" From: ocramius@gmail.com (Marco Pivetta) --0000000000004308480627cec2d8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Tim, On Tue, 26 Nov 2024 at 10:50, Tim D=C3=BCsterhus wrote: > Hi > > Am 2024-11-26 10:40, schrieb Eugene Sidelnyk: > > I think it would make sense to change the signature of iterator_count > > to > > accept iterable rather than array|Traversable so that static analysis > > tools > > would pick it up better > > That sounds like a bug in Psalm's understanding of union types. PHPStan > handles it just fine: > https://phpstan.org/r/8604ef1d-3500-4695-8c23-bb5d30ce4268 > Is `Traversable|array` an alias of `iterable`? Is it **always** like that? Marco Pivetta https://mastodon.social/@ocramius https://ocramius.github.io/ --0000000000004308480627cec2d8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey Tim,

On Tue, 26 Nov 2024 = at 10:50, Tim D=C3=BCsterhus <tim@ba= stelstu.be> wrote:
Hi

Am 2024-11-26 10:40, schrieb Eugene Sidelnyk:
> I think it would make sense to change the signature of iterator_count =
> to
> accept iterable rather than array|Traversable so that static analysis =
> tools
> would pick it up better

That sounds like a bug in Psalm's understanding of union types. PHPStan=
handles it just fine:
https://phpstan.org/r/8604ef1d-3500-4695-= 8c23-bb5d30ce4268

Is `Traversable|a= rray` an alias of `iterable`? Is it **always** like that?
--0000000000004308480627cec2d8--