Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#212 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
14

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

php-db/phpdb のほかの issue

php-db/phpdb の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。