Skip to main content
1 of 3
Patrick Kenny
  • 29.4k
  • 19
  • 139
  • 316

Coding standards: "Missing class doc comment" when using attribute on class

I recently updated PHP from 8.1 to 8.2.

This resulted in a bunch of deprecation notices about use of dynamic properties in PHPUnit tests.

So, based on the docs, I added the AllowDynamicProperties class.

/**
 * Unit tests for the myModule class (timing).
 *
 * @group myModuleSuite
 *
 * @coversDefaultClass \Drupal\myModule\Class
 *
 * @property \DateTimeZone $timezone_utc
 * @property \DateTimeZone $timezone_nyc
 */
#[\AllowDynamicProperties]
class MyModuleTimingTest extends UnitTestCase {

This fixes the deprecation notice for PHP 8.2, but now the Drupal coding standards check complains about a "missing doc comment" for my MyModuleTimingTest class.

How am I supposed to write this so that I can use the attribute and not violate the coding standards?

Patrick Kenny
  • 29.4k
  • 19
  • 139
  • 316