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

[Laravel] Conflicts between Modular architecture and ReflectionClassRecursiveIterator #7023

Open
gd6tm opened this issue Mar 14, 2025 · 4 comments · Fixed by #7024
Open

[Laravel] Conflicts between Modular architecture and ReflectionClassRecursiveIterator #7023

gd6tm opened this issue Mar 14, 2025 · 4 comments · Fixed by #7024

Comments

@gd6tm
Copy link
Contributor

gd6tm commented Mar 14, 2025

API Platform version(s) affected: 4.1.0 and 4.1.1

Description
I have a Modular architecture in my laravel project.
app/Modules/ExampleModule
app/Modules/ExampleModule2
...

Each modules have unit testing with PestPhp.
app/Modules/ExampleModule/tests/
app/Modules/ExampleModule2/tests/

Since the 4.1 there is the tagged interfaces that has been added in the tagServices
Unfortunately Laravel try to discover the files in the Test Folder, creating this error during the composer autoload command

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Pest\Exceptions\InvalidPestCommand 
Please run [./vendor/bin/pest] instead.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

How to reproduce
Create the tree in app
app/Modules/ExampleModule/tests/Feature/Test.php
here the test but it's not relevant

use Tests\TestCase;

pest()->extend(TestCase::class);

it('Test description', function () {}
}
@soyuka
Copy link
Member

soyuka commented Mar 15, 2025

I see didn't predict that, maybe that #7024 does the trick, let me know!

@gd6tm
Copy link
Contributor Author

gd6tm commented Mar 16, 2025

nop, that doesn't resolve the problem, but perhaps you forgot to add the ReflectionClassRecursiveIterator file in the commit, because you add a second parameter false here $classes = ReflectionClassRecursiveIterator::getReflectionClassesFromDirectories([$directory], false);
but the method definition doesn't have a second parameter public static function getReflectionClassesFromDirectories(array $directories): array

here a repo if you need
https://github.com/gd6tm/laravel_modular_pest_api_platform

@soyuka
Copy link
Member

soyuka commented Mar 17, 2025

I'll test this today, thanks for the report !

@soyuka
Copy link
Member

soyuka commented Mar 18, 2025

I tried with class_exists https://gist.github.com/soyuka/6419e2aecc8ab2e25020d9f018eccff3#file-reflectionclassrecursiveiterator-php-L84 but I still have the issue. I think that it could be solved directly inside Pest: pestphp/pest#1372.

Anyways I'll skip Test files.

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 a pull request may close this issue.

2 participants