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

Use FullyQualified for class instead of Name #225

Merged
merged 5 commits into from
Jul 7, 2024

Conversation

megawubs
Copy link
Contributor

@megawubs megawubs commented Jun 28, 2024

This ensures a leading slash \ is added to the namespace of the class that is newed up, ensuring the namespace is loaded from the root and not relative to the current namespace.

Currently this rector breaks my code as it changes the code into something that does not work.

@@ @@
     public function handleTenant(TenantWithDatabase $tenant): void
     {
         $tenant->run(function (): void {
-            CreateTenantBrandingAvatarsJob::dispatch()->onQueue(Queue::CENTRAL);
+            dispatch(new App\Central\Jobs\CreateTenantBrandingAvatarsJob())->onQueue(Queue::CENTRAL);
         });
     }
 }
    ----------- end diff -----------

Applied rules:
 * DispatchToHelperFunctionsRector

Note the missing \ before App. This results in a namespace that can not be resolved. And broken tests

image

But with the leading slash, it's correct.

image

This ensures a leading slash '\' is added to the namespace, ensuring the namespace is loaded from the root and not relative to the current namespace.
@megawubs
Copy link
Contributor Author

I've tried running composer fix-cs but this changes a lot of code that I did not touch. I don't know if it's required before merge?

@TomasVotruba
Copy link
Collaborator

Indeed, this is best practice to work with names 👍

@GeniJaho GeniJaho enabled auto-merge (squash) July 7, 2024 09:34
@GeniJaho GeniJaho disabled auto-merge July 7, 2024 09:34
@GeniJaho
Copy link
Collaborator

GeniJaho commented Jul 7, 2024

@megawubs Thanks for the PR and sorry for the late reply. We've just fixed the code style issue and can merge your PR. Can you please run composer fix-cs once more?

@megawubs
Copy link
Contributor Author

megawubs commented Jul 7, 2024

I've just updated the code and ran composer fix-cs

@GeniJaho GeniJaho merged commit c8e28db into driftingly:main Jul 7, 2024
5 checks passed
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.

3 participants