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

Bug: handling files from global visibility #18

Closed
6elkir opened this issue Jan 20, 2023 · 2 comments
Closed

Bug: handling files from global visibility #18

6elkir opened this issue Jan 20, 2023 · 2 comments
Labels

Comments

@6elkir
Copy link

6elkir commented Jan 20, 2023

What steps will reproduce the problem?

scanFiles finds files only in the specified directory, everything is ok.

What is the expected result?

However, get_declared_classes processes ALL classes in the context's reach. This means that if we want to get a list of classes from a given directory, but there are other classes in the project that implement the given interface, the find method will return them as well.

What do you get instead?

I recommend filtering the directory at the class reflection level

@xepozz
Copy link
Contributor

xepozz commented Jan 22, 2023

Thanks for the suggestion. Could you please provide a test case? I've made a fix, but the test case is needed.

@vjik
Copy link
Member

vjik commented Jan 22, 2023

Thanks for the suggestion. Could you please provide a test case? I've made a fix, but the test case is needed.

For example, create class TestUser out of tests directory:

<?php

declare(strict_types=1);

namespace Yiisoft\Classifier;

use Yiisoft\Classifier\Tests\Support\Interfaces\UserInterface;

final class TestUser implements UserInterface
{
}

And add new TestUser(); before run Classifier in tests. It's will broke tests, because TestUser will be found also.

@xepozz xepozz closed this as completed Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants