Skip to content

Double slashes when replacing namespace in use keywoards inside clasess #166

@thomasplevy

Description

@thomasplevy

We've come upon an issue (at least with the Stripe PHP SDK) where use references within a class are not replaced properly during reprefixing

Reproduction Steps

With this composer.json file:

{
    "name": "thoams/stripe-strauss",
    "autoload": {
        "psr-4": {
            "Thoams\\StripeStrauss\\": "src/"
        }
    },
    "require-dev": {
        "brianhenryie/strauss": "^0.22.2"
    },
    "require": {
        "stripe/stripe-php": "^17.1"
    },
    "scripts": {
        "prefix-namespaces": [
            "strauss",
            "@php composer dump-autoload"
        ],
        "post-install-cmd": [
            "@prefix-namespaces"
        ],
        "post-update-cmd": [
            "@prefix-namespaces"
        ]
    }
}
  1. Run composer run prefix-namespaces
  2. Open vendor-prefixed/stripe/stripe-php/Billing/CreditGrant.php
  3. Observe that the line incorrectly replaced:

Original: https://github.com/stripe/stripe-php/blob/ef2fad15725d5f559a6d62dc38f1d68f726e504d/lib/Billing/CreditGrant.php#L33

Updated:

    use \\Thoams\\StripeStrauss\\Stripe\ApiOperations\Update;

Elsewhere in the file the replacement works correctly, however.

There's other instances of this throughout the reprefixed stripe lib.


Another dev on my team working on this rolled back to 0.20.1 and this issue does not occur on this version (I didn't actually test it, but I trust his word) but we can't use that version due to issues with JsonWrapper (JsonMapper/JsonMapper#195) that was addressed in 0.22.1

He was wrong. The issue started with 0.22.0


I've run out of time today to try to figure out the exact cause of the issue or I'd open a PR to try to address it. I picked through the code a bit but I couldn't pinpoint it.

Thanks for your effort on this project, we're big fans

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions