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.
Comment | File | Size | Author |
---|---|---|---|
#9 | namespace_the_batch_processing_callbacks-2764081.patch | 2.03 KB | scott_euser |
#2 | 2764081-1.patch | 398 bytes | ashishdalvi |
Comments
Comment #2
ashishdalviAdding Patch
Comment #4
scott_euser CreditAttribution: scott_euser commentedHi 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
Comment #6
scott_euser CreditAttribution: scott_euser commentedUnfortunately 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?
Comment #7
aspilicious CreditAttribution: aspilicious commentedYou need to add.a namespace line before the use statements. The patch to remove the comment is correct, the current code isn't.
Comment #8
scott_euser CreditAttribution: scott_euser commentedSorry 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.
Comment #9
scott_euser CreditAttribution: scott_euser commentedComment #11
scott_euser CreditAttribution: scott_euser commented