Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#212 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu ở src/Sql/Ddl với các phương thức process* của CreateTable, AlterTable và DropTable, và đọc AbstractSql::buildSqlString() cùng getSqlString() để xác nhận nền tảng luôn là non-null. Đổi từng chữ ký từ ?PlatformInterface $adapterPlatform = null thành PlatformInterface $adapterPlatform, giữ tham số trong processCombinedby() và processStatementEnd() để tương thích vị trí, rồi xác minh bằng mago analyze --ignore-baseline src/Sql rằng 21 phát hiện giảm như dự đoán và bộ test vẫn vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
18
Fork
8
Merge trung bình
6 ngày 11 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của php-db/phpdb

Tất cả issue của php-db/phpdb

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.