Generated with the help of an LLM.

Problem/Motivation

On Drupal 12, every test that loads a class extending ResourceFieldEnhancerBase gets 3 deprecations from Symfony's DebugClassLoader:

Method "Shaper\DataAdaptor\ReversibleTransformationValidationInterface::getInternalValidator()" might add "ValidateableInterface" as a native return type declaration in the future. Do the same in implementation "Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase" now to avoid errors or add an explicit @return annotation to suppress this message.

The same message comes for getInputValidator() and getOutputValidator().

run-tests.sh exits 1 for a test class with deprecations, even when all tests pass. So modules with an enhancer plugin get a failing "PHPUnit (next major)" job. Geofield is one: see #3598572: Automated Drupal 12 compatibility fixes for geofield 10.3.x-dev.

Steps to reproduce

On Drupal 12.0.0-beta2 with PHP 8.5, run Geofield's GeofieldGeoJsonEnhancerTest with !50 of #3598572: Automated Drupal 12 compatibility fixes for geofield 10.3.x-dev: "Tests: 15, Assertions: 28, Deprecations: 3."

Proposed resolution

Add @return \Shaper\Validator\ValidateableInterface to the three methods. The message itself suggests this. With it, the same test passes with no deprecations.

A native return type would also work, but it would break enhancers in other modules that override these methods without a return type.

Remaining tasks

  • Merge request.
  • Review.

User interface changes

None.

API changes

None. Only docblocks change.

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

orkutmuratyilmaz created an issue. See original summary.

sourav_paul’s picture

working on it...

orkutmuratyilmaz’s picture

Status: Active » Needs review

@sourav_paul, can you review my commit please?

sourav_paul’s picture

yes, the deprecation showing on D 12.0. has been fixed by the MR which has applied cleanly, also ran run-tests.sh passes.

Thanks

orkutmuratyilmaz’s picture

Status: Needs review » Reviewed & tested by the community

@sourav_paul, thanks for the test:) since it's okay for you, I'm changing the issue's status as RTBC now.