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

[RFC]: Require a PlatformInterface in the DDL process* methods

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
databases

调研方向

从 src/Sql/Ddl 中 CreateTable、AlterTable 和 DropTable 的 process* 方法开始,并阅读 AbstractSql::buildSqlString() 与 getSqlString() 以确认平台始终为 non-null。将每个签名从 ?PlatformInterface $adapterPlatform = null 改为 PlatformInterface $adapterPlatform,同时为保持位置兼容性在 processCombinedby() 和 processStatementEnd() 上保留该参数,然后使用 mago analyze --ignore-baseline src/Sql 验证 21 项发现如预期下降,且测试套件仍然通过。

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

描述

RFC
Proposed Version

Next minor

Basic Information

The process* methods on CreateTable, AlterTable and DropTable take ?PlatformInterface $adapterPlatform = null, but use it unconditionally: they call quoteIdentifier(), quoteTrustedValue(), processExpression() and resolveTable(), none of which accept null. Their only caller, AbstractSql::buildSqlString(), always passes a non-null platform.

This accounts for 21 analyzer findings in src/Sql/Ddl:

  • possibly-null-argument (8) and possible-method-access-on-null (6).
  • less-specific-nested-return-statement (4) and invalid-return-statement (1): calling a method on a possibly-null platform yields mixed, so the arrays these methods return lose their element types.
  • unused-parameter (2): CreateTable::processCombinedby() and processStatementEnd() receive the platform but don't use it.
Background

AbstractSql::getSqlString() supplies a default platform before calling buildSqlString(), so no path reaches these methods with null.

Considerations
  • These are protected methods. Making the parameter required narrows it for callers, but subclasses that override with ?PlatformInterface $adapterPlatform = null remain compatible, since a child may widen a parameter.
  • A subclass that calls parent::processX() without arguments, or with null, would get an ArgumentCountError or TypeError. None of the driver packages do this.
Proposal(s)

Change the signature of each DDL process* method to PlatformInterface $adapterPlatform. Keep the parameter on processCombinedby() and processStatementEnd(), since buildSqlString() passes it positionally to every process* method.

Appendix/Additional Info

Finding counts are from mago analyze --ignore-baseline src/Sql once the docblock typing in #204 is applied.

主要语言
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 摘要。