Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to check for multiple extends #432

Merged
merged 2 commits into from
May 28, 2024
Merged

Add ability to check for multiple extends #432

merged 2 commits into from
May 28, 2024

Conversation

kapersoft
Copy link
Contributor

This PR adds the ability to add multiple parameters in the Extends constructor. The violation will happen when none of the given strings will match the extend.

In my project I want to check if unit tests extends PHPUnit's TestCase or Mockery's TestCase:

return static function (Config $config): void {
    $testClassSet = ClassSet::fromDir(__DIR__ . '/Tests');

    $rule = Rule::allClasses()
        ->that(new ResideInOneOfTheseNamespaces('Tests\Unit'))
        ->andThat(new HaveNameMatching('*Test'))
        ->should(new Extend(\PHPUnit\Framework\TestCase::class, \Mockery\Adapter\Phpunit\MockeryTestCase::class))
        ->because('unit tests must extend the PHPUnit TestCase or Mockery TestCase');

    $config->add($testClassSet, $rule);
};

When one parameter is used in the Extend constructor, it works the same as before.

@AlessandroMinoccheri
Copy link
Member

Hi @kapersoft thanks for this PR, can you please also update the README file with this new behavior?

@kapersoft
Copy link
Contributor Author

@AlessandroMinoccheri I have applied the same changes to the NotExtend-class and updated the readme.md

@AlessandroMinoccheri
Copy link
Member

Little fix to do @kapersoft for coding standards, then it can be merged.

@kapersoft
Copy link
Contributor Author

@AlessandroMinoccheri ✅ Done.

Copy link
Member

@AlessandroMinoccheri AlessandroMinoccheri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@AlessandroMinoccheri AlessandroMinoccheri merged commit cc81afc into phparkitect:main May 28, 2024
18 checks passed
@kapersoft
Copy link
Contributor Author

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants