Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#212 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
68/100
Tipo de issue
Refatoração
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
php
Domínio
databases

Direção de pesquisa

Comece em src/Sql/Ddl com os métodos process* de CreateTable, AlterTable e DropTable, e leia AbstractSql::buildSqlString() e getSqlString() para confirmar que a plataforma é sempre non-null. Altere cada assinatura de ?PlatformInterface $adapterPlatform = null para PlatformInterface $adapterPlatform, mantendo o parâmetro em processCombinedby() e processStatementEnd() por compatibilidade posicional, e então verifique com mago analyze --ignore-baseline src/Sql que os 21 achados diminuem conforme o previsto e que a suíte de testes ainda passa.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
PHP
Estrelas
18
Forks
8
Merge médio
6d 11h
PRs com merge (30d)
14

Preparar o ambiente

  • Inclui um Dockerfile ou arquivo Docker Compose
  • Sem modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de php-db/phpdb

Todas as issues de php-db/phpdb

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.