Problem/Motivation

One of the changes for Coder 9 is that Squiz.Classes.ClassFileName replaces Drupal.Classes.ClassFileName. Unfortunately, it has a different behavior in that it does not allow two classes to be declared in a single file, which is done in many Drupal tests. That is resulting in a large MR in the parent issue.

Those changes are moved to this issue.

Steps to reproduce

Proposed resolution

Replace Drupal.Classes.ClassFileName with Squiz.Classes.ClassFileName

Remaining tasks

Review

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3589643

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

quietone created an issue. See original summary.

quietone’s picture

Issue summary: View changes
Status: Active » Needs review
borisson_’s picture

The change in phpcs.xml.dist looks good and most of the changes I scanned through also look good, I don't understand why phpstan baseline file has changed?

smustgrave’s picture

from what I can tell the baseline changed due to some phpstan lines being removed

@phpstan-ignore testClass.missingAttribute.Group, testClass.missingAttribute.RunInSeparateProcesses for example.

borisson_’s picture

Status: Needs review » Needs work

Looks like that's it, let's make sure we don't need to do those changes if we can, then this looks good to go.

longwave’s picture

Yeah, I think those phpstan-ignores are there by design, we never want that class to have the attributes?

quietone’s picture

Status: Needs work » Needs review

I've restored the phpstan-ignore .

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me now.

longwave’s picture

Status: Reviewed & tested by the community » Needs review

To me adding test fixtures inside the same file makes more sense than keeping them separate. If we introduce this here then we have to explicitly add an ignore for every single test fixture that is handled in this way - shouldn't we consider enabling this rule only for non-test files?

longwave’s picture

The coding standards say "Best practices include having one class or interface or trait per file. That file should be named for the class, such that the file name for FooInterface would be FooInterface.php." - ie to me this is a best practice but not a hard requirement.

Maybe we should follow RFC 2119 for the coding standards - ie. use MUST and SHOULD for requirements vs recommendations.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.17 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

borisson_’s picture

To me adding test fixtures inside the same file makes more sense than keeping them separate. If we introduce this here then we have to explicitly add an ignore for every single test fixture that is handled in this way - shouldn't we consider enabling this rule only for non-test files?

Most test files only have one class, so it's only for a few of them that we need to add this rule, so if we can keep doing it like this, that makes more sense to me.

quietone’s picture

It is roughly 171/3935 or 4% of files ending in 'Test.php'. So, yes, it isn't a lot of files. On the other hand, excluding test file is what we are doing now. Maybe it is best to keep to current practice while we update to Coder 9.

quietone’s picture

Status: Needs work » Needs review

I should have set this to needs review.

I still think longwave is correct. Let's not do this, or at least, not now. I think we can explore if we want to change how we write some tests in the Coding Standards project.

smustgrave’s picture

Coder 9 just landed not sure if anything needs to be tweaked here.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

quietone’s picture

Status: Needs work » Closed (works as designed)

Yes, I think this is really working as designed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.