Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Join::join() raises TypeError instead of InvalidArgumentException for an invalid name without a leading string

未关闭
#206 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@simon-mundy 已经在做这个了。

开始于 2026年10月5日。

  • #223 来自 @simon-mundy —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
php, sql
领域
databases

调研方向

Read the validation in src/Sql/Join.php around the referenced line and the forInvalidJoinName() signature in src/Sql/Exception/InvalidArgumentException.php. Check the reported inputs: the call should raise InvalidArgumentException rather than TypeError, and for a non-string element the message should name its type. A linked pull request is already open, so check its status before starting.

由索引模型根据 Issue 内容生成。

描述

bug
Package Version

0.6.x-dev @ e022af5c

Php Version

8.3, 8.4, 8.5

Database Engine

Any

Basic Information

Join::join() rejects a name array that is not a single-element associative array, and passes the array's first element into the message (Join.php#L97):

throw Exception\InvalidArgumentException::forInvalidJoinName(array_shift($name));

forInvalidJoinName() takes a string (InvalidArgumentException.php#L134). When the first element is not a string (an empty array, an unaliased Select, an integer), building the exception raises a TypeError first.

This came in with #192, which replaced sprintf(...) (which accepted any type) with the typed named constructor. #192 notes that the same unsoundness was re-attributed to forInvalidJoinName in the analyzer baseline.

Steps to Reproduce
  1. (new Join())->join([], 'a = b')
  2. (new Join())->join([new Select('foo')], 'a = b')
  3. (new Join())->join([5], 'a = b')
Expected Behavior

PhpDb\Sql\Exception\InvalidArgumentException. Where the element is not a string, the message names its type, e.g. join() expects 'int' as a single element associative array.

Actual behavior?
TypeError: PhpDb\Sql\Exception\InvalidArgumentException::forInvalidJoinName(): Argument #1 ($name) must be of type string, null given, called in src/Sql/Join.php on line 115
主要语言
PHP
星标
18
派生
8
平均合并
6 天 11 小时
30 天内合并 PR
14

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

php-db/phpdb 的其他 Issue

查看 php-db/phpdb 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。