Summary
PlatformDecoratorInterface declares only setSubject(), but every caller of
AbstractPlatform::getTypeDecorator() immediately calls getSqlString() or
prepareStatement() on the result. Those methods are not on the contract, so the
calls are unprovable and the analyzer reports them as calls to non-existent methods.
Separately, Platform stores its decorators in a per-platform map
([platformName][class => decorator]) while AbstractPlatform — which every driver
package extends — stores a flat [class => decorator] map. The two shapes share one
property name, so the property cannot be typed.
Together these account for 26 of the 28 analyzer findings in src/Sql/Platform.
Proposed change
PlatformDecoratorInterface extends SqlInterface, PreparableSqlInterface. Every
decorator in the ecosystem already satisfies this — they all extend Select,
Insert, Update, Delete, CreateTable or AlterTable.
setSubject() no longer accepts null, matching the non-nullable $subject
property it assigns to. Passing null is currently a TypeError.
- Remove the per-platform decorator registry from
Platform. It has no callers: the
three-argument setTypeDecorator() and two-argument getTypeDecorator() are never
invoked anywhere in this repository or in any driver package, and no test registers
decorators for more than one platform. Platform then inherits the flat map, like
every driver.
- Mark
Platform final.
- Remove the two now-unreachable guards in
Sql::buildSqlString() and
Sql::prepareStatementForSqlObject(), and the two tests covering them.
Compatibility
AbstractPlatform is unchanged in shape and signature, so phpdb-mysql and
phpdb-sqlite, which extend it and call the two-argument setTypeDecorator(), are
unaffected. phpdb-sqlite's reflection test on decorators still passes.
phpdb-pgsql instantiates Sql\Platform\Platform directly in
AdapterPlatform::getSqlPlatformDecorator(). It registers no decorators and calls none
of the removed methods. Verified by installing phpdb-pgsql against this branch and
against 0.6.x: both produce SELECT "users".* FROM "users" from the same probe.
phpdb-adapter-{ibmdb2,oci8,sql92,sqlsrv} will carry their own copy of
PhpDb\Sql\Platform\* and will have no runtime dependency on php-db/phpdb.
Breaking changes
Removed from Platform: the three-argument setTypeDecorator(), the two-argument
getTypeDecorator(), the getDecorators() override and the protected
resolvePlatformName(). Platform becomes final. No known caller uses any of them.
Notes
This addresses the @todo sat-migration block in Platform::__construct(). That approach has been
superseded by each driver shipping its own platform class.
Summary
PlatformDecoratorInterfacedeclares onlysetSubject(), but every caller ofAbstractPlatform::getTypeDecorator()immediately callsgetSqlString()orprepareStatement()on the result. Those methods are not on the contract, so thecalls are unprovable and the analyzer reports them as calls to non-existent methods.
Separately,
Platformstores its decorators in a per-platform map(
[platformName][class => decorator]) whileAbstractPlatform— which every driverpackage extends — stores a flat
[class => decorator]map. The two shapes share oneproperty name, so the property cannot be typed.
Together these account for 26 of the 28 analyzer findings in
src/Sql/Platform.Proposed change
PlatformDecoratorInterface extends SqlInterface, PreparableSqlInterface. Everydecorator in the ecosystem already satisfies this — they all extend
Select,Insert,Update,Delete,CreateTableorAlterTable.setSubject()no longer acceptsnull, matching the non-nullable$subjectproperty it assigns to. Passing
nullis currently aTypeError.Platform. It has no callers: thethree-argument
setTypeDecorator()and two-argumentgetTypeDecorator()are neverinvoked anywhere in this repository or in any driver package, and no test registers
decorators for more than one platform.
Platformthen inherits the flat map, likeevery driver.
Platformfinal.Sql::buildSqlString()andSql::prepareStatementForSqlObject(), and the two tests covering them.Compatibility
AbstractPlatformis unchanged in shape and signature, sophpdb-mysqlandphpdb-sqlite, which extend it and call the two-argumentsetTypeDecorator(), areunaffected.
phpdb-sqlite's reflection test ondecoratorsstill passes.phpdb-pgsqlinstantiatesSql\Platform\Platformdirectly inAdapterPlatform::getSqlPlatformDecorator(). It registers no decorators and calls noneof the removed methods. Verified by installing
phpdb-pgsqlagainst this branch andagainst
0.6.x: both produceSELECT "users".* FROM "users"from the same probe.phpdb-adapter-{ibmdb2,oci8,sql92,sqlsrv}will carry their own copy ofPhpDb\Sql\Platform\*and will have no runtime dependency onphp-db/phpdb.Breaking changes
Removed from
Platform: the three-argumentsetTypeDecorator(), the two-argumentgetTypeDecorator(), thegetDecorators()override and the protectedresolvePlatformName().Platformbecomesfinal. No known caller uses any of them.Notes
This addresses the
@todo sat-migrationblock inPlatform::__construct(). That approach has beensuperseded by each driver shipping its own platform class.