Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126051 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 E666D1A00BD for ; Tue, 26 Nov 2024 09:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732613846; bh=JuCq/txUIwyp2W27VZhrrUbBmKD6Oaw4ZJo8BkSReWI=; h=From:Date:Subject:To:From; b=UBSNarrHUz5X7GpNcs1v78UnoM2/GNP2J3rp38frL3X+NswUIfWr1s+mHplhHdeR0 3QT6gLpXKVy/Ldyh+W+m0SoQ8KCWqW+IvhyuVNFHbd+Rh5eqW5tE+PoRUjnYVPfE9O /ysbMRI9YUk/zOY3w+rC/d2zGiJf2jjZ8WMJ2/LRsMCpviREmSfTvYUICEKdaRfi5L 0vu/XwFmU10pP9CXKT6y4avNomY3VDDDciK+mtgxHgxJS0iLxSozXdmJhfiOGS6mGa Ff19LUJ+MiPM12qhveYGtIX9SKnd+rfFEnk7PZFxiXTWvNQu+s/IhAn/BQVTvwFoxu kaUU/TtXiB9mg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9A4D180047 for ; Tue, 26 Nov 2024 09:37:24 +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.6 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 autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 09:37:24 +0000 (UTC) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6ee994218d9so48253137b3.0 for ; Tue, 26 Nov 2024 01:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732614034; x=1733218834; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=cfTcnwaK5Chj6MJdLfg80cCDLsJmXJG9tUf0et7edZE=; b=kCmyAPDCnzomDWWcoLzwHTCU+6ty/FmLvjb0Oybr9RGYAGFD3R1vpty3dIqzTfIhJP ZcP9YCg1kqWMKnXygIgkKBQXR5cdgBetF9FH/nKoDCL58Ujo/ByOhi521Qyd+0kA2o4p gj+OLB76GpH5Ft18TPTFNwt0k1UIFXlaLSOcyCeU3wvtW63gB/1ImQkFKMaOs66KNs3R hKCxUMOy8AQVD98LWIIQOB7GREfOffVgO62HN0kid9+VmXVvp3cucUUtA9f/d6EKg2d+ +eDCKotw518H1xePv+6eujKPNk5iBR9VQGCQHcF1NqkDu2voA2jtPKQIGwjrthx56/ZX HNGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732614034; x=1733218834; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cfTcnwaK5Chj6MJdLfg80cCDLsJmXJG9tUf0et7edZE=; b=RxtSlNbnXkNq4IgDXATWQxw4ZXjOo9F169MvwH0bMyOeMeEeOMbJkt6x65zUneXoJI SN6448/nCaYMvENd8xgISEWOQ4DrxEhe2Hf3vW9j21m4yMDkgBzzzq1hMkTtA+iky9t8 Jd7dWHlV+vnYoB9W/0Jy/Op7h71XDWrQCI2VrX4aEIFqcqZwimAbv8P2dzyYoxF/3YEu LjlBKq/65wteiqpUro8RVGtyb6CDeMbODxp0DXHgAZxow/NUfaJ44OxIZ3hY5FkYMdKc 2h3Bs3dkDC/3FCH6e8/C+ycMRvKCEeY1bOHvVSWnU1hj7oRR7vBMkCpqfllT+fQvgQjx 1NFQ== X-Gm-Message-State: AOJu0Yw7gP+0tidJnKbshKHQULPyj/BnEPkL/392tuSBRV5Nh87wRec1 BCylGs7vgbKWQwOmFs2w5iVux62r9+UwqF0DPb/VrXfr0IIY/8fC7jB5mJMFtB795y5sKj+5fqX ZBpmFP4S+S5lKpnypgMD2b4decz4tnJUY X-Gm-Gg: ASbGnct1yFHWKIH/YJV+9LQo5ge5pNfr+k7xPqPmEwzavOH3GBY5UWGsA0CKxzrFvI/ wU4Tm0rk6s/8yfxFDvgF27aXRprB70wo85w== X-Google-Smtp-Source: AGHT+IHny1sEVYHZpfsWaj56o+iHPxufSHM+dOKDIrgKohVw9Kk9HRhcXNw4+Ir1f+1Wv9xCSmknUnRBH/4yiRsIppk= X-Received: by 2002:a05:690c:c18:b0:6db:de99:28ae with SMTP id 00721157ae682-6eee08d1e7bmr136453557b3.17.1732614033852; Tue, 26 Nov 2024 01:40:33 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 26 Nov 2024 11:40:23 +0200 Message-ID: Subject: [PHP-DEV] iterator_count signature for iterables To: PHP Internals Content-Type: multipart/alternative; boundary="00000000000005536b0627cda45c" From: zsidelnik@gmail.com (Eugene Sidelnyk) --00000000000005536b0627cda45c Content-Type: text/plain; charset="UTF-8" Hello internals! Currently, iterator_count has the following signature: iterator_count(Traversable|array $iterator): int If we try to use iterable type and pass it to iterator_count function, we'd get following static analysis error: Argument 1 of iterator_count expects Traversable|array, but iterable> provided (see https://psalm.dev/004) $start(iterator_count($chunks)); From what I know, iterable is just built-in compile time type alias for array|Traversable (https://www.php.net/manual/en/language.types.iterable.php) 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 --00000000000005536b0627cda45c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello internals!

Currently,= =C2=A0iterator_count has the following signature:

= =C2=A0iterator_count(Traversable|array $iterator): int

=
If we try to use iterable type and pass it to iterator_count function,= we'd get following static analysis error:

=C2= =A0Argument 1 of iterator_count expects Traversable|array<array-key, mix= ed>, but iterable<int, list<string>> provided (see https://psalm.dev/004)
$start(iterator_co= unt($chunks));

From what I know, iterable is just = built-in compile time type alias for =20 array|Traversable (https://www.php.net/ma= nual/en/language.types.iterable.php)

I think i= t would make sense to change the signature of iterator_count to accept iter= able rather than array|Traversable so that static analysis tools would pick= it up better


--00000000000005536b0627cda45c--