#7520·dbal

PHPStan reports getObjectName() on Table, Column and Index as a call to an internal class since 4.5.0

Author: fballianoCreated Sep 29, 2026Updated Sep 29, 2026

Bug Report

Q A
Version 4.5.0
Previous Version if the bug is a regression 4.4.5

Summary

#7387 marked AbstractNamedObject and AbstractOptionallyNamedObject as @internal. The intent is that users must not extend or type against these classes, and must use the NamedObject and OptionallyNamedObject interfaces instead.

But getObjectName() is declared only in these base classes. So PHPStan reports every call like $table->getObjectName() as a call to a method of an internal class, when the call comes from outside the Doctrine root namespace.

DBAL's own analysis cannot see this: PHPStan reports internal elements only across root namespaces, and the DBAL sources and tests (and ORM, Migrations) are all under Doctrine\.

Current behavior

Call to method getObjectName() of internal class
Doctrine\DBAL\Schema\AbstractNamedObject<Doctrine\DBAL\Schema\Name\OptionallyQualifiedName>
from outside its root namespace Doctrine. [identifier=method.internalClass]

The same happens for Column, Index, Sequence and for the AbstractOptionallyNamedObject subclasses (for example ForeignKeyConstraint).

Expected behavior

Calling the NamedObject::getObjectName() contract on a public schema class is not reported.

How to reproduce

php
<?php

declare(strict_types=1);

namespace App;

use Doctrine\DBAL\Schema\Table;

function tableName(Table $table): string
{
    return $table->getObjectName()->getUnqualifiedName()->getValue();
}

Run vendor/bin/phpstan analyse on the file (PHPStan 2.1, any level).

The only workaround today is to pass the object through a parameter typed as NamedObject, or to ignore method.internalClass.

Possible fix

  • Declare getObjectName() in the concrete classes on 4.5.x, as 5.0.x does after #7394.
  • Or keep the base classes non-internal on 4.5.x and document that they must not be extended.