As per coding standard documentation at 'https://www.drupal.org/coding-standards/docs', @file tag docblock should not be there in the files that contain a namespaced class/interface/trait, whose file name is the class name with a .php extension.

The @file doc block MUST be present for all PHP files, with one exception: files that contain a namespaced class/interface/trait, whose file name is the class name with a .php extension, and whose file path is closely related to the namespace (under PSR-4 or a similar standard), SHOULD NOT have a @file documentation block.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ashish.Dalvi created an issue. See original summary.

ashishdalvi’s picture

Status: Active » Needs review
FileSize
398 bytes

Adding Patch

  • scott_euser committed e71ad22 on 8.x-1.x
    Issue #2764081 by Ashish.Dalvi: Remove file docblock for namespaced file...
scott_euser’s picture

Status: Needs review » Fixed

Hi Ashish.Dalvi,

Thanks for the clear explanation and patch. My CS missed that as I was missing the namespace (CS throws the error only when namespace is there as far as I can tell). I've removed the file docblock and added the namespace.

I've been having issues with the commits not getting updated in the tar/zip so please let me know if you don't see the update. It does show up in the commits stream here.

Thanks,
Scott

  • scott_euser committed afcbc6d on 8.x-1.x
    Issue #2764081 by Ashish.Dalvi: Rollback breaking change
    
scott_euser’s picture

Status: Fixed » Postponed (maintainer needs more info)

Unfortunately that is a breaking change. It seems the batch operations processing requires that the class be in the global namespace and therefore without a namespace tag. The @file therefore must be in place since this class cannot be namespaced (as the exception explains the @file should only be left out when namespaced).

With no @file and no namespace, Drupal CS throws an error.

Perhaps you can suggest an alternative route?

aspilicious’s picture

You need to add.a namespace line before the use statements. The patch to remove the comment is correct, the current code isn't.

scott_euser’s picture

Status: Postponed (maintainer needs more info) » Needs work

Sorry but it's not so simple as that. If you do that and run an export, you'll see that batch processing fails as the class is no longer globally available.

The patch does not add a namespace so it remains globally available but without the namespace the @file is required.

I either need to move the callback into the module file or need to figure out how to avoid the missing class when Drupal Core batch processing tries to run the callback. I will investigate further asap.

scott_euser’s picture

Status: Needs work » Fixed
FileSize
2.03 KB

  • scott_euser committed a4d5a29 on 8.x-1.x
    Issue #2764081 by Ashish.Dalvi: Remove file block, add namespace to...
scott_euser’s picture

Status: Fixed » Closed (fixed)