Giter Club home page Giter Club logo

imposter-plugin's People

Contributors

dependabot-preview[bot] avatar tangrufus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imposter-plugin's Issues

Global Installation Issue

I was trying out doing a global installation of this package so I could keep it out of the project requirements, but ran into an issue. It looks like it's attempting to run after being globally installed because I get the error:

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
                          
  [UnexpectedValueException]   
  Imposter namespace is empty

I'm going to look in the code a bit, but I'm hoping it would be easy to make sure that if composer global is being run then the the package won't attempt to run.

Error when exclude-from-classmap points to non-existing folder

Hey, I'm having problem with installing Symfony\Process package.

It has the following line in composer.json:

    "autoload": {
        "psr-4": { "Symfony\\Component\\Process\\": "" },
        "exclude-from-classmap": [
            "/Tests/"
        ]
    },

It looks like the Composer distribution does not include this Test folder which causes the following error:

 [UnexpectedValueException]                                                                                                                                                                        
  RecursiveDirectoryIterator::__construct(/Users/johannessiipola/Documents/Projects/searchwp-finnish-base-forms-new-local/app/public/wp-content/plugins/searchwp-finnish-base-forms/vendor/symfony  
  /process//Tests/): failed to open dir: No such file or directory         

I can prevent this error either by creating this folder or removing the line from the package's composer.json.

Fatal error: Cannot declare class

Good evening.

I have tried imposter-plugin for composer but i think i'm not using it in the right way: i placed this code in composer.json file:

"extra": {
    "imposter": {
      "namespace": "My\\Vendor",
      "excludes": [ ]
    }
  }

And then i installed the imposter plugin via composer require.
Then i run composer install and all my classes get namespaced but when i try to use them im getting the errors:

Fatal error: Cannot declare class Ekr\Vendor\Monolog\Formatter\LineFormatter, because the name is already in use in /var/www/html/.../vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php on line 0

Wich is my mistake?

Composer 2 support

I see that the composer-plugin-api is set to 1.1, meaning we cannot use it with v2 of the Composer.

Any plans to make it compatible with it? Is there some way to help make it compatible?

Edit

I've forked it and added

        "composer-plugin-api": "^1.1 || ^2",

To the required field, and all the tests passed 🤷‍♂️

Installing Imposter Plugin for the first time gives an error because there's lack of config

Clean directory, not even composer initial files.

$ composer require typisttech/imposter-plugin
Using version ^0.3.1 for typisttech/imposter-plugin
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing typisttech/imposter (0.3.1): Downloading (100%)
  - Installing typisttech/imposter-plugin (0.3.1): Downloading (100%)
Writing lock file
Generating autoload files
Running Imposter...
======================
Loading package information from C:\Users\Kuba\Desktop\composer imposter test/composer.json


  [UnexpectedValueException]
  Imposter namespace is empty


imposter:run

Script @composer imposter:run handling the pre-autoload-dump event returned with error code 1

Installation failed, deleting ./composer.json.

Some well earned appreciation

Just wanted to thank you for releasing this. It works like a charm and saved me quite some time AND is pleasant to work with. Cheers!

[ErrorException] array_merge() expects at least 1 parameter, 0 given

I'm getting the following error after running composer imposter:run

[ErrorException]
array_merge() expects at least 1 parameter, 0 given

My composer.json file:

{
 // ...
  "require": {
    "composer/installers": "~1.0",
    "timber/timber": "^1.5",
    "abraham/twitteroauth": "^0.7.4",
    "defuse/php-encryption": "^2.1",
    "guzzlehttp/guzzle": "^6.3",
    "brain/cortex": "~1.0.0@dev",
    "symfony/var-dumper": "^4.2.0",
    "monolog/monolog": "^1.24.0",
    "google/cloud-firestore": "^1.0.0",
    "typisttech/imposter-plugin": "^0.3.1"
  },
  "autoload": {
    "psr-4": {
      "Sw\\": "lib/Sw/"
    },
    "files": [
        // some files here
    ]
  },
  "extra": {
    "imposter": {
      "namespace": "Sw\\Vendor"
    }
  }
}

Issues with Guzzle (PSR4 transforming)

Detailed description

I'm maintining a wide variaty of WHMCS modules. Recently WHMCS seems to started using Composer in their own, closed source, software - which conflicts with my modules. Since them I'm looking for such a plugin as Imposter to fix my dependency issues.

Most things seems to work just fine, expect with Guzzle and loading PSR-4 classes.

For example a trace I gathered. Here the core WHMCS software requests Guzzle, and the autoloader seems to respond with my transformed Guzzle instance:

1  Composer\Autoload\includeFile(/var/www/*/app/modules/addons/mollierecurring/vendor/composer/../guzzlehttp/guzzle/src/ClientInterface.php) called at [/var/www/*/app/vendor/composer/ClassLoader.php:322]
--
  | #2  Composer\Autoload\ClassLoader->loadClass(DevApp\WHMCS\MollieRecurring\Vendor\GuzzleHttp\ClientInterface)
  | #3  spl_autoload_call(DevApp\WHMCS\MollieRecurring\Vendor\GuzzleHttp\ClientInterface) called at [/var/www/*/app/modules/addons/mollierecurring/vendor/guzzlehttp/guzzle/src/Client.php:25]
  | #4  include(/var/www/*/app/modules/addons/mollierecurring/vendor/guzzlehttp/guzzle/src/Client.php) called at [/var/www/*/app/vendor/composer/ClassLoader.php:444]
  | #5  Composer\Autoload\includeFile(/var/www/*/app/modules/addons/mollierecurring/vendor/composer/../guzzlehttp/guzzle/src/Client.php) called at [/var/www/*/app/vendor/composer/ClassLoader.php:322]
  | #6  Composer\Autoload\ClassLoader->loadClass(GuzzleHttp\Client)
  | #7  spl_autoload_call(GuzzleHttp\Client) called at [/var/www/*/app/vendor/whmcs/whmcs-foundation/lib/Admin/Setup/General/UriManagement/ConfigurationController.php:0]
  | #8  WHMCS\Admin\Setup\General\UriManagement\ConfigurationController->queryEnvironmentMode() called at [/var/www/*/app/vendor/whmcs/whmcs-foundation/lib/Admin/Setup/General/UriManagement/ConfigurationController.php:0]
  | #9  WHMCS\Admin\Setup\General\UriManagement\ConfigurationController->remoteDetectEnvironmentMode(WHMCS\Http\Message\ServerRequest Object ([*queryBag] => Symfony\Component\HttpFoundation\ParameterBag Object ([*parameters] => Array ()),[*requestBag] => Symfony\Component\HttpFoundation\ParameterBag Object ([*parameters] => Array ()),[*attributesBag] => Symfony\Component\HttpFoundation\ParameterBag Object ([*parameters] => Array ()),[Zend\Diactoros\ServerRequestattributes] => Array (),[Zend\Diactoros\ServerRequestcookieParams] => Array (),[Zend\Diactoros\ServerRequestparsedBody] => ,[Zend\Diactoros\ServerRequestqueryParams] => Array (),[Zend\Diactoros\ServerRequestserverParams] => Array (),[Zend\Diactoros\ServerRequestuploadedFiles] => Array (),[*headers] => Array (),[*headerNames] => Array (),[Zend\Diactoros\ServerRequestprotocol] => 1.1,[Zend\Diactoros\ServerRequeststream] => Zend\Diactoros\PhpInputStream Object ([Zend\Diactoros\PhpInputStreamcache] => ,[Zend\Diactoros\PhpInputStreamreachedEof] => ,[*resource] => Resource id #361,[*stream] => php://input),[Zend\Diactoros\ServerRequestmethod] => ,[Zend\Diactoros\ServerRequestrequestTarget] => ,[Zend\Diactoros\ServerRequesturi] => Zend\Diactoros\Uri Object ([*allowedSchemes] => Array ([http] => 80,[https] => 443),[Zend\Diactoros\Urischeme] => ,[Zend\Diactoros\UriuserInfo] => ,[Zend\Diactoros\Urihost] => ,[Zend\Diactoros\Uriport] => ,[Zend\Diactoros\Uripath] => ,[Zend\Diactoros\Uriquery] => ,[Zend\Diactoros\Urifragment] => ,[Zend\Diactoros\UriuriString] => ))) called at [/var/www/*/app/vendor/whmcs/whmcs-foundation/lib/Admin/Setup/General/UriManagement/View/Helper/SimpleSetting.php:0]
  | #10 WHMCS\Admin\Setup\General\UriManagement\View\Helper\SimpleSetting->getSimpleSettingHtmlPartial() called at [/var/www/*/app/admin/configgeneral.php:0]

This results in either incompatbility or Cannot declare class DevApp\WHMCS\MollieRecurring\Vendor\GuzzleHttp\Client, because the name is already in use in /var/www/*/app/modules/addons/mollierecurring/vendor/guzzlehttp/guzzle/src/Client.php on line 25-errors.

Also - the autoloading files for Guzzle does not work. This because Guzzle includes this file, which checks if GuzzleHttp\uri_template is loaded - but most of the time it is (because of the core software, which already has Guzzle loaded) and so my namespace's Guzzle functions won't get loaded.

WHMCS loads Composer itself and I'm not sure how their composer.json looks like. Mine is, for example:

{
    "require": {
        "mollie/mollie-api-php": "2.0.*",
        "typisttech/imposter-plugin": "^0.3.0"
    },
    "config": {
        "vendor-dir": "src/addons/mollierecurring/vendor"
    },
    "extra": {
        "imposter": {
            "namespace": "DevApp\\WHMCS\\MollieRecurring\\Vendor\\"
        }
    }
}

Context

It is important to me to keep using my current packages (I don't use guzzle directly, but most of my packages do). This could also benefit other people, as Guzzle is a widely used package to handle HTTP requests.

Possible implementation

Unsure. Maybe manually update the PSR-4 mapping?

Your environment

  • PHP 7.2
  • WHMCS addons
  • Different Guzzle versions

Terminal output formatting

I'm not sure if this is a Composer issue, Imposter-plugin issue or PHPCS installer issue, but...

I'm using your awesome typisttech/imposter-plugin package as well as the coding standards packages:

  • dealerdirect/phpcodesniffer-composer-installer
  • phpcompatibility/php-compatibility
  • wp-coding-standards/wpcs

The phpcodesniffer-composer-installer upon install or update is giving details about installed standards which interferes with imposter output.

This results in the following log:

Generating autoload files
Running Imposter...
======================
Loading package information from /var/project-path/composer.json
Imposter operations: 6 transformations
 - Transforming: /var/project-path/vendor/micropackage/requirements/src
 - Transforming: /var/project-path/vendor/micropackage/internationalization/src
 - Transforming: /var/project-path/vendor/micropackage/dochooks/src
 - Transforming: /var/project-path/vendor/micropackage/filesystem/src
 - Transforming: /var/project-path/vendor/micropackage/templates/src
 - Transforming: /var/project-path/vendor/micropackage/templates/src/functions/template.php

Done.
 6/6 [============================] 100%PHP CodeSniffer Config installed_paths set to ../../phpcompatibility/php-compatibility,../../wp-coding-standards/wpcs
Generating optimized autoload filesRunning Imposter...
======================
Loading package information from /var/project-path/composer.json
Imposter operations: 6 transformations
 - Transforming: /var/project-path/vendor/micropackage/requirements/src
 - Transforming: /var/project-path/vendor/micropackage/internationalization/src
 - Transforming: /var/project-path/vendor/micropackage/dochooks/src
 - Transforming: /var/project-path/vendor/micropackage/filesystem/src
 - Transforming: /var/project-path/vendor/micropackage/templates/src
 - Transforming: /var/project-path/vendor/micropackage/templates/src/functions/template.php

Done.
Generated optimized autoload files containing 975 classes

Namespace change not applied to functions

What would need to be done to address this? THX

Example: https://drone.owncloud.com/owncloud/files_primary_s3/589/42

Error: Call to undefined function Aws\manifest() in /drone/server/apps/files_primary_s3/vendor/aws/aws-sdk-php/src/Api/ApiProvider.php:97
Stack trace:
#0 /drone/server/apps/files_primary_s3/vendor/aws/aws-sdk-php/src/ClientResolver.php(260): OCA\Files_Primary_S3\Vendor\Aws\Api\ApiProvider::defaultProvider(Array)
#1 /drone/server/apps/files_primary_s3/vendor/aws/aws-sdk-php/src/AwsClient.php(161): OCA\Files_Primary_S3\Vendor\Aws\ClientResolver->resolve(Array, Object(OCA\Files_Primary_S3\Vendor\Aws\HandlerList))
#2 /drone/server/apps/files_primary_s3/vendor/aws/aws-sdk-php/src/S3/S3Client.php(263): OCA\Files_Primary_S3\Vendor\Aws\AwsClient->__construct(Array)
#3 /drone/server/apps/files_primary_s3/lib/command/createbucket.php(109): OCA\Files_Primary_S3\Vendor\Aws\S3\S3Client->__construct(Array)
#4 /drone/server/apps/files_primary_s3/lib/command/createbucket.php(72): OCA\Files_Primary_S3\Command\createBucket->getClient()
#5 /drone/server/lib/composer/symfony/console/Command/Command.php(255): OCA\Files_Primary_S3\Command\createBucket->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /drone/server/lib/composer/symfony/console/Application.php(946): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /drone/server/lib/composer/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files_Primary_S3\Command\createBucket), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /drone/server/lib/composer/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /drone/server/lib/private/Console/Application.php(161): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /drone/server/console.php(106): OC\Console\Application->run()
#11 /drone/server/occ(11): require_once('/drone/server/c...')
#12 {main}

array_merge() exception in ArrayUtil

Detailed description

Followed standard procedure for installing on the readme. Running any composer command afterward results in:


                                                       
  [ErrorException]                                     
  array_merge() expects at least 1 parameter, 0 given  
                                                       

Exception trace:
 () at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/ArrayUtil.php:41
 Composer\Util\ErrorHandler::handle() at n/a:n/a
 array_merge() at n/a:n/a
 call_user_func_array() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/ArrayUtil.php:41
 TypistTech\Imposter\ArrayUtil::flatten() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/ArrayUtil.php:29
 TypistTech\Imposter\ArrayUtil::flattenMap() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/Config.php:56
 TypistTech\Imposter\Config->getAutoloadPaths() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/Config.php:44
 TypistTech\Imposter\Config->getAutoloads() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/ConfigCollection.php:42
 TypistTech\Imposter\ConfigCollection->TypistTech\Imposter\{closure}() at n/a:n/a
 array_map() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/ArrayUtil.php:27
 TypistTech\Imposter\ArrayUtil::flattenMap() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/ConfigCollection.php:43
 TypistTech\Imposter\ConfigCollection->getAutoloads() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter/src/Imposter.php:83
 TypistTech\Imposter\Imposter->getAutoloads() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter-plugin/src/ImposterPlugin.php:106
 TypistTech\Imposter\Plugin\ImposterPlugin->getImposterAutoloads() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter-plugin/src/ImposterPlugin.php:90
 TypistTech\Imposter\Plugin\ImposterPlugin->addAutoloadTo() at /var/www/html/wp-content/plugins/wp-oauth/vendor/typisttech/imposter-plugin/src/ImposterPlugin.php:50
 TypistTech\Imposter\Plugin\ImposterPlugin->activate() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:236
 Composer\Plugin\PluginManager->addPlugin() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:205
 Composer\Plugin\PluginManager->registerPackage() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:261
 Composer\Plugin\PluginManager->loadRepository() at phar:///usr/local/bin/composer/src/Composer/Plugin/PluginManager.php:76
 Composer\Plugin\PluginManager->loadInstalledPlugins() at phar:///usr/local/bin/composer/src/Composer/Factory.php:384
 Composer\Factory->createComposer() at phar:///usr/local/bin/composer/src/Composer/Factory.php:576
 Composer\Factory::create() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:332
 Composer\Console\Application->getComposer() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:444
 Composer\Console\Application->getPluginCommands() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:149
 Composer\Console\Application->doRun() at phar:///usr/local/bin/composer/vendor/symfony/console/Application.php:127
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/composer/src/Composer/Console/Application.php:100
 Composer\Console\Application->run() at phar:///usr/local/bin/composer/bin/composer:54
 require() at /usr/local/bin/composer:24

Your environment

PHP 7.1
Tried on Ubuntu, WSL(windows subsystem linux), and windows,
composer.json:

  "name": "my-project",
  "description": "private",
  "require": {
    "google/apiclient": "2.1.3",
    "yahnis-elsts/plugin-update-checker": "4.0.3",
    "typisttech/imposter-plugin": "^0.2.6"
  },
  "extra": {
    "imposter": {
      "namespace": "Symphony_Agency_oauth"
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.