Problem/Motivation

DebugClassLoader reports methods that lack a native return type. For example:

Method "Drupal\Core\Form\FormInterface::buildForm()" might add "array" as a native return type declaration in the future. Do the same in implementation "Drupal\simple_oauth\Form\OpenIdConnectSettingsForm" now to avoid errors or add an explicit @return annotation to suppress this message.

On Drupal 11.4, it flags UserIdentityProvider::getUserEntityByIdentifier() and two jsonSerialize() methods. On Drupal 12, it flags 170 methods in 33 classes. TokenAuthUser has 102 of them. These deprecations fail the "phpunit (next major)" job in #3603030: Automated Drupal 12 compatibility fixes for simple_oauth 6.1.x-dev.

Steps to reproduce

Run the "phpunit (next major)" CI job.

Proposed resolution

Add accurate @return annotations to flagged methods in classes that are public API in 6.1.x. This removes the class-loader warnings without changing method signatures.

Add native return types to SimpleOauthAuthenticationProvider, OpenIdConnectSettingsForm and DisallowSimpleOauthRequests. These classes are marked @internal.

TokenAuthUser is also @internal, but it gets @return annotations. Most of its methods return the value from the decorated User. Fluent methods such as addRole() return the decorated User, not the TokenAuthUser. A native static type on those methods throws a TypeError.

Five warnings come from core traits: RedundantEditableConfigNamesTrait::getEditableConfigNames() and the CacheableDependencyTrait methods on ScopeEntity. Drupal 12 does not change these traits. Core ignores the same warnings for its own classes. Suppress these five warnings using two narrowly scoped patterns in a project .deprecation-ignore.txt. Set DRUPAL_DEPRECATION_FILTER_CONFIG in .gitlab-ci.yml so PHPUnit uses that file on Drupal 11.5 and later.

Add native return types to the other classes in the next major version.

Test-only MR !250 applies this branch on top of #3603030: Automated Drupal 12 compatibility fixes for simple_oauth 6.1.x-dev. Its "phpunit (next major)" job reports no return type deprecations from simple_oauth classes.

Remaining tasks

User interface changes

None.

API changes

No public API signature changes in 6.1.x. Native return declarations are added only to internal classes. DebugClassLoader can warn subclasses that override these methods without a return type. Its vendor-prefix and version checks decide when it does.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tolstoydotcom created an issue. See original summary.

vidit.anjaria’s picture

pfrilling’s picture

Assigned: Unassigned » pfrilling

Assigning myself to work on in Sprint20

pfrilling’s picture

Assigned: pfrilling » Unassigned
Status: Active » Needs review

I rebased onto 6.1.x and fixed the linting errors to get the pipeline green.

vidit.anjaria’s picture

Issue tags: +2026Sprint21
pfrilling’s picture

Assigned: Unassigned » pfrilling
Status: Needs review » Needs work

Moving to needs work and will look into fixing all return type deprecations from https://www.drupal.org/project/simple_oauth/issues/3603030#comment-16833189

pfrilling’s picture

Title: D11.3 Deprecation warning re getUserEntityByIdentifier() missing @return » Add return type annotations flagged by DebugClassLoader on Drupal 12
Assigned: pfrilling » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
Related issues: +#3603030: Automated Drupal 12 compatibility fixes for simple_oauth 6.1.x-dev

I opened draft MR !250 to test this on Drupal 12. It stacks this branch on top of the #3603030: Automated Drupal 12 compatibility fixes for simple_oauth 6.1.x-dev branch, so it picks up the consumers patch and the attribute discovery fixes. It is test only and should not be merged.

Results from the "phpunit (next major)" job:

Five of the 170 come from the core traits RedundantEditableConfigNamesTrait and CacheableDependencyTrait. Core ignores the same messages for its own classes, so I added them to a project .deprecation-ignore.txt. On Drupal 11.5 and later, PHPUnit only reads that file when DRUPAL_DEPRECATION_FILTER_CONFIG points at it, so I set it in .gitlab-ci.yml. Without it, those five remain.

The job still fails on deprecations that are out of scope here: consumers' own return types, annotation-based plugin discovery and procedural hooks. The last two are the follow-ups proposed in #3603030: Automated Drupal 12 compatibility fixes for simple_oauth 6.1.x-dev.

I also updated the issue summary.

Drafted with help from an LLM