Type-stubs for `pg_fetch_all` are incorrect
还没有人认领这个 Issue。
评估
调研方向
从 stubs/ext/pgsql/pg_fetch_all.php 开始,将其返回注解与 php-src 中 ext/pgsql/pgsql.c#L2181 处链接的 pg_fetch_all 实现进行比较。确认结果是否始终为列表,判断 stub 格式是否支持依赖 mode 的细化,并更新注解,使其与已确认的行为一致。
由索引模型根据 Issue 内容生成。
描述
The current type-stubs for pg_fetch_all are as follows:
/**
* @return array<int, array>
* @refcount 1
*/
#[\Since('8.1')]
function pg_fetch_all(\PgSql\Result $result, int $mode = PGSQL_ASSOC): array
{
}
But as far as I can tell, pg_fetch_all actually returns list<array>. I've tried to verify this by looking through the pg_fetch_all source, and I'm quite sure it will always return a list, but it's a bit too dense for me to be certain.
I've also run the following assert on our codebase, and at least for all our queries, it true:
$data = pg_fetch_all($result);
assert(array_is_list($data));
Side-note: this is much less important, but would it in theory be possible to do something like the following, to further restrict the type?
/**
* @return ($mode is PGSQL_NUM
* ? list<list<string|null>>
* : ($mode is PGSQL_ASSOC
* ? list<array<string, ?null>>
* : list<array<array-key, ?string>>
* )
* )
*/
- 主要语言
- PHP
- 星标
- 31
- 派生
- 12
- 平均合并
- 1 天 10 小时
- 30 天内合并 PR
- 4
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
phpstan/php-8-stubs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
phpstan/php-8-stubs#167 ·
-
难度 4/5 3-5 天 新手友好度 25/100
phpstan/php-8-stubs#23 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
phpstan/php-8-stubs#1 · 4 条评论 ·
查看 phpstan/php-8-stubs 的全部 Issue
相似的 Issue
-
bug needs grooming
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
phpstan/phpstan-phpunit#361 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
HE-Arc/le-panier-du-coin#49 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 2 天内回复
-
15.0
难度 2/5 1-3 小时 新手友好度 65/100