Skip to content

Double backslashes being added #58

Description

@harryhorton

Detailed description

Google's apiclient has a file vendor/firebase/php-jwt/src/JWT.php that uses

use \DomainException;
use \InvalidArgumentException;
use \UnexpectedValueException;
use \DateTime;

The result is:

namespace mynamespace\vendor\Firebase\JWT;
use mynamespace\vendor\\DomainException;
use mynamespace\vendor\\InvalidArgumentException;
use mynamespace\vendor\\UnexpectedValueException;
use mynamespace\vendor\\DateTime;
//Note the double backslashes

This is causing
syntax error, unexpected '\' (T_NS_SEPARATOR), expecting identifier (T_STRING) or '{'

Composer.json:

  "name": "name",
  "description": "description",
  "require": {
    "google/apiclient": "2.1.3",
    "yahnis-elsts/plugin-update-checker": "^4.2",
    "typisttech/imposter-plugin": "^0.2.6"
  },
  "extra": {
    "imposter": {
      "namespace": "mynamespace\\vendor",
      "excludes": [
        "yahnis-elsts/plugin-update-checker"
      ]
    }
  }
}

Thanks again for any assistance you can provide =)

Activity

  1. tangrufus commented on Nov 1, 2017

    @tangrufus
    Member

    It's a bug. Failing test case added in #59

    Still think of a better regex for Transformer::prefixUse

    https://github.com/TypistTech/imposter/blob/7fc35b618844669d87bbece4345bbfa3917795bb/src/Transformer.php#L120-L137

    Any suggestion?

  2. added a commit that references this issue on Jan 16, 2018
    5faf490
  3. tangrufus commented on Jan 16, 2018

    @tangrufus
    Member

    Fixed in #59

    Tip A

    Beware that these 2 lines are different.

    use MyClass; # Imposter prefered
    use \MyClass;

    Imposter prefer not using leading backslashes beacuse imposter needs to hijack namespace lookup.

    Tip B

    When updating imposter and imposter-plugin, delete the vendor directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions