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

Strauss replacing strings that looks like class name #112

Open
Dartui opened this issue Jul 22, 2024 · 2 comments
Open

Strauss replacing strings that looks like class name #112

Dartui opened this issue Jul 22, 2024 · 2 comments

Comments

@Dartui
Copy link

Dartui commented Jul 22, 2024

Here is a repository that recreates the issue: https://github.com/Dartui/strauss-prefix-error
Here is a change that is generated by Strauss: https://github.com/Dartui/strauss-prefix-error/pull/1/files

If you want to test that locally simply clone repository and run composer install.

TL;DR - Strauss replaces string values to the FQCN if it matches the name of the imported class that is used in the same file. Is it possible to exclude this behavior somehow? I've tried using exclude_from_prefix but without success

@Dartui
Copy link
Author

Dartui commented Aug 9, 2024

For anyone interested - running strauss --updateCallSites=false disables replacements in project files. It does not solve the issue, but for me it resolves my problem.

Feel free to close that issue if there are no plans to take on that.

@BrianHenryIE
Copy link
Owner

updateCallSites should be false by default. So maybe that’s a bug itself.

To the original issue — I haven’t come up with a way to address it. It is a namespace, and namespaces are correctly required to be replaced in strings, but I don’t know how to disambiguate a namespace from a proper noun when they are the exact same string.

Ideally all projects would use Company\Project style namespaces. As suggested (not required) in PSR-4.

If you have a suggestion on how to tell them apart, let me know.

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

No branches or pull requests

2 participants