Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Research: ConnectionInterface contract for final driver Connection classes

Offen
#167 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Ruhig
Tech-Stack
php
Bereich
database

Rechercherichtung

Start with phpdb-mysql's test/unit/ConnectionTest.php, especially createMockConnection(), then trace the upstream interfaces and Connection::connect(), createResource(), and setResource(). Done means the resource-factory contract and approach for final driver Connection classes are decided and the PHPUnit failure mode is covered by the relevant tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Context

Researching whether phpdb-mysql's Connection class can be made final ahead of its 1.0.0 release. This will need a resource-factory contract designed here in php-db/phpdb, since the same problem will apply to every driver package. Still tracing the upstream interfaces and deciding on an approach, not rushed.

Root cause of the test failures

phpdb-mysql's test/unit/ConnectionTest.php::createMockConnection() uses a PHPUnit partial mock:

$connection = $this->getMockBuilder(Connection::class)
    ->onlyMethods(['createResource'])
    ->setConstructorArgs([$params])
    ->getMock();

onlyMethods() partial mocking works by generating a real subclass of Connection at runtime with the specified method overridden. Marking Connection final breaks this, since PHP does not allow subclassing a final class. This throws:

PHPUnit\Framework\MockObject\Generator\ClassIsFinalException: Class "PhpDb\Mysql\Connection" is declared "final" and cannot be doubled

Also confirmed that calling setResource() with a fake resource before connect() does not work as a substitute. connect()'s first line is if ($this->resource instanceof mysqli) { return $this; }. Once a resource is set, connect() treats that as already connected and returns immediately, skipping the DSN and SSL flag building logic and the real_connect() call that the tests need to exercise.

Vorherrschende Sprache
PHP
Sterne
18
Forks
8
Ø Merge
6 T. 11 Std.
Gemergte PRs (30 T.)
14

Entwicklungsumgebung

  • Enthält ein Dockerfile oder eine Docker-Compose-Datei
  • Keine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus php-db/phpdb

Alle Issues in php-db/phpdb

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.