Skip to main content
removed tags from the title
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

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

added 279 characters in body
Source Link
Patrick Kenny
  • 29.4k
  • 19
  • 139
  • 316

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?

How I'm checking the coding standards

Using Coder module 8.3.16.

/vendor/bin/phpcs -p --colors --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md --ignore=node_modules,vendor ./web/modules/custom ./web/themes/custom

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?

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?

How I'm checking the coding standards

Using Coder module 8.3.16.

/vendor/bin/phpcs -p --colors --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md --ignore=node_modules,vendor ./web/modules/custom ./web/themes/custom

Source Link
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?