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

It does not prefix everything #88

Closed
sovetski opened this issue Mar 7, 2024 · 1 comment · Fixed by #89
Closed

It does not prefix everything #88

sovetski opened this issue Mar 7, 2024 · 1 comment · Fixed by #89

Comments

@sovetski
Copy link

sovetski commented Mar 7, 2024

Hi,

My composer.json:

{
    "require": {        
        "aws/aws-sdk-php": "^3.257"
    },
    "require-dev": {
        "brianhenryie/strauss": "^0.16.0"
    },
    "scripts": {
        "prefix-namespaces": [
            "strauss"
        ],
        "post-install-cmd": [
            "@prefix-namespaces"
        ],
        "post-update-cmd": [
            "@prefix-namespaces"
        ]
    },
    "extra": {
        "strauss": {
            "namespace_prefix": "MyCustomTest\\",
            "classmap_prefix": "MyCustomTest_"
        }
    }
}

I applied this suggestion which works as well, and it runs very quickly now.

But the problem is: The library does not prefix everything, in AWS example, before or after removing unused services, the problem is the same. It does not prefix this code (in: /vendor-prefixed/aws/aws-sdk-php/src/S3/S3Client.php):

    public function getObjectUrl($bucket, $key)
    {
        $command = $this->getCommand('GetObject', [
            'Bucket' => $bucket,
            'Key'    => $key
        ]);

        return (string) \Aws\serialize($command)->getUri(); // <<<---- HERE
    }

All other parts look fine, only this code is not prefixed, and I can not upload any files to AWS without this.

Any idea? I guess maybe it is because it starts with \?

@BrianHenryIE
Copy link
Owner

Great, thanks! That's merged into master now, a9bb376, and I added a test, 6518699. I also applied that removeUnusedServices script to some older tests that I had marked as skip because they were previously too slow, 5b905e1.

In general, edge cases like these need to be identified from errors before I can fix them. I think it would be better if this tool were using nikic/PHP-Parser, but the regex approach has gotten us this far. The currently open issues are more around dealing with Composer than the replacements themselves so it's not a priority to look into yet.

I have some other work in-progress so I'm not going to create a release immediately.

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