From 69f85769aed70fc16a5bd1d20ca7bc2492fa5349 Mon Sep 17 00:00:00 2001 From: nekorjira Date: Thu, 11 Dec 2014 13:09:10 +0800 Subject: [PATCH] updated dependencies, removed submodules --- .gitmodules | 3 - ChangeLog.md | 3 + README.md | 13 +- README.txt | 5 +- composer.json | 16 +- composer.lock | 166 +++++ lib/class-wp-php-console.php | 20 +- lib/php-console | 1 - vendor/autoload.php | 7 + vendor/composer/ClassLoader.php | 387 +++++++++++ vendor/composer/autoload_classmap.php | 9 + vendor/composer/autoload_namespaces.php | 11 + vendor/composer/autoload_psr4.php | 9 + vendor/composer/autoload_real.php | 50 ++ vendor/composer/installed.json | 153 +++++ vendor/composer/installers/.editorconfig | 10 + vendor/composer/installers/.gitignore | 3 + vendor/composer/installers/.travis.yml | 14 + vendor/composer/installers/LICENSE | 19 + vendor/composer/installers/README.md | 187 +++++ vendor/composer/installers/composer.json | 75 ++ vendor/composer/installers/phpunit.xml.dist | 25 + .../src/Composer/Installers/AglInstaller.php | 21 + .../Installers/AnnotateCmsInstaller.php | 11 + .../Composer/Installers/AsgardInstaller.php | 45 ++ .../src/Composer/Installers/BaseInstaller.php | 131 ++++ .../Composer/Installers/BitrixInstaller.php | 11 + .../Composer/Installers/CakePHPInstaller.php | 145 ++++ .../src/Composer/Installers/ChefInstaller.php | 11 + .../Installers/CodeIgniterInstaller.php | 11 + .../Installers/Concrete5Installer.php | 12 + .../Composer/Installers/CraftInstaller.php | 9 + .../Composer/Installers/CroogoInstaller.php | 21 + .../Composer/Installers/DokuWikiInstaller.php | 50 ++ .../Composer/Installers/DolibarrInstaller.php | 16 + .../Composer/Installers/DrupalInstaller.php | 13 + .../src/Composer/Installers/ElggInstaller.php | 9 + .../src/Composer/Installers/FuelInstaller.php | 11 + .../Composer/Installers/FuelphpInstaller.php | 9 + .../src/Composer/Installers/GravInstaller.php | 30 + .../Composer/Installers/HuradInstaller.php | 25 + .../src/Composer/Installers/Installer.php | 159 +++++ .../Composer/Installers/JoomlaInstaller.php | 15 + .../Composer/Installers/KirbyInstaller.php | 9 + .../Composer/Installers/KohanaInstaller.php | 9 + .../Composer/Installers/LaravelInstaller.php | 9 + .../Composer/Installers/LithiumInstaller.php | 10 + .../Installers/MODULEWorkInstaller.php | 9 + .../Composer/Installers/MODXEvoInstaller.php | 16 + .../Composer/Installers/MagentoInstaller.php | 11 + .../src/Composer/Installers/MakoInstaller.php | 9 + .../Installers/MediaWikiInstaller.php | 50 ++ .../Installers/MicroweberInstaller.php | 111 +++ .../Composer/Installers/MoodleInstaller.php | 47 ++ .../Composer/Installers/OctoberInstaller.php | 46 ++ .../src/Composer/Installers/OxidInstaller.php | 11 + .../src/Composer/Installers/PPIInstaller.php | 9 + .../Composer/Installers/PhpBBInstaller.php | 11 + .../Composer/Installers/PimcoreInstaller.php | 21 + .../Composer/Installers/PiwikInstaller.php | 32 + .../Composer/Installers/PuppetInstaller.php | 11 + .../Composer/Installers/RedaxoInstaller.php | 10 + .../Installers/RoundcubeInstaller.php | 22 + .../Composer/Installers/ShopwareInstaller.php | 58 ++ .../Installers/SilverStripeInstaller.php | 36 + .../Composer/Installers/Symfony1Installer.php | 26 + .../Composer/Installers/TYPO3CmsInstaller.php | 14 + .../Installers/TYPO3FlowInstaller.php | 38 ++ .../Composer/Installers/TheliaInstaller.php | 12 + .../src/Composer/Installers/TuskInstaller.php | 14 + .../Composer/Installers/WHMCSInstaller.php | 10 + .../Composer/Installers/WolfCMSInstaller.php | 9 + .../Installers/WordPressInstaller.php | 11 + .../src/Composer/Installers/ZendInstaller.php | 11 + .../Composer/Installers/ZikulaInstaller.php | 10 + vendor/composer/installers/src/bootstrap.php | 13 + .../Installers/Test/AsgardInstallerTest.php | 61 ++ .../Installers/Test/CakePHPInstallerTest.php | 163 +++++ .../Installers/Test/DokuWikiInstallerTest.php | 89 +++ .../Installers/Test/GravInstallerTest.php | 63 ++ .../Installers/Test/InstallerTest.php | 412 +++++++++++ .../Test/MediaWikiInstallerTest.php | 66 ++ .../Installers/Test/OctoberInstallerTest.php | 66 ++ .../Installers/Test/PimcoreInstallerTest.php | 44 ++ .../Installers/Test/PiwikInstallerTest.php | 63 ++ .../Composer/Installers/Test/TestCase.php | 64 ++ .../composer/installers/tests/bootstrap.php | 4 + vendor/php-console/php-console/LICENSE | 32 + vendor/php-console/php-console/README.md | 247 +++++++ vendor/php-console/php-console/composer.json | 35 + .../features/complex_usage_example.php | 91 +++ .../examples/features/debug_vars.php | 69 ++ .../examples/features/eval_terminal.php | 30 + .../examples/features/handle_errors.php | 48 ++ .../features/handle_javascript_errors.js | 2 + .../features/handle_javascript_errors.php | 15 + .../examples/features/handle_on_redirect.php | 25 + .../features/highload_optimization.php | 12 + .../examples/features/old_version_adapter.php | 19 + .../examples/features/protect_by_password.php | 19 + .../php-console/examples/index.php | 148 ++++ .../php-console/examples/styles.css | 42 ++ .../php-console/examples/utils/build_phar.php | 57 ++ .../examples/utils/detect_headers_limit.php | 37 + .../examples/utils/test_jump_to_file.php | 40 ++ .../php-console/src/PhpConsole/Auth.php | 106 +++ .../php-console/src/PhpConsole/Connector.php | 645 ++++++++++++++++++ .../php-console/src/PhpConsole/Dispatcher.php | 104 +++ .../src/PhpConsole/Dispatcher/Debug.php | 39 ++ .../src/PhpConsole/Dispatcher/Errors.php | 134 ++++ .../src/PhpConsole/Dispatcher/Evaluate.php | 72 ++ .../php-console/src/PhpConsole/Dumper.php | 181 +++++ .../src/PhpConsole/EvalProvider.php | 242 +++++++ .../php-console/src/PhpConsole/Handler.php | 241 +++++++ .../php-console/src/PhpConsole/Helper.php | 121 ++++ .../src/PhpConsole/OldVersionAdapter.php | 123 ++++ .../php-console/src/PhpConsole/PsrLogger.php | 77 +++ .../php-console/src/PhpConsole/Storage.php | 40 ++ .../src/PhpConsole/Storage/AllKeysList.php | 71 ++ .../PhpConsole/Storage/ExpiringKeyValue.php | 60 ++ .../src/PhpConsole/Storage/File.php | 93 +++ .../src/PhpConsole/Storage/Memcache.php | 54 ++ .../src/PhpConsole/Storage/Session.php | 38 ++ .../php-console/src/PhpConsole/__autoload.php | 10 + .../tests/ClientEmulator/Connector.php | 218 ++++++ .../tests/ClientEmulator/Request.php | 33 + .../tests/ClientEmulator/Response.php | 14 + .../php-console/php-console/tests/README.md | 7 + .../php-console/tests/Test/Connector.php | 56 ++ .../php-console/tests/Test/Dispatcher.php | 40 ++ .../tests/Test/Dispatcher/Debug.php | 83 +++ .../tests/Test/Dispatcher/Errors.php | 161 +++++ .../tests/Test/Dispatcher/Eval.php | 128 ++++ .../php-console/tests/Test/Dumper.php | 177 +++++ .../php-console/tests/Test/EvalProvider.php | 112 +++ .../php-console/tests/Test/Handler.php | 230 +++++++ .../php-console/tests/Test/Helper.php | 113 +++ .../php-console/tests/Test/PsrLogger.php | 82 +++ .../php-console/tests/Test/Remote/Auth.php | 83 +++ .../tests/Test/Remote/Connector.php | 163 +++++ .../tests/Test/Remote/Evaluate.php | 183 +++++ .../php-console/tests/Test/Remote/Handler.php | 141 ++++ .../Test/Remote/HandlerAfterConnector.php | 11 + .../Test/Remote/HandlerBeforeConnector.php | 11 + .../php-console/tests/Test/Remote/Test.php | 207 ++++++ .../php-console/tests/Test/Storage.php | 50 ++ .../php-console/tests/Test/Storage/File.php | 40 ++ .../tests/Test/Storage/Memcache.php | 21 + .../tests/Test/Storage/Session.php | 14 + .../php-console/tests/Test/Test.php | 81 +++ .../php-console/tests/bootstrap.php | 5 + .../php-console/tests/composer.json | 6 + .../php-console/php-console/tests/config.php | 40 ++ .../php-console/php-console/tests/phpunit.xml | 40 ++ .../tests/scripts/dispatch_debug.php | 6 + .../tests/scripts/init_default_connector.php | 4 + .../tests/scripts/init_default_handler.php | 3 + .../php-console/tests/scripts/print.php | 3 + .../scripts/set_connector_allowed_ip.php | 4 + .../tests/scripts/set_connector_auth.php | 4 + .../tests/scripts/set_connector_encoding.php | 9 + .../scripts/set_connector_eval_enabled.php | 12 + .../tests/scripts/set_connector_ssl_only.php | 3 + .../tests/scripts/set_server_encoding.php | 8 + .../tests/scripts/trigger_compile_error.php | 3 + .../tests/scripts/trigger_exception.php | 7 + .../tests/scripts/trigger_fatal_error.php | 3 + .../trigger_max_execution_time_error.php | 10 + .../scripts/trigger_memory_limit_error.php | 12 + .../scripts/trigger_not_fatal_errors.php | 8 + .../tests/scripts/trigger_parse_error.php | 3 + .../php-console/php-console/tests/server.php | 15 + .../php-console/tests/vendor/README.md | 1 + wp-php-console.php | 6 +- 174 files changed, 9840 insertions(+), 24 deletions(-) delete mode 100644 .gitmodules create mode 100644 composer.lock delete mode 160000 lib/php-console create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/installed.json create mode 100644 vendor/composer/installers/.editorconfig create mode 100644 vendor/composer/installers/.gitignore create mode 100644 vendor/composer/installers/.travis.yml create mode 100644 vendor/composer/installers/LICENSE create mode 100644 vendor/composer/installers/README.md create mode 100644 vendor/composer/installers/composer.json create mode 100644 vendor/composer/installers/phpunit.xml.dist create mode 100644 vendor/composer/installers/src/Composer/Installers/AglInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/BaseInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/ChefInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php create mode 100644 vendor/composer/installers/src/Composer/Installers/CraftInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/ElggInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/FuelInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/GravInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/HuradInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/Installer.php create mode 100644 vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MakoInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/OxidInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/PPIInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php create mode 100644 vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/TuskInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/ZendInstaller.php create mode 100644 vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php create mode 100644 vendor/composer/installers/src/bootstrap.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php create mode 100644 vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php create mode 100644 vendor/composer/installers/tests/bootstrap.php create mode 100644 vendor/php-console/php-console/LICENSE create mode 100644 vendor/php-console/php-console/README.md create mode 100644 vendor/php-console/php-console/composer.json create mode 100644 vendor/php-console/php-console/examples/features/complex_usage_example.php create mode 100644 vendor/php-console/php-console/examples/features/debug_vars.php create mode 100644 vendor/php-console/php-console/examples/features/eval_terminal.php create mode 100644 vendor/php-console/php-console/examples/features/handle_errors.php create mode 100644 vendor/php-console/php-console/examples/features/handle_javascript_errors.js create mode 100644 vendor/php-console/php-console/examples/features/handle_javascript_errors.php create mode 100644 vendor/php-console/php-console/examples/features/handle_on_redirect.php create mode 100644 vendor/php-console/php-console/examples/features/highload_optimization.php create mode 100644 vendor/php-console/php-console/examples/features/old_version_adapter.php create mode 100644 vendor/php-console/php-console/examples/features/protect_by_password.php create mode 100644 vendor/php-console/php-console/examples/index.php create mode 100644 vendor/php-console/php-console/examples/styles.css create mode 100644 vendor/php-console/php-console/examples/utils/build_phar.php create mode 100644 vendor/php-console/php-console/examples/utils/detect_headers_limit.php create mode 100644 vendor/php-console/php-console/examples/utils/test_jump_to_file.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Auth.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Connector.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Dispatcher.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Dispatcher/Debug.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Dispatcher/Errors.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Dispatcher/Evaluate.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Dumper.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/EvalProvider.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Handler.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Helper.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/OldVersionAdapter.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/PsrLogger.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Storage.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Storage/AllKeysList.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Storage/ExpiringKeyValue.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Storage/File.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Storage/Memcache.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/Storage/Session.php create mode 100644 vendor/php-console/php-console/src/PhpConsole/__autoload.php create mode 100644 vendor/php-console/php-console/tests/ClientEmulator/Connector.php create mode 100644 vendor/php-console/php-console/tests/ClientEmulator/Request.php create mode 100644 vendor/php-console/php-console/tests/ClientEmulator/Response.php create mode 100644 vendor/php-console/php-console/tests/README.md create mode 100644 vendor/php-console/php-console/tests/Test/Connector.php create mode 100644 vendor/php-console/php-console/tests/Test/Dispatcher.php create mode 100644 vendor/php-console/php-console/tests/Test/Dispatcher/Debug.php create mode 100644 vendor/php-console/php-console/tests/Test/Dispatcher/Errors.php create mode 100644 vendor/php-console/php-console/tests/Test/Dispatcher/Eval.php create mode 100644 vendor/php-console/php-console/tests/Test/Dumper.php create mode 100644 vendor/php-console/php-console/tests/Test/EvalProvider.php create mode 100644 vendor/php-console/php-console/tests/Test/Handler.php create mode 100644 vendor/php-console/php-console/tests/Test/Helper.php create mode 100644 vendor/php-console/php-console/tests/Test/PsrLogger.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/Auth.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/Connector.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/Evaluate.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/Handler.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/HandlerAfterConnector.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/HandlerBeforeConnector.php create mode 100644 vendor/php-console/php-console/tests/Test/Remote/Test.php create mode 100644 vendor/php-console/php-console/tests/Test/Storage.php create mode 100644 vendor/php-console/php-console/tests/Test/Storage/File.php create mode 100644 vendor/php-console/php-console/tests/Test/Storage/Memcache.php create mode 100644 vendor/php-console/php-console/tests/Test/Storage/Session.php create mode 100644 vendor/php-console/php-console/tests/Test/Test.php create mode 100644 vendor/php-console/php-console/tests/bootstrap.php create mode 100644 vendor/php-console/php-console/tests/composer.json create mode 100644 vendor/php-console/php-console/tests/config.php create mode 100644 vendor/php-console/php-console/tests/phpunit.xml create mode 100644 vendor/php-console/php-console/tests/scripts/dispatch_debug.php create mode 100644 vendor/php-console/php-console/tests/scripts/init_default_connector.php create mode 100644 vendor/php-console/php-console/tests/scripts/init_default_handler.php create mode 100644 vendor/php-console/php-console/tests/scripts/print.php create mode 100644 vendor/php-console/php-console/tests/scripts/set_connector_allowed_ip.php create mode 100644 vendor/php-console/php-console/tests/scripts/set_connector_auth.php create mode 100644 vendor/php-console/php-console/tests/scripts/set_connector_encoding.php create mode 100644 vendor/php-console/php-console/tests/scripts/set_connector_eval_enabled.php create mode 100644 vendor/php-console/php-console/tests/scripts/set_connector_ssl_only.php create mode 100644 vendor/php-console/php-console/tests/scripts/set_server_encoding.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_compile_error.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_exception.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_fatal_error.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_max_execution_time_error.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_memory_limit_error.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_not_fatal_errors.php create mode 100644 vendor/php-console/php-console/tests/scripts/trigger_parse_error.php create mode 100644 vendor/php-console/php-console/tests/server.php create mode 100644 vendor/php-console/php-console/tests/vendor/README.md diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 0d1a328..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/php-console"] - path = lib/php-console - url = git://github.com/barbushin/php-console diff --git a/ChangeLog.md b/ChangeLog.md index e53fdbb..1096566 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,6 @@ +### 1.2.0 (11 dec 2014) +* Updated dependencies and got rid of git submodules. + ### 1.1.0 (07 nov 2014) * Added donation link/button. * PHP Console server is now instantiated later, allowing to catch all your theme functions too. diff --git a/README.md b/README.md index f7849f3..97e9a19 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ This is an implementation of **[PHP Console](https://github.com/barbushin/php-console)** as a [WordPress](http://www.wordpress.org) plugin. - > PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things using [Google Chrome PHP Console extension](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) and [PhpConsole server library](https://github.com/barbushin/php-console). This implementation for WordPress allows you to test any WordPress specific function or class (including those introduced by your active theme and plugins!) from PHP Console terminal and inspect results, catch error and warnings with stack trace straight from Chrome Dev Tools console. @@ -14,23 +13,23 @@ Follow these steps: 1. First, install **[PHP Console for Google Chrome](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef)**. -2. Then, add this plugin to your WordPress installation (by placing it into your `wp-content/plugins/` directory). **Note:** If you are cloning or manually downloading this git repo from GitHub, make sure to init PHP Console git submodule (i.e. `lib\php-console` directory should not be empty - this step is not necessary if you happen to download this plugin from WordPress.org). +2. Then, add this plugin to your WordPress installation (by placing it into your `wp-content/plugins/` directory or corresponding plugins directory in your installation). -3. Once installed, activate WP PHP Console from WordPress plugins dashboard page; then go to `PHP Console` settings page from the `Settings` menu. From here you need to enter a password for the eval terminal (required, otherwise the eval terminal simply won't work). +3. Once installed, activate WP PHP Console from WordPress plugins dashboard page as you would do with any other plugin; then go to `PHP Console` settings page from the `Settings` menu. From here you need to enter a password for the eval terminal (required, otherwise the eval terminal simply won't work). You can also set other options. ### Options -In WP PHP Console settings page, you can also tick a checkbox to use the terminal only on a SSL connection (of course then if you don't have SSL the terminal simply won't work). You can also specify IP addresses to restrict the accessibility to the eval terminal (a single address eg. `192.168.0.4`; or an address mask eg. `192.168.*.*` or multiple IPs, comma separated `192.168.1.22,192.168.1.24,192.168.3.*`). +In WP PHP Console settings page, you can tick a checkbox to use the terminal only on a SSL connection (of course then if you don't actually have SSL, PHP Console simply won't work). You can also specify IP addresses to restrict the accessibility to the eval terminal (a single address eg. `192.168.0.4`; or an address mask eg. `192.168.*.*` or multiple IPs, comma separated `192.168.1.22,192.168.1.24,192.168.3.*`). In case of having issues in connecting with the PHP terminal, try entering a generic wildcard `*` in this field. ## Usage -Once you have set up a password, you can navigate any of your WordPress page (including WordPress admin) and try the console. You will se a "key" icon in your browser address bar. By clicking on it, it will prompt for the password you have set just before. After entering the correct password, you can use the eval terminal and run any PHP code from it, including WordPress own functions. Furthermore, in Chrome Dev Tools console you will also see printed any PHP errors, warnings, notices with stack trace, which will be useful to debug your plugin or theme. +Once you have set up a password, you can navigate any of your WordPress page (including WordPress admin dashboard pages) and try the console. You will se a "key" icon in your browser address bar. By clicking on it, it will prompt for the password you have set just before. After entering the correct password, you can use the eval terminal and run any PHP code from it, including WordPress own functions. Furthermore, in Chrome Dev Tools console you will also see printed any PHP errors, warnings, notices with stack trace, which will be useful to debug your plugin or theme. ### Caveats -You should not use this plugin or PHP Console library in a production environment, rather a development/testing environment. You will otherwise add more load to your server and even put your site at risk since you're exposing PHP code publicly. +You should NOT use this plugin or PHP Console library in a production environment, rather a development/testing environment. You will otherwise add more load to your server and even put your site at risk since you're exposing PHP code publicly. ### Browser support -Currently PHP Console only supports Google Chrome browser. If you're using for example Firefox or Opera this plugin won't be of much use to you at the moment. \ No newline at end of file +Currently PHP Console only supports Google Chrome browser. If you're using, developing or testing with Firefox or Opera this plugin won't be of much use to you at the moment. \ No newline at end of file diff --git a/README.txt b/README.txt index 33101de..d91bb5d 100644 --- a/README.txt +++ b/README.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: development, debug, debugging Requires at least: 3.0.1 Tested up to: 4.0 -Stable tag: 1.1.0 +Stable tag: 1.2.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -50,6 +50,9 @@ No it doesn't, unless PHP Console is ported as a Firefox add-on for example. == Changelog == += 1.2.0 = +* Updated dependencies + = 1.1.0 = * Added donation link/button. * PHP Console server is now instantiated later, allowing to catch all your theme functions too. diff --git a/composer.json b/composer.json index 35fd139..1b5cb59 100644 --- a/composer.json +++ b/composer.json @@ -1,14 +1,20 @@ { - "name": "nekojira/wp-php-console", + "name": "wp-php-console", "description": "A WordPress implementation of PHP Console.", - "version": "1.1.0", - "type": "wordpress-plugin", + "version": "1.2.0", "keywords": [ "wordpress", "debug", "debugging", - "development" + "development", + "php-console" ], "homepage": "https://github.com/nekojira/wp-php-console", - "license": "GPLv2 or later" + "license": "GPLv2 or later", + "type": "wordpress-plugin", + "require": { + "php": ">=5.3.2", + "composer/installers": "v1.0.19", + "php-console/php-console": "~3.1" + } } \ No newline at end of file diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..67b9832 --- /dev/null +++ b/composer.lock @@ -0,0 +1,166 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "86c8ec268ca8f47e7f1a2182bb112f55", + "packages": [ + { + "name": "composer/installers", + "version": "v1.0.19", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "89d77bfbee79e16653f7162c86e602cc188471db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/89d77bfbee79e16653f7162c86e602cc188471db", + "reference": "89d77bfbee79e16653f7162c86e602cc188471db", + "shasum": "" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + }, + "type": "composer-installer", + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Composer\\Installers\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "http://composer.github.com/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Hurad", + "MODX Evo", + "OXID", + "Thelia", + "WolfCMS", + "agl", + "annotatecms", + "bitrix", + "cakephp", + "chef", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "elgg", + "fuelphp", + "grav", + "installer", + "joomla", + "kohana", + "laravel", + "lithium", + "magento", + "mako", + "mediawiki", + "modulework", + "moodle", + "phpbb", + "piwik", + "ppi", + "puppet", + "roundcube", + "shopware", + "silverstripe", + "symfony", + "typo3", + "wordpress", + "zend", + "zikula" + ], + "time": "2014-11-29 01:29:17" + }, + { + "name": "php-console/php-console", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/barbushin/php-console.git", + "reference": "1e6ebef04363fa86ddab9f9998ce537147ab9636" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barbushin/php-console/zipball/1e6ebef04363fa86ddab9f9998ce537147ab9636", + "reference": "1e6ebef04363fa86ddab9f9998ce537147ab9636", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "php-console/laravel-service-provider": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-0": { + "PhpConsole": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD 3-Clause" + ], + "authors": [ + { + "name": "Sergey Barbushin", + "email": "barbushin@gmail.com", + "homepage": "http://linkedin.com/in/barbushin" + } + ], + "description": "Server side PHP library for Google Chrome extension \"PHP Console\".", + "homepage": "https://github.com/barbushin/php-console", + "keywords": [ + "chrome", + "debug", + "error handler", + "errors", + "google chrome", + "php" + ], + "time": "2014-02-03 13:42:12" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "platform": { + "php": ">=5.3.2" + }, + "platform-dev": [] +} diff --git a/lib/class-wp-php-console.php b/lib/class-wp-php-console.php index 6dc42ab..bc70879 100644 --- a/lib/class-wp-php-console.php +++ b/lib/class-wp-php-console.php @@ -3,7 +3,7 @@ /** * WP PHP Console Plugin Core Class * - * @link https://github.com/wp-php-console + * @link https://github.com/nekojira/wp-php-console * @since 1.0.0 * * @package WP_PHP_Console @@ -37,6 +37,14 @@ class WP_PHP_Console { */ protected $version; + /** + * Options. + * + * @since 1.0.0 + * @access protected + */ + protected $options; + /** * Construct. * @@ -46,6 +54,7 @@ public function __construct() { $this->plugin_name = 'wp-php-console'; $this->version = '1.1.0'; + $this->options = get_option( 'wp-php-console' ); add_action( 'plugins_loaded', array( $this, 'set_locale' ) ); add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); @@ -256,6 +265,9 @@ public function settings_info() { */ public function init() { + if ( ! class_exists( 'PhpConsole\Connector' ) ) + return; + $options = get_option( 'wp_php_console' ); $password = isset( $options['password'] ) ? $options['password'] : ''; @@ -269,12 +281,12 @@ public function init() { if ( PhpConsole\Handler::getInstance()->isStarted() != true ) $handler->start(); - $enableSslOnlyMode = isset( $options['ssl'] ) ? $options['ssl'] : ''; + $enableSslOnlyMode = isset( $options['ssl'] ) ? ( ! empty( $options['ssl'] ) ? $options['ssl'] : '' ) : ''; if ( $enableSslOnlyMode == true ) $connector->enableSslOnlyMode(); - $allowedIpMasks = isset( $options['ip'] ) ? explode( ',', $options['ip'] ) : ''; - if ( $allowedIpMasks ) + $allowedIpMasks = isset( $options['ip'] ) ? ( ! empty( $options['ip'] ) ? implode( ',', $options['ip'] ) : '' ) : ''; + if ( ! is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) ) $connector->setAllowedIpMasks( (array) $allowedIpMasks ); $evalProvider = $connector->getEvalDispatcher()->getEvalProvider(); diff --git a/lib/php-console b/lib/php-console deleted file mode 160000 index 888e538..0000000 --- a/lib/php-console +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 888e538de05cb5e5b5c5bb6669e322c0087cc8fb diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..c60d632 --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-0 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/php-console/php-console/src'), + 'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'), +); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..b265c64 --- /dev/null +++ b/vendor/composer/autoload_psr4.php @@ -0,0 +1,9 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + return $loader; + } +} + +function composerRequire2c64d051d18a1b25d2d528d8981e0274($file) +{ + require $file; +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..64fbe4f --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,153 @@ +[ + { + "name": "composer/installers", + "version": "v1.0.19", + "version_normalized": "1.0.19.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "89d77bfbee79e16653f7162c86e602cc188471db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/89d77bfbee79e16653f7162c86e602cc188471db", + "reference": "89d77bfbee79e16653f7162c86e602cc188471db", + "shasum": "" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + }, + "time": "2014-11-29 01:29:17", + "type": "composer-installer", + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Composer\\Installers\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "http://composer.github.com/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Hurad", + "MODX Evo", + "OXID", + "Thelia", + "WolfCMS", + "agl", + "annotatecms", + "bitrix", + "cakephp", + "chef", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "elgg", + "fuelphp", + "grav", + "installer", + "joomla", + "kohana", + "laravel", + "lithium", + "magento", + "mako", + "mediawiki", + "modulework", + "moodle", + "phpbb", + "piwik", + "ppi", + "puppet", + "roundcube", + "shopware", + "silverstripe", + "symfony", + "typo3", + "wordpress", + "zend", + "zikula" + ] + }, + { + "name": "php-console/php-console", + "version": "3.1.1", + "version_normalized": "3.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/barbushin/php-console.git", + "reference": "1e6ebef04363fa86ddab9f9998ce537147ab9636" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barbushin/php-console/zipball/1e6ebef04363fa86ddab9f9998ce537147ab9636", + "reference": "1e6ebef04363fa86ddab9f9998ce537147ab9636", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "php-console/laravel-service-provider": "*" + }, + "time": "2014-02-03 13:42:12", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "PhpConsole": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD 3-Clause" + ], + "authors": [ + { + "name": "Sergey Barbushin", + "email": "barbushin@gmail.com", + "homepage": "http://linkedin.com/in/barbushin" + } + ], + "description": "Server side PHP library for Google Chrome extension \"PHP Console\".", + "homepage": "https://github.com/barbushin/php-console", + "keywords": [ + "chrome", + "debug", + "error handler", + "errors", + "google chrome", + "php" + ] + } +] diff --git a/vendor/composer/installers/.editorconfig b/vendor/composer/installers/.editorconfig new file mode 100644 index 0000000..153cf3e --- /dev/null +++ b/vendor/composer/installers/.editorconfig @@ -0,0 +1,10 @@ +; top-most EditorConfig file +root = true + +; Unix-style newlines +[*] +end_of_line = LF + +[*.php] +indent_style = space +indent_size = 4 diff --git a/vendor/composer/installers/.gitignore b/vendor/composer/installers/.gitignore new file mode 100644 index 0000000..ff7f293 --- /dev/null +++ b/vendor/composer/installers/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +.idea/ diff --git a/vendor/composer/installers/.travis.yml b/vendor/composer/installers/.travis.yml new file mode 100644 index 0000000..81ca8e1 --- /dev/null +++ b/vendor/composer/installers/.travis.yml @@ -0,0 +1,14 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - curl -s http://getcomposer.org/installer | php -- --quiet + - php composer.phar install --dev + +script: phpunit diff --git a/vendor/composer/installers/LICENSE b/vendor/composer/installers/LICENSE new file mode 100644 index 0000000..85f97fc --- /dev/null +++ b/vendor/composer/installers/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Kyle Robinson Young + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/composer/installers/README.md b/vendor/composer/installers/README.md new file mode 100644 index 0000000..cd77d16 --- /dev/null +++ b/vendor/composer/installers/README.md @@ -0,0 +1,187 @@ +# A Multi-Framework [Composer](http://getcomposer.org) Library Installer + +[![Build Status](http://img.shields.io/travis/composer/installers.svg)](http://travis-ci.org/composer/installers) + +This is for PHP package authors to require in their `composer.json`. It will +install their package to the correct location based on the specified package +type. + +The goal of `installers` is to be a simple package type to install path map. +Users can also customize the install path per package and package authors can +modify the package name upon installing. + +`installers` isn't intended on replacing all custom installers. If your +package requires special installation handling then by all means, create a +custom installer to handle it. + +**Natively Supported Frameworks**: + +The following frameworks natively work with Composer and will be +installed to the default `vendor` directory. `composer/installers` +is not needed to install packages with these frameworks: + +* Aura +* Symfony2 +* Yii +* Yii2 + +**Current Supported Package Types**: + +> Stable types are marked as **bold**, this means that installation paths +> for those type will not be changed. Any adjustment for those types would +> require creation of brand new type that will cover required changes. + +| Framework | Types +| --------- | ----- +| Asgard | `asgard-module`
`asgard-theme` +| AGL | `agl-module` +| AnnotateCms | `annotatecms-module`
`annotatecms-component`
`annotatecms-service` +| Bitrix | `bitrix-module`
`bitrix-component`
`bitrix-theme` +| CakePHP 2+ | **`cakephp-plugin`** +| Chef | `chef-recipe`
`chef-role` +| CodeIgniter | `codeigniter-library`
`codeigniter-third-party`
`codeigniter-module` +| concrete5 | `concrete5-block`
`concrete5-package`
`concrete5-theme`
`concrete5-update` +| Craft | `craft-plugin` +| Croogo | `croogo-plugin`
`croogo-theme` +| DokuWiki | `dokuwiki-plugin`
`dokuwiki-template` +| Dolibarr | `dolibarr-module` +| Drupal | `drupal-module`
`drupal-theme`

`drupal-library`
`drupal-profile`
`drupal-drush` +| Elgg | `elgg-plugin` +| FuelPHP v1.x | `fuel-module`
`fuel-package`
`fuel-theme` +| FuelPHP v2.x | `fuelphp-component` +| Grav | `grav-plugin`
`grav-theme` +| Hurad | `hurad-plugin`
`hurad-theme` +| Joomla | `joomla-component`
`joomla-module`
`joomla-template`
`joomla-plugin`
`joomla-library` +| Kirby | **`kirby-plugin`** +| Kohana | **`kohana-module`** +| Laravel | `laravel-library` +| Lithium | **`lithium-library`
`lithium-source`** +| Magento | `magento-library`
`magento-skin`
`magento-theme` +| Mako | `mako-package` +| MODX Evo | `modxevo-snippet`
`modxevo-plugin`
`modxevo-module`
`modxevo-template`
`modxevo-lib` +| MediaWiki | `mediawiki-extension` +| October | **`october-module`
`october-plugin`
`october-theme`** +| OXID | `oxid-module`
`oxid-theme`
`oxid-out` +| MODULEWork | `modulework-module` +| Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types) +| Piwik | `piwik-plugin` +| phpBB | `phpbb-extension`
`phpbb-style`
`phpbb-language` +| Pimcore | `pimcore-plugin` +| PPI | **`ppi-module`** +| Puppet | `puppet-module` +| REDAXO | `redaxo-addon` +| Roundcube | `roundcube-plugin` +| shopware | `shopware-backend-plugin`
`shopware-core-plugin`
`shopware-frontend-plugin`
`shopware-theme` +| SilverStripe | `silverstripe-module`
`silverstripe-theme` +| symfony1 | **`symfony1-plugin`** +| Tusk | `tusk-task`
`tusk-command`
`tusk-asset` +| TYPO3 Flow | `typo3-flow-package`
`typo3-flow-framework`
`typo3-flow-plugin`
`typo3-flow-site`
`typo3-flow-boilerplate`
`typo3-flow-build` +| TYPO3 CMS | `typo3-cms-extension` +| Wolf CMS | `wolfcms-plugin` +| WordPress | `wordpress-plugin`
`wordpress-theme`

`wordpress-muplugin` +| Zend | `zend-library`
`zend-extra`
`zend-module` +| Zikula | `zikula-module`
`zikula-theme` + +## Example `composer.json` File + +This is an example for a CakePHP plugin. The only important parts to set in your +composer.json file are `"type": "cakephp-plugin"` which describes what your +package is and `"require": { "composer/installers": "~1.0" }` which tells composer +to load the custom installers. + +```json +{ + "name": "you/ftp", + "type": "cakephp-plugin", + "require": { + "composer/installers": "~1.0" + } +} +``` + +This would install your package to the `Plugin/Ftp/` folder of a CakePHP app +when a user runs `php composer.phar install`. + +So submit your packages to [packagist.org](http://packagist.org)! + +## Custom Install Paths + +If you are consuming a package that uses the `composer/installers` you can +override the install path with the following extra in your `composer.json`: + +```json +{ + "extra": { + "installer-paths": { + "your/custom/path/{$name}/": ["shama/ftp", "vendor/package"] + } + } +} +``` + +A package type can have a custom installation path with a `type:` prefix. + +``` json +{ + "extra": { + "installer-paths": { + "your/custom/path/{$name}/": ["type:wordpress-plugin"] + } + } +} +``` + +This would use your custom path for each of the listed packages. The available +variables to use in your paths are: `{$name}`, `{$vendor}`, `{$type}`. + +## Custom Install Names + +If you're a package author and need your package to be named differently when +installed consider using the `installer-name` extra. + +For example you have a package named `shama/cakephp-ftp` with the type +`cakephp-plugin`. Installing with `composer/installers` would install to the +path `Plugin/CakephpFtp`. Due to the strict naming conventions, you as a +package author actually need the package to be named and installed to +`Plugin/Ftp`. Using the following config within your **package** `composer.json` +will allow this: + +```json +{ + "name": "shama/cakephp-ftp", + "type": "cakephp-plugin", + "extra": { + "installer-name": "Ftp" + } +} +``` + +Please note the name entered into `installer-name` will be the final and will +not be inflected. + +## Contribute! + +* [Fork and clone](https://help.github.com/articles/fork-a-repo). +* Run the command `php composer.phar install --dev` to install the dev + dependencies. See [Composer](https://github.com/composer/composer#installation--usage). +* Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de). +* Create a branch, commit, push and send us a + [pull request](https://help.github.com/articles/using-pull-requests). + +To ensure a consistent code base, you should make sure the code follows the +[Coding Standards](http://symfony.com/doc/2.0/contributing/code/standards.html) +which we borrowed from Symfony. + +If you would like to help, please take a look at the list of +[issues](https://github.com/composer/installers/issues). + +### Should we allow dynamic package types or paths? No. +What are they? The ability for a package author to determine where a package +will be installed either through setting the path directly in their +`composer.json` or through a dynamic package type: `"type": +"framework-install-here"`. + +It has been proposed many times. Even implemented once early on and then +removed. `installers` won't do this because it would allow a single package +author to wipe out entire folders without the user's consent. That user would +then come here to yell at us. diff --git a/vendor/composer/installers/composer.json b/vendor/composer/installers/composer.json new file mode 100644 index 0000000..15fee6e --- /dev/null +++ b/vendor/composer/installers/composer.json @@ -0,0 +1,75 @@ +{ + "name": "composer/installers", + "type": "composer-installer", + "license": "MIT", + "description": "A multi-framework Composer library installer", + "keywords": [ + "installer", + "AGL", + "AnnotateCms", + "Bitrix", + "CakePHP", + "Chef", + "CodeIgniter", + "concrete5", + "Craft", + "Croogo", + "DokuWiki", + "Dolibarr", + "Drupal", + "Elgg", + "FuelPHP", + "Grav", + "Hurad", + "Joomla", + "Kohana", + "Laravel", + "Lithium", + "Magento", + "Mako", + "MODX Evo", + "MediaWiki", + "OXID", + "MODULEWork", + "Moodle", + "Piwik", + "phpBB", + "PPI", + "Puppet", + "Roundcube", + "shopware", + "SilverStripe", + "symfony", + "Thelia", + "TYPO3", + "WolfCMS", + "WordPress", + "Zend", + "Zikula" + ], + "homepage": "http://composer.github.com/installers/", + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "autoload": { + "psr-0": { "Composer\\Installers\\": "src/" } + }, + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "replace": { + "shama/baton": "*", + "roundcube/plugin-installer": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + } +} diff --git a/vendor/composer/installers/phpunit.xml.dist b/vendor/composer/installers/phpunit.xml.dist new file mode 100644 index 0000000..cc5cc99 --- /dev/null +++ b/vendor/composer/installers/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + tests/Composer/Installers + + + + + + src/Composer/Installers + + + \ No newline at end of file diff --git a/vendor/composer/installers/src/Composer/Installers/AglInstaller.php b/vendor/composer/installers/src/Composer/Installers/AglInstaller.php new file mode 100644 index 0000000..01b8a41 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AglInstaller.php @@ -0,0 +1,21 @@ + 'More/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) { + return strtoupper($matches[1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php b/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php new file mode 100644 index 0000000..89d7ad9 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php @@ -0,0 +1,11 @@ + 'addons/modules/{$name}/', + 'component' => 'addons/components/{$name}/', + 'service' => 'addons/services/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php b/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php new file mode 100644 index 0000000..995ee2b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php @@ -0,0 +1,45 @@ + 'Modules/{$name}/', + 'theme' => 'Themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type asgard-module, cut off a trailing '-plugin' if present. + * + * For package type asgard-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'asgard-module') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'asgard-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php b/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php new file mode 100644 index 0000000..cc27d3e --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php @@ -0,0 +1,131 @@ +composer = $composer; + $this->package = $package; + } + + /** + * Return the install path based on package type. + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $type = $this->package->getType(); + + $prettyName = $this->package->getPrettyName(); + if (strpos($prettyName, '/') !== false) { + list($vendor, $name) = explode('/', $prettyName); + } else { + $vendor = ''; + $name = $prettyName; + } + + $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); + + $extra = $package->getExtra(); + if (!empty($extra['installer-name'])) { + $availableVars['name'] = $extra['installer-name']; + } + + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + if (!empty($extra['installer-paths'])) { + $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type); + if ($customPath !== false) { + return $this->templatePath($customPath, $availableVars); + } + } + } + + $packageType = substr($type, strlen($frameworkType) + 1); + $locations = $this->getLocations(); + if (!isset($locations[$packageType])) { + throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); + } + + return $this->templatePath($locations[$packageType], $availableVars); + } + + /** + * For an installer to override to modify the vars per installer. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + return $vars; + } + + /** + * Gets the installer's locations + * + * @return array + */ + public function getLocations() + { + return $this->locations; + } + + /** + * Replace vars in a path + * + * @param string $path + * @param array $vars + * @return string + */ + protected function templatePath($path, array $vars = array()) + { + if (strpos($path, '{') !== false) { + extract($vars); + preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); + if (!empty($matches[1])) { + foreach ($matches[1] as $var) { + $path = str_replace('{$' . $var . '}', $$var, $path); + } + } + } + + return $path; + } + + /** + * Search through a passed paths array for a custom install path. + * + * @param array $paths + * @param string $name + * @param string $type + * @return string + */ + protected function mapCustomInstallPaths(array $paths, $name, $type) + { + foreach ($paths as $path => $names) { + if (in_array($name, $names) || in_array('type:' . $type, $names)) { + return $path; + } + } + + return false; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php b/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php new file mode 100644 index 0000000..48a8367 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php @@ -0,0 +1,11 @@ + 'local/modules/{$name}/', + 'component' => 'local/components/{$name}/', + 'theme' => 'local/templates/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php b/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php new file mode 100644 index 0000000..df91a12 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php @@ -0,0 +1,145 @@ + 'Plugin/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + + return $vars; + } + + /** + * Change the default plugin location when cakephp >= 3.0 + */ + public function getLocations() + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + $this->locations['plugin'] = 'plugins/{$name}/'; + } + return $this->locations; + } + + /** + * Add installer-name for CakePHP >= 3.0.0 + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $extra = $package->getExtra(); + if (empty($extra['installer-name']) && $this->matchesCakeVersion('>=', '3.0.0')) { + $this->setInstallerName($package); + } + return parent::getInstallPath($package, $frameworkType); + } + + /** + * Check if CakePHP version matches against a version + * + * @param string $matcher + * @param string $version + * @return bool + */ + protected function matchesCakeVersion($matcher, $version) + { + $repositoryManager = $this->composer->getRepositoryManager(); + if ($repositoryManager) { + $repos = $repositoryManager->getLocalRepository(); + if (!$repos) { + return false; + } + $cake3 = new MultiConstraint(array( + new VersionConstraint($matcher, $version), + new VersionConstraint('!=', '9999999-dev'), + )); + $pool = new Pool('dev'); + $pool->addRepository($repos); + $packages = $pool->whatProvides('cakephp/cakephp'); + foreach ($packages as $package) { + $installed = new VersionConstraint('=', $package->getVersion()); + if ($cake3->matches($installed)) { + return true; + break; + } + } + } + return false; + } + + /** + * Set installer-name based on namespace for the source path checking in + * following order: + * + * - With only one autoload path the namespace for that path will be used. + * - With multiple paths if path 'src' exists it's namespace will be used. + * - With two autoload paths provided, the namespace of path other than + * 'tests' will be used. + * + * No installer-name is set if PSR-4 autoload block is not found or if none + * of the above conditions are met. + * + * @param PackageInterface $package + */ + protected function setInstallerName(PackageInterface $package) + { + $primaryNS = null; + $autoLoad = $package->getAutoload(); + foreach ($autoLoad as $type => $typeConfig) { + if ($type !== 'psr-4') { + continue; + } + $count = count($typeConfig); + + if ($count === 1) { + $primaryNS = key($typeConfig); + break; + } + + $matches = preg_grep('#^(\./)?src/?$#', $typeConfig); + if ($matches) { + $primaryNS = key($matches); + break; + } + + if ($count === 2) { + reset($typeConfig); + if (preg_match('#^(\./)?tests/?$#', current($typeConfig))) { + next($typeConfig); + } + $primaryNS = key($typeConfig); + break; + } + + break; + } + + if ($primaryNS) { + $package->setExtra(array( + 'installer-name' => trim(str_replace('\\', '/', $primaryNS), '/') + )); + } + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php b/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php new file mode 100644 index 0000000..ab2f9aa --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php @@ -0,0 +1,11 @@ + 'Chef/{$vendor}/{$name}/', + 'role' => 'Chef/roles/{$name}/', + ); +} + diff --git a/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php b/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php new file mode 100644 index 0000000..3b4a4ec --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php @@ -0,0 +1,11 @@ + 'application/libraries/{$name}/', + 'third-party' => 'application/third_party/{$name}/', + 'module' => 'application/modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php b/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php new file mode 100644 index 0000000..4d398a4 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php @@ -0,0 +1,12 @@ + 'blocks/{$name}/', + 'package' => 'packages/{$name}/', + 'theme' => 'themes/{$name}/', + 'update' => 'updates/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php b/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php new file mode 100644 index 0000000..dc3be8d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php @@ -0,0 +1,9 @@ + 'craft/plugins/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php b/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php new file mode 100644 index 0000000..d94219d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php @@ -0,0 +1,21 @@ + 'Plugin/{$name}/', + 'theme' => 'View/Themed/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name'])); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php b/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php new file mode 100644 index 0000000..cfd638d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php @@ -0,0 +1,50 @@ + 'lib/plugins/{$name}/', + 'template' => 'lib/tpl/{$name}/', + ); + + /** + * Format package name. + * + * For package type dokuwiki-plugin, cut off a trailing '-plugin', + * or leading dokuwiki_ if present. + * + * For package type dokuwiki-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'dokuwiki-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'dokuwiki-template') { + return $this->inflectTemplateVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php b/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php new file mode 100644 index 0000000..21f7e8e --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php @@ -0,0 +1,16 @@ + + */ +class DolibarrInstaller extends BaseInstaller +{ + //TODO: Add support for scripts and themes + protected $locations = array( + 'module' => 'htdocs/custom/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php b/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php new file mode 100644 index 0000000..522606a --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php @@ -0,0 +1,13 @@ + 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + 'library' => 'libraries/{$name}/', + 'profile' => 'profiles/{$name}/', + 'drush' => 'drush/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php b/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php new file mode 100644 index 0000000..c0bb609 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php @@ -0,0 +1,9 @@ + 'mod/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php b/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php new file mode 100644 index 0000000..6eba2e3 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php @@ -0,0 +1,11 @@ + 'fuel/app/modules/{$name}/', + 'package' => 'fuel/packages/{$name}/', + 'theme' => 'fuel/app/themes/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php b/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php new file mode 100644 index 0000000..29d980b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php @@ -0,0 +1,9 @@ + 'components/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/GravInstaller.php b/vendor/composer/installers/src/Composer/Installers/GravInstaller.php new file mode 100644 index 0000000..dbe63e0 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/GravInstaller.php @@ -0,0 +1,30 @@ + 'user/plugins/{$name}/', + 'theme' => 'user/themes/{$name}/', + ); + + /** + * Format package name + * + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $restrictedWords = implode('|', array_keys($this->locations)); + + $vars['name'] = strtolower($vars['name']); + $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', + '$1', + $vars['name'] + ); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php b/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php new file mode 100644 index 0000000..8fe017f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php @@ -0,0 +1,25 @@ + 'plugins/{$name}/', + 'theme' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/Installer.php b/vendor/composer/installers/src/Composer/Installers/Installer.php new file mode 100644 index 0000000..084ff62 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Installer.php @@ -0,0 +1,159 @@ + 'AsgardInstaller', + 'agl' => 'AglInstaller', + 'annotatecms' => 'AnnotateCmsInstaller', + 'bitrix' => 'BitrixInstaller', + 'cakephp' => 'CakePHPInstaller', + 'chef' => 'ChefInstaller', + 'codeigniter' => 'CodeIgniterInstaller', + 'concrete5' => 'Concrete5Installer', + 'craft' => 'CraftInstaller', + 'croogo' => 'CroogoInstaller', + 'dokuwiki' => 'DokuWikiInstaller', + 'dolibarr' => 'DolibarrInstaller', + 'drupal' => 'DrupalInstaller', + 'elgg' => 'ElggInstaller', + 'fuel' => 'FuelInstaller', + 'fuelphp' => 'FuelphpInstaller', + 'grav' => 'GravInstaller', + 'hurad' => 'HuradInstaller', + 'joomla' => 'JoomlaInstaller', + 'kirby' => 'KirbyInstaller', + 'kohana' => 'KohanaInstaller', + 'laravel' => 'LaravelInstaller', + 'lithium' => 'LithiumInstaller', + 'magento' => 'MagentoInstaller', + 'mako' => 'MakoInstaller', + 'mediawiki' => 'MediaWikiInstaller', + 'microweber' => 'MicroweberInstaller', + 'modulework' => 'MODULEWorkInstaller', + 'modxevo' => 'MODXEvoInstaller', + 'moodle' => 'MoodleInstaller', + 'october' => 'OctoberInstaller', + 'oxid' => 'OxidInstaller', + 'phpbb' => 'PhpBBInstaller', + 'pimcore' => 'PimcoreInstaller', + 'piwik' => 'PiwikInstaller', + 'ppi' => 'PPIInstaller', + 'puppet' => 'PuppetInstaller', + 'redaxo' => 'RedaxoInstaller', + 'roundcube' => 'RoundcubeInstaller', + 'shopware' => 'ShopwareInstaller', + 'silverstripe' => 'SilverStripeInstaller', + 'symfony1' => 'Symfony1Installer', + 'thelia' => 'TheliaInstaller', + 'tusk' => 'TuskInstaller', + 'typo3-cms' => 'TYPO3CmsInstaller', + 'typo3-flow' => 'TYPO3FlowInstaller', + 'whmcs' => 'WHMCSInstaller', + 'wolfcms' => 'WolfCMSInstaller', + 'wordpress' => 'WordPressInstaller', + 'zend' => 'ZendInstaller', + 'zikula' => 'ZikulaInstaller', + ); + + /** + * {@inheritDoc} + */ + public function getInstallPath(PackageInterface $package) + { + $type = $package->getType(); + $frameworkType = $this->findFrameworkType($type); + + if ($frameworkType === false) { + throw new \InvalidArgumentException( + 'Sorry the package type of this package is not yet supported.' + ); + } + + $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + $installer = new $class($package, $this->composer); + + return $installer->getInstallPath($package, $frameworkType); + } + + public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) + { + if (!$repo->hasPackage($package)) { + throw new \InvalidArgumentException('Package is not installed: '.$package); + } + + $repo->removePackage($package); + + $installPath = $this->getInstallPath($package); + $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? 'deleted' : 'not deleted')); + } + + /** + * {@inheritDoc} + */ + public function supports($packageType) + { + $frameworkType = $this->findFrameworkType($packageType); + + if ($frameworkType === false) { + return false; + } + + $locationPattern = $this->getLocationPattern($frameworkType); + + return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; + } + + /** + * Finds a supported framework type if it exists and returns it + * + * @param string $type + * @return string + */ + protected function findFrameworkType($type) + { + $frameworkType = false; + + krsort($this->supportedTypes); + + foreach ($this->supportedTypes as $key => $val) { + if ($key === substr($type, 0, strlen($key))) { + $frameworkType = substr($type, 0, strlen($key)); + break; + } + } + + return $frameworkType; + } + + /** + * Get the second part of the regular expression to check for support of a + * package type + * + * @param string $frameworkType + * @return string + */ + protected function getLocationPattern($frameworkType) + { + $pattern = false; + if (!empty($this->supportedTypes[$frameworkType])) { + $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + /** @var BaseInstaller $framework */ + $framework = new $frameworkClass(null, $this->composer); + $locations = array_keys($framework->getLocations()); + $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; + } + + return $pattern ? : '(\w+)'; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php b/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php new file mode 100644 index 0000000..9ee7759 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php @@ -0,0 +1,15 @@ + 'components/{$name}/', + 'module' => 'modules/{$name}/', + 'template' => 'templates/{$name}/', + 'plugin' => 'plugins/{$name}/', + 'library' => 'libraries/{$name}/', + ); + + // TODO: Add inflector for mod_ and com_ names +} diff --git a/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php b/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php new file mode 100644 index 0000000..ae7ba8a --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php @@ -0,0 +1,9 @@ + 'site/plugins/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php b/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php new file mode 100644 index 0000000..dcd6d26 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php b/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php new file mode 100644 index 0000000..be4d53a --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php @@ -0,0 +1,9 @@ + 'libraries/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php b/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php new file mode 100644 index 0000000..47bbd4c --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php @@ -0,0 +1,10 @@ + 'libraries/{$name}/', + 'source' => 'libraries/_source/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php b/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php new file mode 100644 index 0000000..9c2e9fb --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php b/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php new file mode 100644 index 0000000..5a66460 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php @@ -0,0 +1,16 @@ + 'assets/snippets/{$name}/', + 'plugin' => 'assets/plugins/{$name}/', + 'module' => 'assets/modules/{$name}/', + 'template' => 'assets/templates/{$name}/', + 'lib' => 'assets/lib/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php b/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php new file mode 100644 index 0000000..cf18e94 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php @@ -0,0 +1,11 @@ + 'app/design/frontend/{$name}/', + 'skin' => 'skin/frontend/default/{$name}/', + 'library' => 'lib/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php b/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php new file mode 100644 index 0000000..ca3cfac --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php @@ -0,0 +1,9 @@ + 'app/packages/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php b/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php new file mode 100644 index 0000000..01008c6 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php @@ -0,0 +1,50 @@ + 'extensions/{$name}/', + 'skin' => 'skins/{$name}/', + ); + + /** + * Format package name. + * + * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform + * to CamelCase keeping existing uppercase chars. + * + * For package type mediawiki-skin, cut off a trailing '-skin' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'mediawiki-extension') { + return $this->inflectExtensionVars($vars); + } + + if ($vars['type'] === 'mediawiki-skin') { + return $this->inflectSkinVars($vars); + } + + return $vars; + } + + protected function inflectExtensionVars($vars) + { + $vars['name'] = preg_replace('/-extension$/', '', $vars['name']); + $vars['name'] = str_replace('-', ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + + return $vars; + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php b/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php new file mode 100644 index 0000000..4bbbec8 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php @@ -0,0 +1,111 @@ + 'userfiles/modules/{$name}/', + 'module-skin' => 'userfiles/modules/{$name}/templates/', + 'template' => 'userfiles/templates/{$name}/', + 'element' => 'userfiles/elements/{$name}/', + 'vendor' => 'vendor/{$name}/', + 'components' => 'components/{$name}/' + ); + + /** + * Format package name. + * + * For package type microweber-module, cut off a trailing '-module' if present + * + * For package type microweber-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'microweber-template') { + return $this->inflectTemplateVars($vars); + } + if ($vars['type'] === 'microweber-templates') { + return $this->inflectTemplatesVars($vars); + } + if ($vars['type'] === 'microweber-core') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-adapter') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-module') { + return $this->inflectModuleVars($vars); + } + if ($vars['type'] === 'microweber-modules') { + return $this->inflectModulesVars($vars); + } + if ($vars['type'] === 'microweber-skin') { + return $this->inflectSkinVars($vars); + } + if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { + return $this->inflectElementVars($vars); + } + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/template-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplatesVars($vars) + { + $vars['name'] = preg_replace('/-templates$/', '', $vars['name']); + $vars['name'] = preg_replace('/templates-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectCoreVars($vars) + { + $vars['name'] = preg_replace('/-providers$/', '', $vars['name']); + $vars['name'] = preg_replace('/-provider$/', '', $vars['name']); + $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = preg_replace('/module-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModulesVars($vars) + { + $vars['name'] = preg_replace('/-modules$/', '', $vars['name']); + $vars['name'] = preg_replace('/modules-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + $vars['name'] = preg_replace('/skin-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectElementVars($vars) + { + $vars['name'] = preg_replace('/-elements$/', '', $vars['name']); + $vars['name'] = preg_replace('/elements-$/', '', $vars['name']); + $vars['name'] = preg_replace('/-element$/', '', $vars['name']); + $vars['name'] = preg_replace('/element-$/', '', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php b/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php new file mode 100644 index 0000000..04be73c --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php @@ -0,0 +1,47 @@ + 'mod/{$name}/', + 'admin_report' => 'admin/report/{$name}/', + 'tool' => 'admin/tool/{$name}/', + 'assignment' => 'mod/assignment/type/{$name}/', + 'assignsubmission' => 'mod/assign/submission/{$name}/', + 'assignfeedback' => 'mod/assign/feedback/{$name}/', + 'auth' => 'auth/{$name}/', + 'availability' => 'availability/condition/{$name}/', + 'block' => 'blocks/{$name}/', + 'calendartype' => 'calendar/type/{$name}/', + 'format' => 'course/format/{$name}/', + 'coursereport' => 'course/report/{$name}/', + 'datafield' => 'mod/data/field/{$name}/', + 'datapreset' => 'mod/data/preset/{$name}/', + 'editor' => 'lib/editor/{$name}/', + 'enrol' => 'enrol/{$name}/', + 'filter' => 'filter/{$name}/', + 'gradeexport' => 'grade/export/{$name}/', + 'gradeimport' => 'grade/import/{$name}/', + 'gradereport' => 'grade/report/{$name}/', + 'gradingform' => 'grade/grading/form/{$name}/', + 'local' => 'local/{$name}/', + 'message' => 'message/output/{$name}/', + 'plagiarism' => 'plagiarism/{$name}/', + 'portfolio' => 'portfolio/{$name}/', + 'qbehaviour' => 'question/behaviour/{$name}/', + 'qformat' => 'question/format/{$name}/', + 'qtype' => 'question/type/{$name}/', + 'quizaccess' => 'mod/quiz/accessrule/{$name}/', + 'quiz' => 'mod/quiz/report/{$name}/', + 'report' => 'report/{$name}/', + 'repository' => 'repository/{$name}/', + 'scormreport' => 'mod/scorm/report/{$name}/', + 'theme' => 'theme/{$name}/', + 'profilefield' => 'user/profile/field/{$name}/', + 'webservice' => 'webservice/{$name}/', + 'workshopallocation' => 'mod/workshop/allocation/{$name}/', + 'workshopeval' => 'mod/workshop/eval/{$name}/', + 'workshopform' => 'mod/workshop/form/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php b/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php new file mode 100644 index 0000000..6bf53fd --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php @@ -0,0 +1,46 @@ + 'modules/{$name}/', + 'plugin' => 'plugins/{$vendor}/{$name}/', + 'theme' => 'themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type october-plugin, cut off a trailing '-plugin' if present. + * + * For package type october-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'october-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'october-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + + return $vars; + } +} \ No newline at end of file diff --git a/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php b/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php new file mode 100644 index 0000000..22fb56a --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php @@ -0,0 +1,11 @@ + 'modules/{$name}/', + 'theme' => 'application/views/{$name}/', + 'out' => 'out/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php b/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php new file mode 100644 index 0000000..170136f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php b/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php new file mode 100644 index 0000000..deb2b77 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php @@ -0,0 +1,11 @@ + 'ext/{$vendor}/{$name}/', + 'language' => 'language/{$name}/', + 'style' => 'styles/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php b/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php new file mode 100644 index 0000000..4781fa6 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php @@ -0,0 +1,21 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php b/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php new file mode 100644 index 0000000..c17f457 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php @@ -0,0 +1,32 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php b/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php new file mode 100644 index 0000000..77cc3dd --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php @@ -0,0 +1,11 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php b/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php new file mode 100644 index 0000000..0954457 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php @@ -0,0 +1,10 @@ + 'redaxo/include/addons/{$name}/', + 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php b/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php new file mode 100644 index 0000000..d8d795b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php @@ -0,0 +1,22 @@ + 'plugins/{$name}/', + ); + + /** + * Lowercase name and changes the name to a underscores + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace('-', '_', $vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php b/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php new file mode 100644 index 0000000..673f1fc --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php @@ -0,0 +1,58 @@ + 'engine/Shopware/Plugins/Local/Backend/{$name}/', + 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/', + 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/', + 'theme' => 'templates/{$name}/' + ); + + /** + * Transforms the names + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'shopware-theme') { + return $this->correctThemeName($vars); + } else { + return $this->correctPluginName($vars); + } + } + + /** + * Changes the name to a camelcased combination of vendor and name + * @param array $vars + * @return array + */ + private function correctPluginName($vars) + { + $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName); + + return $vars; + } + + /** + * Changes the name to a underscore separated name + * @param array $vars + * @return array + */ + private function correctThemeName($vars) + { + $vars['name'] = str_replace('-', '_', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php b/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php new file mode 100644 index 0000000..17ca543 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php @@ -0,0 +1,36 @@ + '{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Return the install path based on package type. + * + * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework + * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0 + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + if ( + $package->getName() == 'silverstripe/framework' + && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion()) + && version_compare($package->getVersion(), '2.999.999') < 0 + ) { + return $this->templatePath($this->locations['module'], array('name' => 'sapphire')); + } else { + return parent::getInstallPath($package, $frameworkType); + } + + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php b/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php new file mode 100644 index 0000000..1675c4f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php @@ -0,0 +1,26 @@ + + */ +class Symfony1Installer extends BaseInstaller +{ + protected $locations = array( + 'plugin' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php b/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php new file mode 100644 index 0000000..8220b40 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php @@ -0,0 +1,14 @@ + + */ +class TYPO3CmsInstaller extends BaseInstaller +{ + protected $locations = array( + 'extension' => 'typo3conf/ext/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php b/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php new file mode 100644 index 0000000..42572f4 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php @@ -0,0 +1,38 @@ + 'Packages/Application/{$name}/', + 'framework' => 'Packages/Framework/{$name}/', + 'plugin' => 'Packages/Plugins/{$name}/', + 'site' => 'Packages/Sites/{$name}/', + 'boilerplate' => 'Packages/Boilerplates/{$name}/', + 'build' => 'Build/{$name}/', + ); + + /** + * Modify the package name to be a TYPO3 Flow style key. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $autoload = $this->package->getAutoload(); + if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) { + $namespace = key($autoload['psr-0']); + $vars['name'] = str_replace('\\', '.', $namespace); + } + if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) { + $namespace = key($autoload['psr-4']); + $vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.'); + } + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php b/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php new file mode 100644 index 0000000..158af52 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php @@ -0,0 +1,12 @@ + 'local/modules/{$name}/', + 'frontoffice-template' => 'templates/frontOffice/{$name}/', + 'backoffice-template' => 'templates/backOffice/{$name}/', + 'email-template' => 'templates/email/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php b/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php new file mode 100644 index 0000000..7c0113b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php @@ -0,0 +1,14 @@ + + */ + class TuskInstaller extends BaseInstaller + { + protected $locations = array( + 'task' => '.tusk/tasks/{$name}/', + 'command' => '.tusk/commands/{$name}/', + 'asset' => 'assets/tusk/{$name}/', + ); + } diff --git a/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php b/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php new file mode 100644 index 0000000..2cbb4a4 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php @@ -0,0 +1,10 @@ + 'modules/gateways/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php b/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php new file mode 100644 index 0000000..cb38788 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php @@ -0,0 +1,9 @@ + 'wolf/plugins/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php b/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php new file mode 100644 index 0000000..b03219c --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php @@ -0,0 +1,11 @@ + 'wp-content/plugins/{$name}/', + 'theme' => 'wp-content/themes/{$name}/', + 'muplugin' => 'wp-content/mu-plugins/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php b/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php new file mode 100644 index 0000000..bde9bc8 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php @@ -0,0 +1,11 @@ + 'library/{$name}/', + 'extra' => 'extras/library/{$name}/', + 'module' => 'module/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php b/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php new file mode 100644 index 0000000..56cdf5d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$vendor}-{$name}/', + 'theme' => 'themes/{$vendor}-{$name}/' + ); +} diff --git a/vendor/composer/installers/src/bootstrap.php b/vendor/composer/installers/src/bootstrap.php new file mode 100644 index 0000000..0de276e --- /dev/null +++ b/vendor/composer/installers/src/bootstrap.php @@ -0,0 +1,13 @@ +installer = new AsgardInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)), + array('name' => $expected, 'type' => $type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'asgard-module', + 'asgard-module', + 'Asgard' + ), + array( + 'asgard-module', + 'blog', + 'Blog' + ), + // tests that exactly one '-theme' is cut off + array( + 'asgard-theme', + 'some-theme-theme', + 'Some-theme', + ), + // tests that names without '-theme' suffix stay valid + array( + 'asgard-theme', + 'someothertheme', + 'Someothertheme', + ), + ); + } +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php new file mode 100644 index 0000000..3b15ea4 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php @@ -0,0 +1,163 @@ +package = new Package('CamelCased', '1.0', '1.0'); + $this->io = $this->getMock('Composer\IO\PackageInterface'); + $this->composer = new Composer(); + } + + /** + * testInflectPackageVars + * + * @return void + */ + public function testInflectPackageVars() + { + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); + $this->assertEquals($result, array('name' => 'CamelCased')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with-dash')); + $this->assertEquals($result, array('name' => 'WithDash')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); + $this->assertEquals($result, array('name' => 'WithUnderscore')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'cake/acl')); + $this->assertEquals($result, array('name' => 'Cake/Acl')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit')); + $this->assertEquals($result, array('name' => 'Cake/DebugKit')); + } + + /** + * Test getLocations returning appropriate values based on CakePHP version + * + */ + public function testGetLocations() { + $package = new RootPackage('CamelCased', '1.0', '1.0'); + $composer = new Composer(); + $rm = new RepositoryManager( + $this->getMock('Composer\IO\IOInterface'), + $this->getMock('Composer\Config') + ); + $composer->setRepositoryManager($rm); + $installer = new CakePHPInstaller($package, $composer); + + // 2.0 < cakephp < 3.0 + $this->setCakephpVersion($rm, '2.0.0'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + $this->setCakephpVersion($rm, '2.5.9'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + $this->setCakephpVersion($rm, '~2.5'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + // special handling for 2.x versions when 3.x is still in development + $this->setCakephpVersion($rm, 'dev-master'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + $this->setCakephpVersion($rm, '>=2.5'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + // cakephp >= 3.0 + $this->setCakephpVersion($rm, '3.0.*-dev'); + $result = $installer->getLocations(); + $this->assertContains('plugins/', $result['plugin']); + + $this->setCakephpVersion($rm, '~8.8'); + $result = $installer->getLocations(); + $this->assertContains('plugins/', $result['plugin']); + } + + /** + * Test if installer-name was set + * + */ + public function testGetInstallPath() { + $autoload = array( + 'psr-4' => array( + 'FOC\\Authenticate' => '' + ) + ); + $this->package->setAutoload($autoload); + $this->package->setType('cakephp-plugin'); + $rm = new RepositoryManager( + $this->getMock('Composer\IO\IOInterface'), + $this->getMock('Composer\Config') + ); + $this->composer->setRepositoryManager($rm); + $installer = new CakePHPInstaller($this->package, $this->composer); + + $this->setCakephpVersion($rm, '3.0.0'); + $installer->getInstallPath($this->package, 'cakephp'); + $extra = $this->package->getExtra(); + $this->assertEquals('FOC/Authenticate', $extra['installer-name']); + + $autoload = array( + 'psr-4' => array( + 'FOC\Acl\Test' => './tests', + 'FOC\Acl' => '' + ) + ); + $this->package->setAutoload($autoload); + $this->package->setExtra(array()); + $installer->getInstallPath($this->package, 'cakephp'); + $extra = $this->package->getExtra(); + $this->assertEquals('FOC/Acl', $extra['installer-name']); + + $autoload = array( + 'psr-4' => array( + 'Foo\Bar' => 'foo', + 'Acme\Plugin\Test' => 'tests', + 'Acme\Plugin' => './src' + ) + ); + $this->package->setAutoload($autoload); + $this->package->setExtra(array()); + $installer->getInstallPath($this->package, 'cakephp'); + $extra = $this->package->getExtra(); + $this->assertEquals('Acme/Plugin', $extra['installer-name']); + } + + protected function setCakephpVersion($rm, $version) { + $parser = new VersionParser(); + list(, $version) = explode(' ', $parser->parseConstraints($version)); + $installed = new InstalledArrayRepository(); + $package = new Package('cakephp/cakephp', $version, $version); + $installed->addPackage($package); + $rm->setLocalRepository($installed); + } + +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php new file mode 100644 index 0000000..9e385e6 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php @@ -0,0 +1,89 @@ +installer = new DokuWikiInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)), + array('name' => $expected, 'type'=>$type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'dokuwiki-plugin', + 'dokuwiki-test-plugin', + 'test', + ), + array( + 'dokuwiki-plugin', + 'test-plugin', + 'test', + ), + array( + 'dokuwiki-plugin', + 'dokuwiki_test', + 'test', + ), + array( + 'dokuwiki-plugin', + 'test', + 'test', + ), + array( + 'dokuwiki-plugin', + 'test-template', + 'test-template', + ), + array( + 'dokuwiki-template', + 'dokuwiki-test-template', + 'test', + ), + array( + 'dokuwiki-template', + 'test-template', + 'test', + ), + array( + 'dokuwiki-template', + 'dokuwiki_test', + 'test', + ), + array( + 'dokuwiki-template', + 'test', + 'test', + ), + array( + 'dokuwiki-template', + 'test-plugin', + 'test-plugin', + ), + ); + } +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php new file mode 100644 index 0000000..b757799 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php @@ -0,0 +1,63 @@ +composer = new Composer(); + } + + public function testInflectPackageVars() + { + $package = $this->getPackage('vendor/name', '0.0.0'); + $installer = new GravInstaller($package, $this->composer); + $packageVars = $this->getPackageVars($package); + + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test'))); + $this->assertEquals('test', $result['name']); + + foreach ($installer->getLocations() as $name => $location) { + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test"))); + $this->assertEquals('test-test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name"))); + $this->assertEquals('test-test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test"))); + $this->assertEquals('test-test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name"))); + $this->assertEquals('test-test', $result['name']); + } + } + + /** + * @param $package \Composer\Package\PackageInterface + */ + public function getPackageVars($package) + { + $type = $package->getType(); + + $prettyName = $package->getPrettyName(); + if (strpos($prettyName, '/') !== false) { + list($vendor, $name) = explode('/', $prettyName); + } else { + $vendor = ''; + $name = $prettyName; + } + + return compact('name', 'vendor', 'type'); + } +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php new file mode 100644 index 0000000..1a28a63 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php @@ -0,0 +1,412 @@ +fs = new Filesystem; + + $this->composer = new Composer(); + $this->config = new Config(); + $this->composer->setConfig($this->config); + + $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor'; + $this->ensureDirectoryExistsAndClear($this->vendorDir); + + $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin'; + $this->ensureDirectoryExistsAndClear($this->binDir); + + $this->config->merge(array( + 'config' => array( + 'vendor-dir' => $this->vendorDir, + 'bin-dir' => $this->binDir, + ), + )); + + $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') + ->disableOriginalConstructor() + ->getMock(); + $this->composer->setDownloadManager($this->dm); + + $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $this->io = $this->getMock('Composer\IO\IOInterface'); + } + + /** + * tearDown + * + * @return void + */ + public function tearDown() + { + $this->fs->removeDirectory($this->vendorDir); + $this->fs->removeDirectory($this->binDir); + } + + /** + * testSupports + * + * @return void + * + * @dataProvider dataForTestSupport + */ + public function testSupports($type, $expected) + { + $installer = new Installer($this->io, $this->composer); + $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type)); + } + + /** + * dataForTestSupport + */ + public function dataForTestSupport() + { + return array( + array('agl-module', true), + array('annotatecms-module', true), + array('annotatecms-component', true), + array('annotatecms-service', true), + array('bitrix-module', true), + array('bitrix-component', true), + array('bitrix-theme', true), + array('cakephp', false), + array('cakephp-', false), + array('cakephp-app', false), + array('cakephp-plugin', true), + array('chef-cookbook', true), + array('chef-role', true), + array('codeigniter-app', false), + array('codeigniter-library', true), + array('codeigniter-third-party', true), + array('codeigniter-module', true), + array('concrete5-block', true), + array('concrete5-package', true), + array('concrete5-theme', true), + array('concrete5-update', true), + array('craft-plugin', true), + array('croogo-plugin', true), + array('croogo-theme', true), + array('dokuwiki-plugin', true), + array('dokuwiki-template', true), + array('drupal-module', true), + array('dolibarr-module', true), + array('elgg-plugin', true), + array('fuel-module', true), + array('fuel-package', true), + array('fuel-theme', true), + array('fuelphp-component', true), + array('hurad-plugin', true), + array('hurad-theme', true), + array('joomla-library', true), + array('kirby-plugin', true), + array('kohana-module', true), + array('laravel-library', true), + array('lithium-library', true), + array('magento-library', true), + array('mako-package', true), + array('modxevo-snippet', true), + array('modxevo-plugin', true), + array('modxevo-module', true), + array('modxevo-template', true), + array('modxevo-lib', true), + array('mediawiki-extension', true), + array('mediawiki-skin', true), + array('microweber-module', true), + array('modulework-module', true), + array('moodle-mod', true), + array('october-module', true), + array('october-plugin', true), + array('piwik-plugin', true), + array('phpbb-extension', true), + array('pimcore-plugin', true), + array('ppi-module', true), + array('puppet-module', true), + array('redaxo-addon', true), + array('redaxo-bestyle-plugin', true), + array('roundcube-plugin', true), + array('shopware-backend-plugin', true), + array('shopware-core-plugin', true), + array('shopware-frontend-plugin', true), + array('shopware-theme', true), + array('silverstripe-module', true), + array('silverstripe-theme', true), + array('symfony1-plugin', true), + array('thelia-module', true), + array('thelia-frontoffice-template', true), + array('thelia-backoffice-template', true), + array('thelia-email-template', true), + array('tusk-task', true), + array('tusk-asset', true), + array('typo3-flow-plugin', true), + array('typo3-cms-extension', true), + array('whmcs-gateway', true), + array('wolfcms-plugin', true), + array('wordpress-plugin', true), + array('wordpress-core', false), + array('zend-library', true), + array('zikula-module', true), + array('zikula-theme', true), + ); + } + + /** + * testInstallPath + * + * @dataProvider dataForTestInstallPath + */ + public function testInstallPath($type, $path, $name, $version = '1.0.0') + { + $installer = new Installer($this->io, $this->composer); + $package = new Package($name, $version, $version); + + $package->setType($type); + $result = $installer->getInstallPath($package); + $this->assertEquals($path, $result); + } + + /** + * dataFormTestInstallPath + */ + public function dataForTestInstallPath() + { + return array( + array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'), + array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'), + array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'), + array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'), + array('bitrix-module', 'local/modules/my_module/', 'author/my_module'), + array('bitrix-component', 'local/components/my_component/', 'author/my_component'), + array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'), + array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'), + array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'), + array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'), + array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'), + array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'), + array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'), + array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'), + array('concrete5-theme', 'themes/concrete5_theme/', 'remo/concrete5_theme'), + array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'), + array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'), + array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'), + array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'), + array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'), + array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'), + array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'), + array('drupal-module', 'modules/my_module/', 'shama/my_module'), + array('drupal-theme', 'themes/my_module/', 'shama/my_module'), + array('drupal-profile', 'profiles/my_module/', 'shama/my_module'), + array('drupal-drush', 'drush/my_module/', 'shama/my_module'), + array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'), + array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'), + array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'), + array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'), + array('fuelphp-component', 'components/demo/', 'fuelphp/demo'), + array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'), + array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'), + array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'), + array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'), + array('kohana-module', 'modules/my_package/', 'shama/my_package'), + array('laravel-library', 'libraries/my_package/', 'shama/my_package'), + array('lithium-library', 'libraries/li3_test/', 'user/li3_test'), + array('magento-library', 'lib/foo/', 'test/foo'), + array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'), + array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'), + array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'), + array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'), + array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'), + array('mako-package', 'app/packages/my_package/', 'shama/my_package'), + array('mediawiki-extension', 'extensions/APC/', 'author/APC'), + array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'), + array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'), + array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'), + array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'), + array('mediawiki-skin', 'skins/someskin/', 'author/someskin'), + array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'), + array('modulework-module', 'modules/my_package/', 'shama/my_package'), + array('moodle-mod', 'mod/my_package/', 'shama/my_package'), + array('october-module', 'modules/my_plugin/', 'shama/my_plugin'), + array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'), + array('october-theme', 'themes/my_theme/', 'shama/my_theme'), + array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'), + array('phpbb-extension', 'ext/test/foo/', 'test/foo'), + array('phpbb-style', 'styles/foo/', 'test/foo'), + array('phpbb-language', 'language/foo/', 'test/foo'), + array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'), + array('ppi-module', 'modules/foo/', 'test/foo'), + array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'), + array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'), + array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'), + array('roundcube-plugin', 'plugins/base/', 'test/base'), + array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'), + array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'), + array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'), + array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'), + array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'), + array('silverstripe-module', 'my_module/', 'shama/my_module'), + array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'), + array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'), + array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'), + array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'), + array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'), + array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'), + array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'), + array('thelia-module', 'local/modules/my_module/', 'shama/my_module'), + array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'), + array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'), + array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'), + array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'), + array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'), + array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'), + array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'), + array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'), + array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'), + array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'), + array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'), + array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'), + array('zikula-module', 'modules/my-test_module/', 'my/test_module'), + array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'), + ); + } + + /** + * testGetCakePHPInstallPathException + * + * @return void + * + * @expectedException \InvalidArgumentException + */ + public function testGetCakePHPInstallPathException() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('shama/ftp', '1.0.0', '1.0.0'); + + $package->setType('cakephp-whoops'); + $result = $installer->getInstallPath($package); + } + + /** + * testCustomInstallPath + */ + public function testCustomInstallPath() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('shama/ftp', '1.0.0', '1.0.0'); + $package->setType('cakephp-plugin'); + $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0'); + $this->composer->setPackage($consumerPackage); + $consumerPackage->setExtra(array( + 'installer-paths' => array( + 'my/custom/path/{$name}/' => array( + 'shama/ftp', + 'foo/bar', + ), + ), + )); + $result = $installer->getInstallPath($package); + $this->assertEquals('my/custom/path/Ftp/', $result); + } + + /** + * testCustomInstallerName + */ + public function testCustomInstallerName() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0'); + $package->setType('cakephp-plugin'); + $package->setExtra(array( + 'installer-name' => 'FTP', + )); + $result = $installer->getInstallPath($package); + $this->assertEquals('Plugin/FTP/', $result); + } + + /** + * testCustomTypePath + */ + public function testCustomTypePath() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0'); + $package->setType('wordpress-plugin'); + $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0'); + $this->composer->setPackage($consumerPackage); + $consumerPackage->setExtra(array( + 'installer-paths' => array( + 'my/custom/path/{$name}/' => array( + 'type:wordpress-plugin' + ), + ), + )); + $result = $installer->getInstallPath($package); + $this->assertEquals('my/custom/path/my_plugin/', $result); + } + + /** + * testNoVendorName + */ + public function testNoVendorName() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0'); + + $package->setType('symfony1-plugin'); + $result = $installer->getInstallPath($package); + $this->assertEquals('plugins/sfPhpunitPlugin/', $result); + } + + /** + * testTypo3Inflection + */ + public function testTypo3Inflection() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('typo3/fluid', '1.0.0', '1.0.0'); + + $package->setAutoload(array( + 'psr-0' => array( + 'TYPO3\\Fluid' => 'Classes', + ), + )); + + $package->setType('typo3-flow-package'); + $result = $installer->getInstallPath($package); + $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result); + } + + public function testUninstallAndDeletePackageFromLocalRepo() + { + $package = new Package('foo', '1.0.0', '1.0.0'); + + $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer)); + $installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo')); + + $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true)); + $repo->expects($this->once())->method('removePackage')->with($package); + + $installer->uninstall($repo, $package); + } +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php new file mode 100644 index 0000000..3675e18 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php @@ -0,0 +1,66 @@ +installer = new MediaWikiInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)), + array('name' => $expected, 'type'=>$type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'mediawiki-extension', + 'sub-page-list', + 'SubPageList', + ), + array( + 'mediawiki-extension', + 'sub-page-list-extension', + 'SubPageList', + ), + array( + 'mediawiki-extension', + 'semantic-mediawiki', + 'SemanticMediawiki', + ), + // tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions + array( + 'mediawiki-skin', + 'some-skin-skin', + 'some-skin', + ), + // tests that names without '-skin' suffix stay valid + array( + 'mediawiki-skin', + 'someotherskin', + 'someotherskin', + ), + ); + } +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php new file mode 100644 index 0000000..fd427cd --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php @@ -0,0 +1,66 @@ +installer = new OctoberInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)), + array('name' => $expected, 'type' => $type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'october-plugin', + 'subpagelist', + 'subpagelist', + ), + array( + 'october-plugin', + 'subpagelist-plugin', + 'subpagelist', + ), + array( + 'october-plugin', + 'semanticoctober', + 'semanticoctober', + ), + // tests that exactly one '-theme' is cut off + array( + 'october-theme', + 'some-theme-theme', + 'some-theme', + ), + // tests that names without '-theme' suffix stay valid + array( + 'october-theme', + 'someothertheme', + 'someothertheme', + ), + ); + } +} \ No newline at end of file diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php new file mode 100644 index 0000000..ea79374 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php @@ -0,0 +1,44 @@ +package = new Package('CamelCased', '1.0', '1.0'); + $this->io = $this->getMock('Composer\IO\PackageInterface'); + $this->composer = new Composer(); + } + + /** + * testInflectPackageVars + * + * @return void + */ + public function testInflectPackageVars() + { + $installer = new PimcoreInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); + $this->assertEquals($result, array('name' => 'CamelCased')); + + $installer = new PimcoreInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with-dash')); + $this->assertEquals($result, array('name' => 'WithDash')); + + $installer = new PimcoreInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); + $this->assertEquals($result, array('name' => 'WithUnderscore')); + } +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php b/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php new file mode 100644 index 0000000..8d9ff3f --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php @@ -0,0 +1,63 @@ +package = new Package('VisitSummary', '1.0', '1.0'); + $this->io = $this->getMock('Composer\IO\PackageInterface'); + $this->composer = new Composer(); + } + + /** + * testInflectPackageVars + * + * @return void + */ + public function testInflectPackageVars() + { + $installer = new PiwikInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'VisitSummary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + + $installer = new PiwikInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'visit-summary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + + $installer = new PiwikInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'visit_summary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + } + +} diff --git a/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php b/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php new file mode 100644 index 0000000..6418a03 --- /dev/null +++ b/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php @@ -0,0 +1,64 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Installers\Test; + +use Composer\Package\Version\VersionParser; +use Composer\Package\Package; +use Composer\Package\AliasPackage; +use Composer\Package\LinkConstraint\VersionConstraint; +use Composer\Util\Filesystem; + +abstract class TestCase extends \PHPUnit_Framework_TestCase +{ + private static $parser; + + protected static function getVersionParser() + { + if (!self::$parser) { + self::$parser = new VersionParser(); + } + + return self::$parser; + } + + protected function getVersionConstraint($operator, $version) + { + return new VersionConstraint( + $operator, + self::getVersionParser()->normalize($version) + ); + } + + protected function getPackage($name, $version) + { + $normVersion = self::getVersionParser()->normalize($version); + + return new Package($name, $normVersion, $version); + } + + protected function getAliasPackage($package, $version) + { + $normVersion = self::getVersionParser()->normalize($version); + + return new AliasPackage($package, $normVersion, $version); + } + + protected function ensureDirectoryExistsAndClear($directory) + { + $fs = new Filesystem(); + if (is_dir($directory)) { + $fs->removeDirectory($directory); + } + mkdir($directory, 0777, true); + } +} diff --git a/vendor/composer/installers/tests/bootstrap.php b/vendor/composer/installers/tests/bootstrap.php new file mode 100644 index 0000000..30c8fdc --- /dev/null +++ b/vendor/composer/installers/tests/bootstrap.php @@ -0,0 +1,4 @@ +add('Composer\Installers\Test', __DIR__); diff --git a/vendor/php-console/php-console/LICENSE b/vendor/php-console/php-console/LICENSE new file mode 100644 index 0000000..3c3c136 --- /dev/null +++ b/vendor/php-console/php-console/LICENSE @@ -0,0 +1,32 @@ +PHP Console + +Copyright (c) 2011-2013 by Barbushin Sergey . +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/php-console/php-console/README.md b/vendor/php-console/php-console/README.md new file mode 100644 index 0000000..f346ff6 --- /dev/null +++ b/vendor/php-console/php-console/README.md @@ -0,0 +1,247 @@ +# PHP Console server library + +[![Latest Stable Version](https://poser.pugx.org/php-console/php-console/version.png)](https://packagist.org/packages/php-console/php-console) [![Composer Installs](https://poser.pugx.org/php-console/php-console/d/total.png)](https://packagist.org/packages/php-console/php-console) + +PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things using [Google Chrome extension PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) and [PhpConsole server library](https://github.com/barbushin/php-console). + +### Overview + +* See presentation [video](http://www.youtube.com/watch?v=_4kG-Zrs2Io). +* Install Google Chrome extension [PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef). +* See how it works on [live demo](http://php-console.com/instance/examples) page. +* PHP Console extension [features list and screenshots](https://github.com/barbushin/php-console/wiki/PHP-Console-extension-features). +* PHP Console server library [features list](https://github.com/barbushin/php-console/wiki/PHP-Console-server-features). + +### Requirements + +* [PHP Console extension](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef) must be installed on Google Chrome. +* PHP 5.3 (or later) on server. + +*For projects with PHP < 5.3 you can try to use old [deprecated version](https://groups.google.com/forum/?hl=ru#!forum/php-console-deprecated-version) of PHP Console. But mention that actual last version is much more functional.* + +# Installation + +### Composer + + { + "require": { + "php-console/php-console": "3.*" + } + } + +This is the most recommended way, so PhpConsole will be autoloaded using Composer [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) autoloader. Also it can be easy updated to last version using `composer update`. + +### GIT + + git clone https://github.com/barbushin/php-console.git php-console + +### SVN + + svn checkout https://github.com/barbushin/php-console/trunk php-console + +### Download .zip + +Download and extract repository [archive](https://github.com/barbushin/php-console/archive/master.zip). +Include in your project using: + + require_once('/path/to/php-console/src/PhpConsole/__autoload.php'); + +### Download .phar + +Download [PhpConsole.phar](http://php-console.com/instance/examples/utils/build_phar.php?download). +Include in your project using: + + require_once('phar:///var/www/path-to/PhpConsole.phar'); // autoload will be initialized automatically + +### Yii framework extension +See http://www.yiiframework.com/extension/php-console + +### Laravel framework service provider +See https://github.com/barbushin/php-console-laravel + +### Drupal CMS module +See https://drupal.org/project/pc (thanks to [@Chi-teck](https://github.com/Chi-teck)) + +# Usage + +You can try most of PHP Console features on [live demo](http://php-console.com/instance/examples) server. + +## Connector + +There is a [PhpConsole\Connector](src/PhpConsole/Connector.php) class that initializes connection between PHP server and Google Chrome extension. Connection is initalized when [PhpConsole\Connector](src/PhpConsole/Connector.php) instance is initialized: + + $connector = PhpConsole\Connector::getInstance(); + +Also it will be initialized when you call `PhpConsole\Handler::getInstance()` or `PhpConsole\Helper::register()`. + +### Communication protocol + +PHP Console uses headers to communicate with client, so `PhpConsole\Connector::getInstance()` or `PhpConsole\Handler::getInstance()` must be called before any output. If headers are sent before script shut down or PHP Console response package size is out of web-server headers size limit, then PHP Console will store response data in [PhpConsole\Storage](src/PhpConsole/Storage.php) implementation and send it to client in STDOUT, in additional HTTP request. So there is no limits in PHP Console response package size. + +### Troubleshooting with $_SESSION handler overridden in some frameworks + +By default PHP Console uses [PhpConsole\Storage\Session](src/PhpConsole/Storage/Session.php) for postponed responses, so all temporary data will be stored in `$_SESSION`. But there is some problem with frameworks like [Symfony](http://symfony.com) and [Laravel](http://laravel.com) that overrides PHP session handler. In this case you should use any other [PhpConsole\Storage](src/PhpConsole/Storage.php) implementation like: + + // Can be called only before PhpConsole\Connector::getInstance() and PhpConsole\Handler::getInstance() + PhpConsole\Connector::setPostponeStorage(new PhpConsole\Storage\File('/tmp/pc.data')); + +See all available [PhpConsole\Storage](src/PhpConsole/Storage.php) implementations in [/src/PhpConsole/Storage](src/PhpConsole/Storage). + +### Strip sources base path + +If you want to see errors sources and traces paths more short, call: + + $connector->setSourcesBasePath('/path/to/project'); + +So paths like `/path/to/project/module/file.php` will be displayed on client as `/module/file.php`. + +### Works with different server encodings + +If your internal server encoding is not UTF-8, so you need to call: + + $connector->setServerEncoding('CP1251'); + +### Initialization performance + +PhpConsole server library is optimized for lazy initialization only for clients that have Google Chrome extension PHP Console installed. There is [example](examples/features/highload_optimization.php) of correct initialization PhpConsole on your production server. + +## Protect connection + +### Protect by password + +[![ScreenShot](http://php-console.com/res/screenshot/auth_420.png)](http://php-console.com/instance/examples/#protect_by_password) + + $connector->setPassword('yohoho123', true); + +Clients will need to enter password to get access to PHP Console server data. All passwords are stored on client as SHA-256 hashes. Second argument says that PHP Console authorization token will depends on client IP. + +### SSL only connection mode + + $connector->enableSslOnlyMode(); + +So all PHP Console clients will be automatically redirected to HTTPS. + +### Protect connection by list of allowed IP masks + + $connector->setAllowedIpMasks(array('192.168.*.*')); + +## Handle errors + +[![ScreenShot](http://php-console.com/res/screenshot/errors_420.png)](http://php-console.com/instance/examples/#handle_errors) + +There is a [PhpConsole\Handler](src/PhpConsole/Handler.php) class that initializes PHP errors & exceptions handlers and provides the next features: + +* Handle PHP errors(+fatal & memory limit errors) and exceptions. +* Ignore repeated errors. +* Call previously defined errors and exceptions handlers. +* Handle caught exceptions using `$handler->handleException($exception)`. +* Debug vars using `$handler->debug($var, 'some.tags')`. + +Initialize `PhpConsole\Handler` in the top of your main project script: + + $handler = PhpConsole\Handler::getInstance(); + /* You can override default Handler behavior: + $handler->setHandleErrors(false); // disable errors handling + $handler->setHandleExceptions(false); // disable exceptions handling + $handler->setCallOldHandlers(false); // disable passing errors & exceptions to prviously defined handlers + */ + $handler->start(); // initialize handlers + + +## Debug vars + +[![ScreenShot](http://php-console.com/res/screenshot/debug_420.png)](http://php-console.com/instance/examples/#debug_vars) + +PHP Console has multifunctional and smart vars dumper that allows to + +* Dump any type variable. +* Dump protected and private objects properties. +* Limit dump by level, items count, item size and total size(see `$connector->getDumper()`). +* Dump objects class name. +* Smart dump of callbacks and Closure. +* Detect dump call source & trace(call `$connector->getDebugDispatcher()->detectTraceAndSource = true`). + + +### How to call + +**Longest** native debug method call: + + PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug($var, 'some.tags'); + +**Shorter** call debug from Handler: + + PhpConsole\Handler::getInstance()->debug($var, 'some.tags'); + +**Shortest** call debug using global `PC` class + + PhpConsole\Helper::register(); // it will register global PC class + // ... + PC::debug($var, 'tag'); + PC::tag($var); + +**Custom** call debug by user defined function + + function d($var, $tags = null) { + PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug($var, $tags, 1); + } + d($var, 'some.tags'); + +### Tags + +* Debug tags argument is optional. +* Tags is a string with tags separated by dot(e.g. "low.db"). +* Tags can be used to identify what exactly var was dumped. +* You can configure client to ignore displaying some tags. + +## Remote PHP code execution + +[![ScreenShot](http://php-console.com/res/screenshot/eval_terminal_420.png)](http://php-console.com/instance/examples/#eval_terminal) + +PHP Console provide a way to execute PHP code on your server remotely, from Google Chrome extension terminal. + +* Remote PHP code execution allowed only in password protected mode +* Every eval request is signed with unique SHA-256 token +* Result contains: `output`, `return` and `time` data +* Errors & exception occurred during PHP code execution will be handled + + +### Configuration + + $connector = PhpConsole\Connector::getInstance(); + $connector->setPassword($password); + + // Configure eval provider + $evalProvider = $connector->getEvalDispatcher()->getEvalProvider(); + $evalProvider->addSharedVar('post', $_POST); // so "return $post" code will return $_POST + $evalProvider->setOpenBaseDirs(array(__DIR__)); // see http://php.net/open-basedir + + $connector->startEvalRequestsListener(); // must be called in the end of all configurations + + +## PSR-3 logger implementation + +There is PHP Console implementation of [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) interface. to integrate PHP Console with PSR-3 compitable loggers(e.g. [Monolog](https://github.com/Seldaek/monolog)). See [PhpConsole\PsrLogger](src/PhpConsole/PsrLogger.php). + +## Jump to file + +Read [this article](https://github.com/barbushin/php-console/wiki/Jump-to-file) if you want to configure PHP Console extension to open errors/exceptions source file:line right in your IDE, just by click on the button in Notification popup. + +## Easy migrate from PhpConsole `v1.x` to `v3.x` + +If you have used PhpConsole `v1.x` and want to migrate to `v3.x` without any code changes, so just use [PhpConsole\OldVersionAdapter](src/PhpConsole/OldVersionAdapter.php): + + PhpConsole\OldVersionAdapter::register(); // register PhpConsole v1.x class emulator + + // Call old PhpConsole v1 methods as is + PhpConsole::start(true, true, $_SERVER['DOCUMENT_ROOT']); + PhpConsole::debug('Debug using old method PhpConsole::debug()', 'some,tags'); + debug('Debug using old function debug()', 'some,tags'); + echo $undefinedVar; + PhpConsole::getInstance()->handleException(new Exception('test')); + + // Call new PhpConsole methods, if you want :) + PhpConsole\Connector::getInstance()->setServerEncoding('cp1251'); + PhpConsole\Helper::register(); + PC::debug('Debug using new methods'); + +But, anyway, if you can't migrate to new version of PHP Console because of using PHP < 5.3 on your servers, then you can use old [deprecated version](https://groups.google.com/forum/?hl=ru#!forum/php-console-deprecated-version) of PHP Console. diff --git a/vendor/php-console/php-console/composer.json b/vendor/php-console/php-console/composer.json new file mode 100644 index 0000000..b704da8 --- /dev/null +++ b/vendor/php-console/php-console/composer.json @@ -0,0 +1,35 @@ +{ + "name": "php-console/php-console", + "description": "Server side PHP library for Google Chrome extension \"PHP Console\".", + "keywords": ["PHP", "errors", "debug", "chrome", "error handler", "google chrome"], + "homepage": "https://github.com/barbushin/php-console", + "license": "BSD 3-Clause", + "type": "library", + "authors": [ + { + "name": "Sergey Barbushin", + "homepage": "http://linkedin.com/in/barbushin", + "email": "barbushin@gmail.com" + } + ], + "support": { + "issues": "https://github.com/barbushin/php-console/issues?state=open" + }, + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "php-console/laravel-service-provider": "*" + }, + "autoload": { + "psr-0": { + "PhpConsole": "src/" + } + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + } +} diff --git a/vendor/php-console/php-console/examples/features/complex_usage_example.php b/vendor/php-console/php-console/examples/features/complex_usage_example.php new file mode 100644 index 0000000..faa9b09 --- /dev/null +++ b/vendor/php-console/php-console/examples/features/complex_usage_example.php @@ -0,0 +1,91 @@ +isActiveClient()) { + // Init errors & exceptions handler + $handler = PC::getHandler(); + $handler->start(); // start handling PHP errors & exceptions + + $connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); // so files paths on client will be shorter (optional) + $connector->setPassword($password); // protect access by password + // $connector->enableSslOnlyMode(); // PHP Console clients will be always redirected to HTTPS + // $connector->setAllowedIpMasks(array('192.168.*.*')); + + // Enable eval provider + $evalProvider = $connector->getEvalDispatcher()->getEvalProvider(); + $evalProvider->disableFileAccessByOpenBaseDir(); // means disable functions like include(), require(), file_get_contents() & etc + $evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); // so you can access $_SERVER['REQUEST_URI'] just as $uri in terminal + $evalProvider->addSharedVarReference('post', $_POST); + /* + $evalProvider->setOpenBaseDirs(array(__DIR__)); // set directories limited for include(), require(), file_get_contents() & etc + $evalProvider->addCodeHandler(function(&$code) { // modify or validate code before execution + $code = 'return '. $code; + }); + */ + $connector->startEvalRequestsListener(); // must be called after all configurations +} + +// Trigger E_WARNING error with backtrace + +class ErrorTestClass { + + public function __construct() { + $this->method1(array(1, 2), new stdClass()); // this arguments will be displayed in error backtrace + } + + protected function method1($a, $b) { + $this->method2('some long string argument'); + } + + public function method2($c) { + file_get_contents('not_existed.file'); // E_WARNING error + } +} + +new ErrorTestClass(); + +// Trigger JavaScript error + +echo ''; + +// Debug some data + +class DebugExample { + + private $privateProperty = 1; + protected $protectedProperty = 2; + public $publicProperty = 3; + public $selfProperty; + + public function __construct() { + $this->selfProperty = $this; + } + + public function someMethod() { + } +} + +PC::debug(array( + 'null' => null, + 'boolean' => true, + 'longString' => '11111111112222222222333333333344444444445', + 'someObject' => new DebugExample(), + 'someCallback' => array(new DebugExample(), 'someMethod'), + 'someClosure' => function () { + }, + 'someResource' => fopen(__FILE__, 'r'), + 'manyItemsArray' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), + 'deepLevelArray' => array(1 => array(2 => array(3))), +), 'some.test'); + +echo !$connector->isAuthorized() + ? 'To access eval terminal you need to authorize. Click on PHP Console "key" icon in address bar and enter the password.' + : 'See errors & debug data in JavaScript Console(Ctrl+Shift+J).
Click on PHP Console terminal icon in address bar to access eval terminal and try to execute some PHP code.'; \ No newline at end of file diff --git a/vendor/php-console/php-console/examples/features/debug_vars.php b/vendor/php-console/php-console/examples/features/debug_vars.php new file mode 100644 index 0000000..a9935c0 --- /dev/null +++ b/vendor/php-console/php-console/examples/features/debug_vars.php @@ -0,0 +1,69 @@ +start(); +$handler->debug('called from handler debug', 'some.three.tags'); + +// Call debug from PhpConsole\Connector (if you don't use PhpConsole\Handler in your project) +PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug('called from debug dispatcher without tags'); + +// Call debug from global PC class-helper (most short & easy way) +PhpConsole\Helper::register(); // required to register PC class in global namespace, must be called only once +PC::debug('called from PC::debug()', 'db'); +PC::db('called from PC::__callStatic()'); // means "db" will be handled as debug tag + +// Debug some mixed variable + +class DebugExample { + + private $privateProperty = 1; + protected $protectedProperty = 2; + public $publicProperty = 3; + public $selfProperty; + + public function __construct() { + $this->selfProperty = $this; + } + + public function someMethod() { + } +} + +PhpConsole\Connector::getInstance()->getDebugDispatcher()->setDumper( + new PhpConsole\Dumper(2, 10, 40) // set new dumper with levelLimit=2, itemsCountLimit=10, itemSizeLimit=10 +); + +$s = new stdClass(); +$s->asd = array(array(123)); + +PC::debug(array( + 'null' => null, + 'boolean' => true, + 'longString' => '11111111112222222222333333333344444444445', + 'someObject' => new DebugExample(), + 'someCallback' => array(new DebugExample(), 'someMethod'), + 'someClosure' => function () { + }, + 'someResource' => fopen(__FILE__, 'r'), + 'manyItemsArray' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), + 'deepLevelArray' => array(1 => array(2 => array(3))), +)); + +// Trace debug call + +PC::getConnector()->getDebugDispatcher()->detectTraceAndSource = true; + +function a() { + b(); +} + +function b() { + PC::debug('Message with source & trace detection'); +} + +a(); + +echo 'See debug messages in JavaScript Console(Ctrl+Shift+J) and in Notification popups. Click on PHP Console icon in address bar to see configuration options.'; diff --git a/vendor/php-console/php-console/examples/features/eval_terminal.php b/vendor/php-console/php-console/examples/features/eval_terminal.php new file mode 100644 index 0000000..4967bab --- /dev/null +++ b/vendor/php-console/php-console/examples/features/eval_terminal.php @@ -0,0 +1,30 @@ +setPassword($password); // Eval requests listener can be started only in password protected mode +// $connector->enableSslOnlyMode(); // PHP Console clients will be always redirected to HTTPS +// $connector->setAllowedIpMasks(array('192.168.*.*')); + +$evalProvider = $connector->getEvalDispatcher()->getEvalProvider(); +$evalProvider->disableFileAccessByOpenBaseDir(); // means disable functions like include(), require(), file_get_contents() & etc +$evalProvider->addSharedVar('uri', $_SERVER['REQUEST_URI']); // so you can access $_SERVER['REQUEST_URI'] just as $uri in terminal +$evalProvider->addSharedVarReference('post', $_POST); +/* + $evalProvider->setOpenBaseDirs(array(__DIR__)); // set directories limited for include(), require(), file_get_contents() & etc + $evalProvider->addCodeHandler(function(&$code) { // modify or validate code before execution + $code = 'return '. $code; + }); +*/ + +$connector->startEvalRequestsListener(); // must be called after all configurations + +echo !$connector->isAuthorized() + ? 'To access eval terminal you need to authorize. Click on PHP Console "key" icon in address bar and enter the password.' + : 'Click on PHP Console terminal icon in address bar to access eval terminal and try to execute some PHP code.'; diff --git a/vendor/php-console/php-console/examples/features/handle_errors.php b/vendor/php-console/php-console/examples/features/handle_errors.php new file mode 100644 index 0000000..87f9dfb --- /dev/null +++ b/vendor/php-console/php-console/examples/features/handle_errors.php @@ -0,0 +1,48 @@ +start(); // start handling PHP errors & exceptions +$handler->getConnector()->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); // so files paths on client will be shorter (optional) + +// Example of handling error with some backtrace + +class ErrorTestClass { + + public function __construct() { + $this->method1(array(1, 2), new stdClass()); // this arguments will be displayed in error backtrace + } + + protected function method1($a, $b) { + $this->method2('some long string argument'); + } + + public function method2($c) { + echo $undefinedVar; // E_NOTICE error + file_get_contents('not_existed.file'); // E_WARNING error + } +} + +new ErrorTestClass(); + +// Example of handling some caught exception + +try { + throw new Exception('Some caught exception'); +} +catch(Exception $exception) { + $handler->handleException($exception); +} + +echo 'See errors & exceptions messages in JavaScript Console(Ctrl+Shift+J) and in Notification popups. Click on PHP Console icon in address bar to see configuration options.'; + +// Example of handling some custom class uncaught exception + +class ExampleException extends Exception { + +} + +throw new ExampleException('Some uncaught exception with custom class'); + + diff --git a/vendor/php-console/php-console/examples/features/handle_javascript_errors.js b/vendor/php-console/php-console/examples/features/handle_javascript_errors.js new file mode 100644 index 0000000..beed19b --- /dev/null +++ b/vendor/php-console/php-console/examples/features/handle_javascript_errors.js @@ -0,0 +1,2 @@ +// test local JS source file & line detection +undefinedFunc(); diff --git a/vendor/php-console/php-console/examples/features/handle_javascript_errors.php b/vendor/php-console/php-console/examples/features/handle_javascript_errors.php new file mode 100644 index 0000000..4b8c923 --- /dev/null +++ b/vendor/php-console/php-console/examples/features/handle_javascript_errors.php @@ -0,0 +1,15 @@ +setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); + +echo 'See JavaScript Notification popup. You can disable JavaScript errors notification in PHP Console options.'; + +?> + + + diff --git a/vendor/php-console/php-console/examples/features/handle_on_redirect.php b/vendor/php-console/php-console/examples/features/handle_on_redirect.php new file mode 100644 index 0000000..2a1978b --- /dev/null +++ b/vendor/php-console/php-console/examples/features/handle_on_redirect.php @@ -0,0 +1,25 @@ +start(); +$handler->getConnector()->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']); + +$redirectNum = isset($_GET['num']) ? $_GET['num'] + 1 : 1; + +if($redirectNum < 4) { + if($redirectNum == 2) { + echo ${'oops' . $redirectNum}; + } + $handler->debug('Debug message in redirect №' . $redirectNum); + header('Location: ?num=' . $redirectNum); +} +else { + $handler->debug('Debug message in current page'); + echo ' + There was 3 redirects before this page is displayed, and you can see all handled error & debug messages in collapsed blocks in JavaScript Console(Ctrl+Shift+J). + If there was a error in redirected page, so console block will be expanded. + '; +} + diff --git a/vendor/php-console/php-console/examples/features/highload_optimization.php b/vendor/php-console/php-console/examples/features/highload_optimization.php new file mode 100644 index 0000000..d48f022 --- /dev/null +++ b/vendor/php-console/php-console/examples/features/highload_optimization.php @@ -0,0 +1,12 @@ +isActiveClient()) { + // ... any PHP Console initialization & configuration code +} + +// if you're calling PC::debug() or any other PC class methods in your code, so PhpConsole\Helper::register() must be called anyway +PhpConsole\Helper::register(); + +echo 'If you want to make PHP Console initialization more lightweight on your server, then you should execute initialization code only if PhpConsole\Connector->getInstance()->isActiveClient() returns true'; diff --git a/vendor/php-console/php-console/examples/features/old_version_adapter.php b/vendor/php-console/php-console/examples/features/old_version_adapter.php new file mode 100644 index 0000000..269b952 --- /dev/null +++ b/vendor/php-console/php-console/examples/features/old_version_adapter.php @@ -0,0 +1,19 @@ +handleException(new Exception('test')); + +// Call new PhpConsole methods, if you need :) +PhpConsole\Connector::getInstance()->setServerEncoding('cp1251'); +PhpConsole\Helper::register(); +PC::debug('Debug using new methods'); + +echo 'So there is an easy way to migrate from PhpConsole v1.x to v3.x without any code changes'; diff --git a/vendor/php-console/php-console/examples/features/protect_by_password.php b/vendor/php-console/php-console/examples/features/protect_by_password.php new file mode 100644 index 0000000..b8dff80 --- /dev/null +++ b/vendor/php-console/php-console/examples/features/protect_by_password.php @@ -0,0 +1,19 @@ +setPassword($password); +// $connector->enableSslOnlyMode(); // PHP Console clients will be always redirected to HTTPS +// $connector->setAllowedIpMasks(array('192.168.*.*')); + +$connector->getDebugDispatcher()->dispatchDebug('ok'); + +echo !$connector->isAuthorized() + ? 'Click on PHP Console "key" icon in address bar and enter the password.' + : 'Click on PHP Console icon in address bar to logout.'; diff --git a/vendor/php-console/php-console/examples/index.php b/vendor/php-console/php-console/examples/index.php new file mode 100644 index 0000000..19d928e --- /dev/null +++ b/vendor/php-console/php-console/examples/index.php @@ -0,0 +1,148 @@ + 'Debug vars', + 'handle_errors' => 'Handle errors and exceptions', + 'handle_on_redirect' => 'Handle messages on redirect', + 'handle_javascript_errors' => 'Handle JavaScript errors', + 'protect_by_password' => 'Protect by password', + 'eval_terminal' => 'PHP code remote execution', + 'highload_optimization' => 'Highload optimization', + 'complex_usage_example' => 'Complex usage example', + 'old_version_adapter' => 'Old version adapter', +); + +// List of scripts from ./utils directory +$utils = array( + 'build_phar' => 'Build PHAR', + 'test_jump_to_file' => 'Test Jump to File', + 'detect_headers_limit' => 'Detect server headers limit', +); + +// Highlight & print feature script source code +if(isset($_GET['highlight']) && isset($features[$_GET['highlight']])) { + highlight_string(preg_replace('/(\$password\s*=\s*).*?;/', '\1*****;', file_get_contents(__DIR__ . '/features/' . $_GET['highlight'] . '.php'))); + exit; +} + +require_once(__DIR__ . '/../src/PhpConsole/__autoload.php'); +$isActiveClient = PhpConsole\Connector::getInstance()->isActiveClient(); + +?> + + + + PHP Console usage examples + + + + + + + +

PHP Console Features examples & Utils

+ + + + Google Chrome extension + PHP Console + must be installed. + + + + +
+
+

Features

+ +
+ +

Utils

+ +
+
+ + + +
+ + + + diff --git a/vendor/php-console/php-console/examples/styles.css b/vendor/php-console/php-console/examples/styles.css new file mode 100644 index 0000000..7a04db1 --- /dev/null +++ b/vendor/php-console/php-console/examples/styles.css @@ -0,0 +1,42 @@ +body { + color: rgb(75, 75, 75); +} + +a, a:visited, a:hover, a:active { + color: #0078e7; + text-decoration: none; +} + +.link { + padding-top: 0.5em; + display: block; +} + +iframe { + width: 100%; + min-height: 10px; + border: 0; +} + +.active { + font-weight: bold; + outline: none !important; +} + +.warning { + margin: auto; + display: table; + padding: 0.5em; + background: mintcream; + border: 1px solid #eee; +} + +.code { + width: 100%; + padding: 1em; + font-size: 0.9em; + font-family: Consolas, 'Liberation Mono', Courier, monospace; + color: #333; + background: rgb(250, 250, 250); + border: 1px solid #eee; +} diff --git a/vendor/php-console/php-console/examples/utils/build_phar.php b/vendor/php-console/php-console/examples/utils/build_phar.php new file mode 100644 index 0000000..e804f6f --- /dev/null +++ b/vendor/php-console/php-console/examples/utils/build_phar.php @@ -0,0 +1,57 @@ +start(); + +if(isset($_GET['download'])) { + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="PhpConsole.phar"'); + readfile(PHP_CONSOLE_PHAR_FILEPATH); + exit; +} + +if(!Phar::canWrite()) { + throw new Exception('Unable to create PHAR archive, must be phar.readonly=Off option in php.ini'); +} +if(!is_writable(dirname(PHP_CONSOLE_PHAR_FILEPATH))) { + throw new Exception('Directory ' . dirname(PHP_CONSOLE_PHAR_FILEPATH) . ' must be writable'); +} +if(file_exists(PHP_CONSOLE_PHAR_FILEPATH)) { + unlink(PHP_CONSOLE_PHAR_FILEPATH); +} + +$phar = new Phar(PHP_CONSOLE_PHAR_FILEPATH); +$phar = $phar->convertToExecutable(Phar::PHAR); +$phar->startBuffering(); +$phar->buildFromDirectory(PHP_CONSOLE_DIR, '~' . '/[^_]\w+\.php$~'); +$phar->stopBuffering(); +$phar->setStub('stopBuffering(); + +$pharPath = realpath(PHP_CONSOLE_PHAR_FILEPATH); +$pharUri = substr($pharPath, strlen($_SERVER['DOCUMENT_ROOT'])); + +?> + +Done. See
+
+Now you can include PhpConsole to your project using: require_once('phar://'); diff --git a/vendor/php-console/php-console/examples/utils/detect_headers_limit.php b/vendor/php-console/php-console/examples/utils/detect_headers_limit.php new file mode 100644 index 0000000..e878ab0 --- /dev/null +++ b/vendor/php-console/php-console/examples/utils/detect_headers_limit.php @@ -0,0 +1,37 @@ + $testLimit && $isOk)); + +?> + +Done.
+Your server headers limit is bytes.
+
+Use it to configure PHP Console: PhpConsole\Connector::getInstance()->setHeadersLimit(); + + diff --git a/vendor/php-console/php-console/examples/utils/test_jump_to_file.php b/vendor/php-console/php-console/examples/utils/test_jump_to_file.php new file mode 100644 index 0000000..ca81c1b --- /dev/null +++ b/vendor/php-console/php-console/examples/utils/test_jump_to_file.php @@ -0,0 +1,40 @@ + + + + PHP Console usage examples + + + + + + +This is a test tool for Jump to File feature. + +
+
+ + + +
+
+ + + diff --git a/vendor/php-console/php-console/src/PhpConsole/Auth.php b/vendor/php-console/php-console/src/PhpConsole/Auth.php new file mode 100644 index 0000000..9c12a98 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Auth.php @@ -0,0 +1,106 @@ +publicKeyByIp = $publicKeyByIp; + $this->passwordHash = $this->getPasswordHash($password); + } + + protected final function hash($string) { + return hash('sha256', $string); + } + + /** + * Get password hash like on client + * @param $password + * @return string + */ + protected final function getPasswordHash($password) { + return $this->hash($password . self::PASSWORD_HASH_SALT); + } + + /** + * Get authorization result data for client + * @param ClientAuth|null $clientAuth + * @return ServerAuthStatus + */ + public final function getServerAuthStatus(ClientAuth $clientAuth = null) { + $serverAuthStatus = new ServerAuthStatus(); + $serverAuthStatus->publicKey = $this->getPublicKey(); + $serverAuthStatus->isSuccess = $clientAuth && $this->isValidAuth($clientAuth); + return $serverAuthStatus; + } + + /** + * Check if client authorization data is valid + * @param ClientAuth $clientAuth + * @return bool + */ + public final function isValidAuth(ClientAuth $clientAuth) { + return $clientAuth->publicKey === $this->getPublicKey() && $clientAuth->token === $this->getToken(); + } + + /** + * Get client unique identification + * @return string + */ + protected function getClientUid() { + $clientUid = ''; + if($this->publicKeyByIp) { + if(isset($_SERVER['REMOTE_ADDR'])) { + $clientUid .= $_SERVER['REMOTE_ADDR']; + } + if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $clientUid .= $_SERVER['HTTP_X_FORWARDED_FOR']; + } + } + return $clientUid; + } + + /** + * Get authorization session public key for current client + * @return string + */ + protected function getPublicKey() { + return $this->hash($this->getClientUid() . $this->passwordHash); + } + + /** + * Get string signature for current password & public key + * @param $string + * @return string + */ + public final function getSignature($string) { + return $this->hash($this->passwordHash . $this->getPublicKey() . $string); + } + + /** + * Get expected valid client authorization token + * @return string + */ + private final function getToken() { + return $this->hash($this->passwordHash . $this->getPublicKey()); + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Connector.php b/vendor/php-console/php-console/src/PhpConsole/Connector.php new file mode 100644 index 0000000..6e32988 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Connector.php @@ -0,0 +1,645 @@ +initConnection(); + $this->setServerEncoding(ini_get('mbstring.internal_encoding') ? : self::CLIENT_ENCODING); + } + + private final function __clone() { + } + + /** + * Detect script is running in command-line mode + * @return int + */ + protected function isCliMode() { + return PHP_SAPI == 'cli'; + } + + /** + * Notify clients that there is active PHP Console on server & check if there is request from client with active PHP Console + * @throws \Exception + */ + private final function initConnection() { + if($this->isCliMode()) { + return; + } + + $this->initServerCookie(); + $this->client = $this->initClient(); + + if($this->client) { + ob_start(); + $this->isActiveClient = true; + $this->registerFlushOnShutDown(); + $this->setHeadersLimit(isset($_SERVER['SERVER_SOFTWARE']) && stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false + ? 4096 // default headers limit for Nginx + : 8192 // default headers limit for all other web-servers + ); + $this->listenGetPostponedResponse(); + $this->postponeResponseId = $this->setPostponeHeader(); + } + } + + /** + * Get connected client data( + * @return Client|null + * @throws \Exception + */ + private final function initClient() { + if(isset($_COOKIE[self::CLIENT_INFO_COOKIE])) { + $clientData = @json_decode(base64_decode($_COOKIE[self::CLIENT_INFO_COOKIE], true), true); + if(!$clientData) { + throw new \Exception('Wrong format of response cookie data: ' . $_COOKIE[self::CLIENT_INFO_COOKIE]); + } + + $client = new Client($clientData); + if(isset($clientData['auth'])) { + $client->auth = new ClientAuth($clientData['auth']); + } + return $client; + } + } + + /** + * Notify clients that there is active PHP Console on server + * @throws \Exception + */ + private final function initServerCookie() { + if(!isset($_COOKIE[self::SERVER_COOKIE]) || $_COOKIE[self::SERVER_COOKIE] != self::SERVER_PROTOCOL) { + $isSuccess = setcookie(self::SERVER_COOKIE, self::SERVER_PROTOCOL, null, '/'); + if(!$isSuccess) { + throw new \Exception('Unable to set PHP Console server cookie'); + } + } + } + + /** + * Check if there is client is installed PHP Console extension + * @return bool + */ + public function isActiveClient() { + return $this->isActiveClient; + } + + /** + * Set client connection as not active + */ + protected function breakClientConnection() { + $this->isActiveClient = false; + } + + /** + * Check if client with valid auth credentials is connected + * @return bool + */ + public function isAuthorized() { + return $this->isAuthorized; + } + + /** + * Set IP masks of clients that will be allowed to connect to PHP Console + * @param array $ipMasks Use *(star character) for "any numbers" placeholder array('192.168.*.*', '10.2.12*.*', '127.0.0.1') + */ + public function setAllowedIpMasks(array $ipMasks) { + if($this->isActiveClient()) { + if(isset($_SERVER['REMOTE_ADDR'])) { + $ip = $_SERVER['REMOTE_ADDR']; + foreach($ipMasks as $ipMask) { + if(preg_match('~^' . str_replace(array('.', '*'), array('\.', '\w+'), $ipMask) . '$~i', $ip)) { + return; + } + } + } + $this->breakClientConnection(); + } + } + + /** + * @return Dumper + */ + public function getDumper() { + if(!$this->dumper) { + $this->dumper = new Dumper(); + } + return $this->dumper; + } + + /** + * Override default errors dispatcher + * @param Dispatcher\Errors $dispatcher + */ + public function setErrorsDispatcher(Dispatcher\Errors $dispatcher) { + $this->errorsDispatcher = $dispatcher; + } + + /** + * Get dispatcher responsible for sending errors/exceptions messages + * @return Dispatcher\Errors + */ + public function getErrorsDispatcher() { + if(!$this->errorsDispatcher) { + $this->errorsDispatcher = new Dispatcher\Errors($this, $this->getDumper()); + } + return $this->errorsDispatcher; + } + + /** + * Override default debug dispatcher + * @param Dispatcher\Debug $dispatcher + */ + public function setDebugDispatcher(Dispatcher\Debug $dispatcher) { + $this->debugDispatcher = $dispatcher; + } + + /** + * Get dispatcher responsible for sending debug messages + * @return Dispatcher\Debug + */ + public function getDebugDispatcher() { + if(!$this->debugDispatcher) { + $this->debugDispatcher = new Dispatcher\Debug($this, $this->getDumper()); + } + return $this->debugDispatcher; + } + + /** + * Override default eval requests dispatcher + * @param Dispatcher\Evaluate $dispatcher + */ + public function setEvalDispatcher(Dispatcher\Evaluate $dispatcher) { + $this->evalDispatcher = $dispatcher; + } + + /** + * Get dispatcher responsible for handling eval requests + * @return Dispatcher\Evaluate + */ + public function getEvalDispatcher() { + if(!$this->evalDispatcher) { + $this->evalDispatcher = new Dispatcher\Evaluate($this, new EvalProvider(), $this->getDumper()); + } + return $this->evalDispatcher; + } + + /** + * Enable eval request to be handled by eval dispatcher. Must be called after all Connector configurations. + * Connector::getInstance()->setPassword() is required to be called before this method + * Use Connector::getInstance()->setAllowedIpMasks() for additional access protection + * Check Connector::getInstance()->getEvalDispatcher()->getEvalProvider() to customize eval accessibility & security options + * @param bool $exitOnEval + * @param bool $flushDebugMessages Clear debug messages handled before this method is called + * @throws \Exception + */ + public final function startEvalRequestsListener($exitOnEval = true, $flushDebugMessages = true) { + if(!$this->auth) { + throw new \Exception('Eval dispatcher is allowed only in password protected mode. See PhpConsole\Connector::getInstance()->setPassword(...)'); + } + if($this->isEvalListenerStarted) { + throw new \Exception('Eval requests listener already started'); + } + $this->isEvalListenerStarted = true; + + if($this->isActiveClient() && $this->isAuthorized() && isset($_POST[Connector::POST_VAR_NAME]['eval'])) { + $request = $_POST[Connector::POST_VAR_NAME]['eval']; + if(!isset($request['data']) || !isset($request['signature'])) { + throw new \Exception('Wrong PHP Console eval request'); + } + if($this->auth->getSignature($request['data']) !== $request['signature']) { + throw new \Exception('Wrong PHP Console eval request signature'); + } + if($flushDebugMessages) { + foreach($this->messages as $i => $message) { + if($message instanceof DebugMessage) { + unset($this->messages[$i]); + } + } + } + $this->convertEncoding($request['data'], $this->serverEncoding, self::CLIENT_ENCODING); + $this->getEvalDispatcher()->dispatchCode($request['data']); + if($exitOnEval) { + exit; + } + } + } + + /** + * Set bath to base dir of project source code(so it will be stripped in paths displaying on client) + * @param $sourcesBasePath + * @throws \Exception + */ + public final function setSourcesBasePath($sourcesBasePath) { + $sourcesBasePath = realpath($sourcesBasePath); + if(!$sourcesBasePath) { + throw new \Exception('Path "' . $sourcesBasePath . '" not found'); + } + $this->sourcesBasePath = $sourcesBasePath; + } + + /** + * Protect PHP Console connection by password + * + * Use Connector::getInstance()->setAllowedIpMasks() for additional secure + * @param string $password + * @param bool $publicKeyByIp Set authorization token depending on client IP + * @throws \Exception + */ + public final function setPassword($password, $publicKeyByIp = true) { + if($this->auth) { + throw new \Exception('Password already defined'); + } + $this->convertEncoding($password, self::CLIENT_ENCODING, $this->serverEncoding); + $this->auth = new Auth($password, $publicKeyByIp); + if($this->client) { + $this->isAuthorized = $this->client->auth && $this->auth->isValidAuth($this->client->auth); + } + } + + /** + * Encode var to JSON with errors & encoding handling + * @param $var + * @return string + * @throws \Exception + */ + protected function jsonEncode($var) { + return json_encode($var, defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : null); + } + + /** + * Recursive var data encoding conversion + * @param $data + * @param $fromEncoding + * @param $toEncoding + */ + protected function convertArrayEncoding(&$data, $toEncoding, $fromEncoding) { + array_walk_recursive($data, array($this, 'convertWalkRecursiveItemEncoding'), array($toEncoding, $fromEncoding)); + } + + /** + * Encoding conversion callback for array_walk_recursive() + * @param string $string + * @param null $key + * @param array $args + */ + protected function convertWalkRecursiveItemEncoding(&$string, $key = null, array $args) { + $this->convertEncoding($string, $args[0], $args[1]); + } + + /** + * Convert string encoding + * @param string $string + * @param string $toEncoding + * @param string|null $fromEncoding + * @throws \Exception + */ + protected function convertEncoding(&$string, $toEncoding, $fromEncoding) { + if($string && is_string($string) && $toEncoding != $fromEncoding) { + static $isMbString; + if($isMbString === null) { + $isMbString = extension_loaded('mbstring'); + } + if($isMbString) { + $string = @mb_convert_encoding($string, $toEncoding, $fromEncoding) ? : $string; + } + else { + $string = @iconv($fromEncoding, $toEncoding . '//IGNORE', $string) ? : $string; + } + if(!$string && $toEncoding == 'UTF-8') { + $string = utf8_encode($string); + } + } + } + + /** + * Set headers size limit for your web-server. You can auto-detect headers size limit by /examples/utils/detect_headers_limit.php + * @param $bytes + * @throws \Exception + */ + public final function setHeadersLimit($bytes) { + if($bytes < static::PHP_HEADERS_SIZE) { + throw new \Exception('Headers limit cannot be less then ' . __CLASS__ . '::PHP_HEADERS_SIZE'); + } + $bytes -= static::PHP_HEADERS_SIZE; + $this->headersLimit = $bytes < static::CLIENT_HEADERS_LIMIT ? $bytes : static::CLIENT_HEADERS_LIMIT; + } + + /** + * Set your server PHP internal encoding, if it's different from "mbstring.internal_encoding" or UTF-8 + * @param $encoding + */ + public final function setServerEncoding($encoding) { + if($encoding == 'utf8' || $encoding == 'utf-8') { + $encoding = 'UTF-8'; // otherwise mb_convert_encoding() sometime fails with error(thanks to @alexborisov) + } + $this->serverEncoding = $encoding; + } + + /** + * Send data message to PHP Console client(if it's connected) + * @param Message $message + */ + public function sendMessage(Message $message) { + if($this->isActiveClient()) { + $this->messages[] = $message; + } + } + + /** + * Register shut down callback handler. Must be called after all errors handlers register_shutdown_function() + */ + public final function registerFlushOnShutDown() { + $this->registeredShutDowns++; + register_shutdown_function(array($this, 'onShutDown')); + } + + /** + * This method must be called only by register_shutdown_function(). Never call it manually! + */ + public function onShutDown() { + $this->registeredShutDowns--; + if(!$this->registeredShutDowns) { + $this->proceedResponsePackage(); + } + } + + /** + * Force connection by SSL for clients with PHP Console installed + */ + public function enableSslOnlyMode() { + $this->isSslOnlyMode = true; + } + + /** + * Check if client is connected by SSL + * @return bool + */ + protected function isSsl() { + return (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT']) == 443); + } + + /** + * Send response data to client + * @throws \Exception + */ + private final function proceedResponsePackage() { + if($this->isActiveClient()) { + $response = new Response(); + $response->isSslOnlyMode = $this->isSslOnlyMode; + + if(isset($_POST[self::POST_VAR_NAME]['getBackData'])) { + $response->getBackData = $_POST[self::POST_VAR_NAME]['getBackData']; + } + + if(!$this->isSslOnlyMode || $this->isSsl()) { + if($this->auth) { + $response->auth = $this->auth->getServerAuthStatus($this->client->auth); + } + if(!$this->auth || $this->isAuthorized()) { + $response->isLocal = isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '127.0.0.1'; + $response->docRoot = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : null; + $response->sourcesBasePath = $this->sourcesBasePath; + $response->isEvalEnabled = $this->isEvalListenerStarted; + $response->messages = $this->messages; + } + } + + $responseData = $this->serializeResponse($response); + + if(strlen($responseData) > $this->headersLimit || !$this->setHeaderData($responseData, self::HEADER_NAME, false)) { + $this->getPostponeStorage()->push($this->postponeResponseId, $responseData); + } + } + } + + private final function setPostponeHeader() { + $postponeResponseId = mt_rand() . mt_rand() . mt_rand(); + $this->setHeaderData($this->serializeResponse( + new PostponedResponse(array( + 'id' => $postponeResponseId + )) + ), self::POSTPONE_HEADER_NAME, true); + return $postponeResponseId; + } + + private final function setHeaderData($responseData, $headerName, $throwException = true) { + if(headers_sent($file, $line)) { + if($throwException) { + throw new \Exception('Unable to process response data, headers already sent in ' . $file . ':' . $line . '. Try to use ob_start() and don\'t use flush().'); + } + return false; + } + header($headerName . ': ' . $responseData); + return true; + } + + protected function objectToArray(&$var) { + if(is_object($var)) { + $var = get_object_vars($var); + array_walk_recursive($var, array($this, 'objectToArray')); + } + } + + protected function serializeResponse(DataObject $response) { + if($this->serverEncoding != self::CLIENT_ENCODING) { + $this->objectToArray($response); + $this->convertArrayEncoding($response, self::CLIENT_ENCODING, $this->serverEncoding); + } + return $this->jsonEncode($response); + } + + /** + * Check if there is postponed response request and dispatch it + */ + private final function listenGetPostponedResponse() { + if(isset($_POST[self::POST_VAR_NAME]['getPostponedResponse'])) { + header('Content-Type: application/json; charset=' . self::CLIENT_ENCODING); + echo $this->getPostponeStorage()->pop($_POST[self::POST_VAR_NAME]['getPostponedResponse']); + $this->breakClientConnection(); + exit; + } + } +} + +abstract class DataObject { + + public function __construct(array $properties = array()) { + foreach($properties as $property => $value) { + $this->$property = $value; + } + } +} + +final class Client extends DataObject { + + public $protocol; + /** @var ClientAuth|null */ + public $auth; +} + +final class ClientAuth extends DataObject { + + public $publicKey; + public $token; +} + +final class ServerAuthStatus extends DataObject { + + public $publicKey; + public $isSuccess; +} + +final class Response extends DataObject { + + public $protocol = Connector::SERVER_PROTOCOL; + /** @var ServerAuthStatus */ + public $auth; + public $docRoot; + public $sourcesBasePath; + public $getBackData; + public $isLocal; + public $isSslOnlyMode; + public $isEvalEnabled; + public $messages = array(); +} + +final class PostponedResponse extends DataObject { + + public $protocol = Connector::SERVER_PROTOCOL; + public $isPostponed = true; + public $id; +} + +abstract class Message extends DataObject { + + public $type; +} + +abstract class EventMessage extends Message { + + public $data; + public $file; + public $line; + /** @var null|TraceCall[] */ + public $trace; +} + +final class TraceCall extends DataObject { + + public $file; + public $line; + public $call; +} + +final class DebugMessage extends EventMessage { + + public $type = 'debug'; + public $tags; +} + +final class ErrorMessage extends EventMessage { + + public $type = 'error'; + public $code; + public $class; +} + +final class EvalResultMessage extends Message { + + public $type = 'eval_result'; + public $return; + public $output; + public $time; +} + diff --git a/vendor/php-console/php-console/src/PhpConsole/Dispatcher.php b/vendor/php-console/php-console/src/PhpConsole/Dispatcher.php new file mode 100644 index 0000000..16dbb59 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Dispatcher.php @@ -0,0 +1,104 @@ +connector = $connector; + $this->setDumper($dumper); + } + + /** + * Override default dumper + * @param Dumper $dumper + */ + public function setDumper(Dumper $dumper) { + $this->dumper = $dumper; + } + + /** + * Check if dispatcher is active to send messages + * @return bool + */ + public function isActive() { + return $this->connector->isActiveClient(); + } + + /** + * Send message to PHP Console connector + * @param Message $message + */ + protected function sendMessage(Message $message) { + $this->connector->sendMessage($message); + } + + /** + * Convert backtrace to array of TraceCall with source file & line detection + * @param array $trace Standard PHP backtrace array + * @param null|string $file Reference to var that will contain source file path + * @param null|string $line Reference to var that will contain source line number + * @param int $skipTraceCalls Last trace calls that will be stripped in result + * @return TraceCall[] + */ + protected function fetchTrace(array $trace, &$file = null, &$line = null, $skipTraceCalls = 0) { + foreach($trace as $i => $call) { + if(!$file && $i == $skipTraceCalls && isset($call['file'])) { + $file = $call['file']; + $line = $call['line']; + } + if($i < $skipTraceCalls || (isset($call['file']) && $call['file'] == $file && $call['line'] == $line)) { + unset($trace[$i]); + } + } + + $traceCalls = array(); + foreach(array_reverse($trace) as $call) { + $args = array(); + if(isset($call['args'])) { + foreach($call['args'] as $arg) { + if(is_object($arg)) { + $args[] = get_class($arg); + } + elseif(is_array($arg)) { + $args[] = 'Array[' . count($arg) . ']'; + } + else { + $arg = var_export($arg, 1); + $args[] = strlen($arg) > 15 ? substr($arg, 0, 15) . '...\'' : $arg; + } + } + } + + $traceCall = new TraceCall(); + $traceCall->call = (isset($call['class']) ? $call['class'] . $call['type'] : '') . $call['function'] . '(' . implode(', ', $args) . ')'; + if(isset($call['file'])) { + $traceCall->file = $call['file']; + } + if(isset($call['line'])) { + $traceCall->line = $call['line']; + } + $traceCalls[] = $traceCall; + } + return $traceCalls; + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Debug.php b/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Debug.php new file mode 100644 index 0000000..a22952e --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Debug.php @@ -0,0 +1,39 @@ +isActive()) { + $message = new \PhpConsole\DebugMessage(); + $message->data = $this->dumper->dump($data); + if($tags) { + $message->tags = explode('.', $tags); + } + if($this->detectTraceAndSource && $callLevel !== null) { + $message->trace = $this->fetchTrace(debug_backtrace(), $message->file, $message->line, $callLevel); + } + $this->sendMessage($message); + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Errors.php b/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Errors.php new file mode 100644 index 0000000..6fb777d --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Errors.php @@ -0,0 +1,134 @@ + names(will be initialized in first call) */ + protected static $errorsConstantsValues = array(); + /** @var array PHP errors constants names */ + protected static $errorsConstantsNames = array( + 'E_STRICT', + 'E_DEPRECATED', + 'E_RECOVERABLE_ERROR', + 'E_NOTICE', + 'E_WARNING', + 'E_ERROR', + 'E_PARSE', + 'E_USER_DEPRECATED', + 'E_USER_NOTICE', + 'E_USER_WARNING', + 'E_USER_ERROR', + 'E_CORE_WARNING', + 'E_CORE_ERROR', + 'E_COMPILE_ERROR', + 'E_COMPILE_WARNING', + ); + + /** @var bool Don't send errors messages with same file, line & class */ + public $ignoreRepeatedSource = true; + /** @var bool Dispatch $exception->getPrevious() if not empty */ + public $dispatchPreviousExceptions = true; + + /** @var \PhpConsole\ErrorMessage[] */ + protected $sentMessages = array(); + + /** + * Send error message to client + * @param null|integer $code + * @param null|string $text + * @param null|string $file + * @param null|integer $line + * @param null|int $callLevel Number of proxy methods between original "error handler method" and this method call + */ + public function dispatchError($code = null, $text = null, $file = null, $line = null, $callLevel = 0) { + if($this->isActive()) { + $message = new \PhpConsole\ErrorMessage(); + $message->code = $code; + $message->class = $this->getErrorTypeByCode($code); + $message->data = $this->dumper->dump($text); + $message->file = $file; + $message->line = $line; + if($callLevel !== null) { + $message->trace = $this->fetchTrace(debug_backtrace(), $file, $line, $callLevel + 1); + } + $this->sendMessage($message); + } + } + + /** + * Send exception message to client + * @param \Exception $exception + */ + public function dispatchException(\Exception $exception) { + if($this->isActive()) { + if($this->dispatchPreviousExceptions && $exception->getPrevious()) { + $this->dispatchException($exception->getPrevious()); + } + $message = new \PhpConsole\ErrorMessage(); + $message->code = $exception->getCode(); + $message->class = get_class($exception); + $message->data = $this->dumper->dump($exception->getMessage()); + $message->file = $exception->getFile(); + $message->line = $exception->getLine(); + $message->trace = self::fetchTrace($exception->getTrace(), $message->file, $message->line); + $this->sendMessage($message); + } + } + + /** + * Send message to PHP Console connector + * @param \PhpConsole\Message $message + */ + protected function sendMessage(\PhpConsole\Message $message) { + if(!$this->isIgnored($message)) { + parent::sendMessage($message); + $this->sentMessages[] = $message; + } + } + + /** + * Get PHP error constant name by value + * @param int $code + * @return string + */ + protected function getErrorTypeByCode($code) { + if(!static::$errorsConstantsValues) { + foreach(static::$errorsConstantsNames as $constantName) { + if(defined($constantName)) { + static::$errorsConstantsValues[constant($constantName)] = $constantName; + } + } + } + if(isset(static::$errorsConstantsValues[$code])) { + return static::$errorsConstantsValues[$code]; + } + return (string)$code; + } + + /** + * Return true if message with same file, line & class was already sent + * @param \PhpConsole\ErrorMessage $message + * @return bool + */ + protected function isIgnored(\PhpConsole\ErrorMessage $message) { + if($this->ignoreRepeatedSource && $message->file) { + foreach($this->sentMessages as $sentMessage) { + if($message->file == $sentMessage->file && $message->line == $sentMessage->line && $message->class == $sentMessage->class) { + return true; + } + } + } + return false; + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Evaluate.php b/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Evaluate.php new file mode 100644 index 0000000..55bb57c --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Dispatcher/Evaluate.php @@ -0,0 +1,72 @@ +evalProvider = $evalProvider; + parent::__construct($connector, $dumper); + } + + /** + * Override eval provider + * @param \PhpConsole\EvalProvider $evalProvider + */ + public function setEvalProvider(\PhpConsole\EvalProvider $evalProvider) { + $this->evalProvider = $evalProvider; + } + + /** + * Get eval provider + * @return \PhpConsole\EvalProvider + */ + public function getEvalProvider() { + return $this->evalProvider; + } + + /** + * Execute PHP code and send result message in connector + * @param $code + */ + public function dispatchCode($code) { + if($this->isActive()) { + $previousLastError = error_get_last(); + $oldDisplayErrors = ini_set('display_errors', false); + $result = $this->evalProvider->evaluate($code); + ini_set('display_errors', $oldDisplayErrors); + + $message = new \PhpConsole\EvalResultMessage(); + $message->return = $this->dumper->dump($result->return); + $message->output = $this->dumper->dump($result->output); + $message->time = round($result->time, 6); + + $newLastError = error_get_last(); + if($newLastError && $newLastError != $previousLastError) { + $this->connector->getErrorsDispatcher()->dispatchError($newLastError ['type'], $newLastError ['message'], $newLastError ['file'], $newLastError ['line'], 999); + } + if($result->exception) { + $this->connector->getErrorsDispatcher()->dispatchException($result->exception); + } + $this->sendMessage($message); + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Dumper.php b/vendor/php-console/php-console/src/PhpConsole/Dumper.php new file mode 100644 index 0000000..7bf36b6 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Dumper.php @@ -0,0 +1,181 @@ +levelLimit = $levelLimit; + $this->itemsCountLimit = $itemsCountLimit; + $this->itemSizeLimit = $itemSizeLimit; + $this->dumpSizeLimit = $dumpSizeLimit; + } + + /** + * Convert any type of var to string or array applying all actual limits & transformations + * @param mixed $var + * @return string|array + */ + public function dump($var) { + $this->dumpVarData($var, $this->levelLimit); + return $var; + } + + /** + * Recursively convert any type of var to string or array applying all actual limits & transformations + * @param $data + * @param $levelLimit + * @param bool $rootCall + */ + protected function dumpVarData(&$data, $levelLimit, $rootCall = true) { + static $sizeLeft, + $objectsHashes = array(), + $origQueue = array(), + $refQueue = array(), + $levelsQueue = array(); + + if($rootCall) { + $sizeLeft = $this->dumpSizeLimit ? : 999999999; + } + + if(is_object($data)) { + if($data instanceof \Closure) { + $data = '(callback function)'; + return; + } + if($rootCall) { + $data = array('' => $data); + return $this->dumpVarData($data, $levelLimit + 1); + } + $objectsHashes[] = spl_object_hash($data); + $dataArray = array(); + foreach((array)$data as $key => $value) { + $nullPos = strrpos($key, chr(0)); + if($nullPos) { + $dataArray[substr($key, $nullPos + 1)] = $value; + } + else { + $dataArray[$key] = $value; + } + } + $data = $dataArray; + } + + if(is_array($data)) { + + if($this->detectCallbacks && count($data) == 2 && is_callable($data)) { + list($class, $method) = $data; + $data = '(callback ' . (is_object($class) ? get_class($class) : $class) . '::' . $method . ')'; + $sizeLeft -= strlen($data) + 4; + return; + } + + $i = 0; + $dataArray = array(); + foreach($data as $k => &$v) { + if(($this->itemsCountLimit && $i >= $this->itemsCountLimit) || $sizeLeft <= 0) { + break; + } + if(is_array($v) || is_object($v)) { + if($levelLimit > 1) { + $origQueue[] = $v; + $refQueue[] =& $v; + $levelsQueue[] = $levelLimit; + } + if(is_object($v) && !$v instanceof \Closure) { + $k .= ':' . get_class($v); + $hash = spl_object_hash($v); + if(in_array($hash, $objectsHashes)) { + $v = '*RECURSION*'; + } + else { + $v = '(object)'; + $objectsHashes[] = $hash; + } + } + else { + $v = '(array)'; + } + $sizeLeft -= strlen($k) + strlen($v) + 8; + } + else { + $sizeLeft -= strlen($k) + 4; + $this->dumpVarData($v, $levelLimit - 1, false); + } + $dataArray[$k] =& $v; + $i++; + } + + if($i != count($data)) { + $dataArray['...'] = '(displayed ' . $i . ' of ' . count($data) . ')'; + } + $data = $dataArray; + + if(!$rootCall) { + return; + } + + do { + $origData = array_shift($origQueue); + $level = array_shift($levelsQueue); + $refData =& $refQueue[0]; + array_shift($refQueue); + $sizeLeft += strlen($refData); + if($refData !== '*RECURSION*') { + $this->dumpVarData($origData, $level - 1, false); + $refData = $origData; + } + } + while(count($origQueue) && $sizeLeft >= 0); + + if($rootCall) { + $levelsQueue = $origQueue = $refQueue = $objectsHashes = array(); + } + } + // scalar or resource + else { + if(!is_scalar($data) && $data !== null) { + if(is_resource($data)) { + $data = '(' . strtolower((string)$data) . ' ' . get_resource_type($data) . ')'; + $sizeLeft -= strlen($data); + return; + } + $data = var_export($data, true); + } + if(strlen($data) > $this->itemSizeLimit) { + $data = substr($data, 0, $this->itemSizeLimit - 3) . '...'; + } + if(strlen($data) > $sizeLeft) { + $data = substr($data, 0, $sizeLeft - 3) . '...'; + } + $sizeLeft -= strlen($data); + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/EvalProvider.php b/vendor/php-console/php-console/src/PhpConsole/EvalProvider.php new file mode 100644 index 0000000..180c6f6 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/EvalProvider.php @@ -0,0 +1,242 @@ +applyHandlersToCode($code); + $code = $this->adaptCodeToEval($code); + + $this->backupGlobals(); + $this->applyOpenBaseDirSetting(); + + $startTime = microtime(true); + static::executeCode('', $this->sharedVars); + $selfTime = microtime(true) - $startTime; + + ob_start(); + $result = new EvalResult(); + $startTime = microtime(true); + try { + $result->return = static::executeCode($code, $this->sharedVars); + } + catch(\Exception $exception) { + $result->exception = $exception; + } + $result->time = abs(microtime(true) - $startTime - $selfTime); + $result->output = ob_get_clean(); + + $this->restoreGlobals(); + + return $result; + } + + /** + * Add callback that will be called with &$code var reference before code execution + * @param $callback + * @throws \Exception + */ + public function addCodeHandler($callback) { + if(!is_callable($callback)) { + throw new \Exception('Argument is not callable'); + } + $this->codeCallbackHandlers[] = $callback; + } + + /** + * Call added code handlers + * @param $code + * @return mixed + */ + protected function applyHandlersToCode($code) { + foreach($this->codeCallbackHandlers as $callback) { + call_user_func_array($callback, array(&$code)); + } + return $code; + } + + /** + * Store global vars data in backup var + */ + protected function backupGlobals() { + $this->globalsBackup = array(); + foreach($GLOBALS as $key => $value) { + if($key != 'GLOBALS') { + $this->globalsBackup[$key] = $value; + } + } + } + + /** + * Restore global vars data from backup var + */ + protected function restoreGlobals() { + foreach($this->globalsBackup as $key => $value) { + $GLOBALS[$key] = $value; + } + foreach(array_diff(array_keys($GLOBALS), array_keys($this->globalsBackup)) as $newKey) { + if($newKey != 'GLOBALS') { + unset($GLOBALS[$newKey]); + } + } + } + + /** + * Execute code with shared vars + * @param $code + * @param array $sharedVars + * @return mixed + */ + protected static function executeCode($code, array $sharedVars) { + unset($code); + unset($sharedVars); + + foreach(func_get_arg(1) as $var => $value) { + if(isset($GLOBALS[$var]) && $var[0] == '_') { // extract($this->sharedVars, EXTR_OVERWRITE) and $$var = $value do not overwrites global vars + $GLOBALS[$var] = $value; + } + else { + $$var = $value; + } + } + + return eval(func_get_arg(0)); + } + + /** + * Prepare code PHP tags be correctly passed to eval() function + * @param string $code + * @return string + */ + protected function trimPhpTags($code) { + $replace = array( + '~^(\s*)<\?=~s' => '\1echo ', + '~^(\s*)<\?(php)?~is' => '\1', + '~\?>\s*$~s' => '', + '~<\?(php)?[\s;]*$~is' => '', + ); + return preg_replace(array_keys($replace), $replace, $code); + } + + /** + * Add semicolon to the end of code if it's required + * @param string $code + * @return string + */ + protected function forceEndingSemicolon($code) { + $code = rtrim($code, "; \r\n"); + return $code[strlen($code) - 1] != '}' ? $code . ';' : $code; + } + + /** + * Apply some default code handlers + * @param string $code + * @return string + */ + protected function adaptCodeToEval($code) { + $code = $this->trimPhpTags($code); + $code = $this->forceEndingSemicolon($code); + return $code; + } + + /** + * Protect response code access only to specified directories using http://www.php.net/manual/en/ini.core.php#ini.open-basedir + * IMPORTANT: classes autoload methods will work only for specified directories + * @param array $openBaseDirs + */ + public function setOpenBaseDirs(array $openBaseDirs) { + $this->openBaseDirs = $openBaseDirs; + } + + /** + * Autoload all PHP Console classes + */ + protected function forcePhpConsoleClassesAutoLoad() { + foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__), \RecursiveIteratorIterator::LEAVES_ONLY) as $path) { + /** @var $path \SplFileInfo */ + if($path->isFile() && $path->getExtension() == 'php' && $path->getFilename() !== 'PsrLogger.php') { + require_once($path->getPathname()); + } + } + } + + /** + * Set actual "open_basedir" PHP ini option + * @throws \Exception + */ + protected function applyOpenBaseDirSetting() { + if($this->openBaseDirs) { + $value = implode(PATH_SEPARATOR, $this->openBaseDirs); + if(ini_get('open_basedir') != $value) { + $this->forcePhpConsoleClassesAutoLoad(); + if(ini_set('open_basedir', $value) === false) { + throw new \Exception('Unable to set "open_basedir" php.ini setting'); + } + } + } + } + + /** + * Protect response code from reading/writing/including any files using http://www.php.net/manual/en/ini.core.php#ini.open-basedir + * IMPORTANT: It does not protects from system(), exec(), passthru(), popen() & etc OS commands execution functions + * IMPORTANT: Classes autoload methods will not work, so all required classes must be loaded before code evaluation + */ + public function disableFileAccessByOpenBaseDir() { + $this->setOpenBaseDirs(array(__DIR__ . '/not_existed_dir' . mt_rand())); + } + + /** + * Add var that will be implemented in PHP code executed from PHP Console debug panel (will be implemented in PHP Console > v3.0) + * @param $name + * @param $var + * @throws \Exception + * @internal param bool $asReference + */ + public function addSharedVar($name, $var) { + $this->addSharedVarReference($name, $var); + } + + /** + * Add var that will be implemented in PHP code executed from PHP Console debug panel (will be implemented in PHP Console > v3.0) + * @param $name + * @param $var + * @throws \Exception + * @internal param bool $asReference + */ + public function addSharedVarReference($name, &$var) { + if(isset($this->sharedVars[$name])) { + throw new \Exception('Var with name "' . $name . '" already added'); + } + $this->sharedVars[$name] =& $var; + } +} + +class EvalResult { + + public $return; + public $output; + public $time; + /** @var \Exception|null */ + public $exception; +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Handler.php b/vendor/php-console/php-console/src/PhpConsole/Handler.php new file mode 100644 index 0000000..f0edc84 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Handler.php @@ -0,0 +1,241 @@ +connector = Connector::getInstance(); + } + + private final function __clone() { + } + + /** + * Start errors & exceptions handlers + * @throws \Exception + */ + public function start() { + if($this->isStarted) { + throw new \Exception(get_called_class() . ' is already started, use ' . get_called_class() . '::getInstance()->isStarted() to check it.'); + } + $this->isStarted = true; + + if($this->handleErrors) { + $this->initErrorsHandler(); + } + if($this->handleExceptions) { + $this->initExceptionsHandler(); + } + } + + /** + * Validate that method is called before start. Required for handlers configuration methods. + * @throws \Exception + */ + protected function checkIsCalledBeforeStart() { + if($this->isStarted) { + throw new \Exception('This method can be called only before ' . get_class($this) . '::start()'); + } + } + + /** + * Enable or disable errors handler + * @param bool $isEnabled + */ + public function setHandleErrors($isEnabled) { + $this->checkIsCalledBeforeStart(); + $this->handleErrors = $isEnabled; + } + + /** + * Enable or disable exceptions handler + * @param bool $isEnabled + */ + public function setHandleExceptions($isEnabled) { + $this->checkIsCalledBeforeStart(); + $this->handleExceptions = $isEnabled; + } + + /** + * Enable or disable calling overridden errors & exceptions + * @param bool $isEnabled + */ + public function setCallOldHandlers($isEnabled) { + $this->callOldHandlers = $isEnabled; + } + + /** + * @return Connector + */ + public function getConnector() { + return $this->connector; + } + + /** + * Check if PHP Console handler is started + * @return bool + */ + public function isStarted() { + return $this->isStarted; + } + + /** + * Override PHP exceptions handler to PHP Console handler + */ + protected function initExceptionsHandler() { + $this->oldExceptionsHandler = set_exception_handler(array($this, 'handleException')); + } + + /** + * Set custom errors handler level like E_ALL ^ E_STRICT + * But, anyway, it's strongly recommended to configure ignore some errors type in PHP Console extension options + * IMPORTANT: previously old error handler will be called only with new errors level + * @param int $level see http://us1.php.net/manual/ru/function.error-reporting.php + */ + public function setErrorsHandlerLevel($level) { + $this->checkIsCalledBeforeStart(); + $this->errorsHandlerLevel = $level; + } + + /** + * Override PHP errors handler to PHP Console handler + */ + protected function initErrorsHandler() { + ini_set('display_errors', false); + ini_set('html_errors', false); + error_reporting($this->errorsHandlerLevel ? : E_ALL | E_STRICT); + $this->oldErrorsHandler = set_error_handler(array($this, 'handleError')); + register_shutdown_function(array($this, 'checkFatalErrorOnShutDown')); + $this->connector->registerFlushOnShutDown(); + } + + /** + * Method is called by register_shutdown_function(), it's required to handle fatal PHP errors. Never call it manually. + */ + public function checkFatalErrorOnShutDown() { + $error = error_get_last(); + if($error) { + ini_set('memory_limit', memory_get_usage(true) + 1000000); // if memory limit exceeded + $this->callOldHandlers = false; + $this->handleError($error['type'], $error['message'], $error['file'], $error['line'], null, 1); + } + } + + /** + * Handle error data + * @param int|null $code + * @param string|null $text + * @param string|null $file + * @param int|null $line + * @param null $context + * @param int $skipCallsLevel Number of proxy methods between original "error handler method" and this method call + */ + public function handleError($code = null, $text = null, $file = null, $line = null, $context = null, $skipCallsLevel = 0) { + if(!$this->isStarted || error_reporting() === 0 || $this->isHandlingDisabled()) { + return; + } + $this->onHandlingStart(); + $this->connector->getErrorsDispatcher()->dispatchError($code, $text, $file, $line, $skipCallsLevel + 1); + if($this->oldErrorsHandler && $this->callOldHandlers) { + call_user_func_array($this->oldErrorsHandler, array($code, $text, $file, $line, $context)); + } + $this->onHandlingComplete(); + } + + /** + * Method is called before handling any error or exception + */ + protected function onHandlingStart() { + $this->recursiveHandlingLevel++; + } + + /** + * Method is called after handling any error or exception + */ + protected function onHandlingComplete() { + $this->recursiveHandlingLevel--; + } + + /** + * Check if errors/exception handling is disabled + * @return bool + */ + protected function isHandlingDisabled() { + return $this->recursiveHandlingLevel >= static::ERRORS_RECURSION_LIMIT; + } + + /** + * Handle exception object + * @param \Exception $exception + */ + public function handleException(\Exception $exception) { + if(!$this->isStarted || $this->isHandlingDisabled()) { + return; + } + try { + $this->onHandlingStart(); + $this->connector->getErrorsDispatcher()->dispatchException($exception); + if($this->oldExceptionsHandler && $this->callOldHandlers) { + call_user_func($this->oldExceptionsHandler, $exception); + } + } + catch(\Exception $internalException) { + $this->handleException($internalException); + } + $this->onHandlingComplete(); + } + + /** + * Handle debug data + * @param mixed $data + * @param string|null $tags Tags separated by dot, e.g. "low.db.billing" + * @param int $skipTraceCalls Number of proxy methods between original "debug method call" and this method call + */ + public function debug($data, $tags = null, $skipTraceCalls = 0) { + if($this->connector->isActiveClient()) { + $this->connector->getDebugDispatcher()->dispatchDebug($data, $tags, $skipTraceCalls + 1); + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Helper.php b/vendor/php-console/php-console/src/PhpConsole/Helper.php new file mode 100644 index 0000000..195ff2b --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Helper.php @@ -0,0 +1,121 @@ +debug($var, 'db') + * + * @package PhpConsole + * @version 3.1 + * @link http://php-console.com + * @author Sergey Barbushin http://linkedin.com/in/barbushin + * @copyright © Sergey Barbushin, 2011-2013. All rights reserved. + * @license http://www.opensource.org/licenses/BSD-3-Clause "The BSD 3-Clause License" + */ + class Helper { + + /** @var Connector|null */ + private static $connector; + /** @var Handler|null */ + private static $handler; + /** @var bool */ + protected static $isActive; + + private function __construct() { + } + + /** + * This method must be called to make class "PC" available + * @param Connector|null $connector + * @param Handler|null $handler + * @throws \Exception + * @return Connector + */ + public static function register(Connector $connector = null, Handler $handler = null) { + if(static::$connector) { + throw new \Exception('Helper already registered'); + } + self::$handler = $handler; + self::$connector = $connector ? : Connector::getInstance(); + self::$isActive = self::$connector->isActiveClient(); + return self::$connector; + } + + /** + * Check if method Helper::register() was called before + * @return bool + */ + public static function isRegistered() { + return isset(self::$connector); + } + + /** + * Get actual helper connector instance + * @return Connector + * @throws \Exception + */ + public static function getConnector() { + if(!self::$connector) { + throw new \Exception('Helper is not registered. Call ' . get_called_class() . '::register()'); + } + return self::$connector; + } + + /** + * Get actual handler instance + * @return Handler + * @throws \Exception + */ + public static function getHandler() { + if(!self::$connector) { + throw new \Exception('Helper is not registered. Call ' . get_called_class() . '::register()'); + } + if(!self::$handler) { + self::$handler = Handler::getInstance(); + } + return self::$handler; + } + + /** + * Analog of Handler::getInstance()->debug(...) method + * @param mixed $data + * @param string|null $tags Tags separated by dot, e.g. "low.db.billing" + * @param int $skipTraceCalls Number of proxy methods between original "debug method call" and this method call + */ + public static function debug($data, $tags = null, $skipTraceCalls = 0) { + if(self::$isActive) { + self::$connector->getDebugDispatcher()->dispatchDebug($data, $tags, $skipTraceCalls + 1); + } + } + + /** + * Short access to analog of Handler::getInstance()->debug(...) method + * You can access it like PC::tagName($debugData, $additionalTags = null) + * @param string $tags + * @param $args + */ + public static function __callStatic($tags, $args) { + if(isset($args[1])) { + $tags .= '.' . $args[1]; + } + static::debug(isset($args[0]) ? $args[0] : null, $tags, 1); + } + } +} + +namespace { + if(!class_exists('PC', false)) { + /** + * Helper short class name in global namespace + */ + class PC extends \PhpConsole\Helper { + + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/OldVersionAdapter.php b/vendor/php-console/php-console/src/PhpConsole/OldVersionAdapter.php new file mode 100644 index 0000000..613a9d9 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/OldVersionAdapter.php @@ -0,0 +1,123 @@ +start($handleErrors = true, $handleExceptions = true, $sourceBasePath = null); + * PhpConsole::debug('message', 'some,tags'); + * debug('message', 'some,tags'); + * + * IMPORTANT: This adapter will be removed in PhpConsole > v3, so it's strongly recommended to migrate your code using original PhpConsole v3 methods + * + * @package PhpConsole + * @version 3.1 + * @link http://php-console.com + * @author Sergey Barbushin http://linkedin.com/in/barbushin + * @copyright © Sergey Barbushin, 2011-2013. All rights reserved. + * @license http://www.opensource.org/licenses/BSD-3-Clause "The BSD 3-Clause License" + */ + class OldVersionAdapter { + + public static $callOldErrorHandler = true; + public static $callOldExceptionsHandler = true; + + /** @var OldVersionAdapter|null */ + protected static $instance; + + private function __construct() { + } + + /** + * This method must be called just to force \PhpConsole class initialization + * @param Connector|null $connector + * @param Handler|null $handler + * @throws \Exception + * @return Connector + */ + public static function register(Connector $connector = null, Handler $handler = null) { + } + + /** + * Start PhpConsole v1 handler + * @param bool $handleErrors + * @param bool $handleExceptions + * @param null|string $sourceBasePath + */ + public static function start($handleErrors = true, $handleExceptions = true, $sourceBasePath = null) { + if(self::$instance) { + die('PhpConsole already started'); + } + self::$instance = new static(); + + $handler = Handler::getInstance(); + $handler->setHandleErrors($handleErrors); + $handler->setHandleExceptions($handleExceptions); + $handler->setCallOldHandlers(self::$callOldErrorHandler || self::$callOldExceptionsHandler); + $handler->start(); + + $connector = $handler->getConnector(); + $connector->setSourcesBasePath($sourceBasePath); + } + + public static function getInstance() { + if(!self::$instance) { + throw new \Exception('PhpConsole not started'); + } + return self::$instance; + } + + /** + * @return Connector + */ + public function getConnector() { + return Connector::getInstance(); + } + + /** + * @return Handler + */ + public function getHandler() { + return Handler::getInstance(); + } + + public function handleError($code = null, $message = null, $file = null, $line = null) { + $this->getHandler()->handleError($code, $message, $file, $line, null, 1); + } + + public function handleException(\Exception $exception) { + $this->getHandler()->handleException($exception); + } + + public static function debug($message, $tags = 'debug') { + Handler::getInstance()->debug($message, str_replace(',', '.', $tags), 1); + } + } +} + +namespace { + + if(!class_exists('PhpConsole', false)) { + class PhpConsole extends \PhpConsole\OldVersionAdapter { + + } + } + + if(!function_exists('debug')) { + function debug($message, $tags = 'debug') { + \PhpConsole\Handler::getInstance()->debug($message, $tags, 1); + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/PsrLogger.php b/vendor/php-console/php-console/src/PhpConsole/PsrLogger.php new file mode 100644 index 0000000..094c580 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/PsrLogger.php @@ -0,0 +1,77 @@ + 'notice', + LogLevel::INFO => 'info', + LogLevel::DEBUG => 'debug', + ); + + public static $errorsLevels = array( + LogLevel::EMERGENCY => 'PSR_EMERGENCY', + LogLevel::ALERT => 'PSR_ALERT', + LogLevel::CRITICAL => 'PSR_CRITICAL', + LogLevel::ERROR => 'PSR_ERROR', + LogLevel::WARNING => 'PSR_WARNING', + ); + + /** @var Connector */ + protected $connector; + /** @var Dumper */ + protected $contextDumper; + + public function __construct(Connector $connector = null, Dumper $contextDumper = null) { + $this->connector = $connector ? : Connector::getInstance(); + $this->contextDumper = $contextDumper ? : $this->connector->getDumper(); + } + + /** + * Logs with an arbitrary level. + * + */ + public function log($level, $message, array $context = array()) { + if(is_object($message) && is_callable($message, '__toString')) { + $message = (string)$message; + } + $message = $this->fetchMessageContext($message, $context); + + if(isset(static::$debugLevels[$level])) { + $this->connector->getDebugDispatcher()->dispatchDebug($message, static::$debugLevels[$level], null); + } + elseif(isset(static::$errorsLevels[$level])) { + if(isset($context['exception']) && $context['exception'] instanceof \Exception) { + $this->connector->getErrorsDispatcher()->dispatchException($context['exception']); + } + else { + $this->connector->getErrorsDispatcher()->dispatchError(static::$errorsLevels[$level], $message, null, null, null); + } + } + else { + throw new \Psr\Log\InvalidArgumentException('Unknown log level "' . $level . '"'); + } + } + + protected function fetchMessageContext($message, array $context) { + $replace = array(); + foreach($context as $key => $value) { + $replace['{' . $key . '}'] = $this->contextDumper->dump($value); + } + return strtr($message, $replace); + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Storage.php b/vendor/php-console/php-console/src/PhpConsole/Storage.php new file mode 100644 index 0000000..6a8557a --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Storage.php @@ -0,0 +1,40 @@ +keyLifetime = $seconds; + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Storage/AllKeysList.php b/vendor/php-console/php-console/src/PhpConsole/Storage/AllKeysList.php new file mode 100644 index 0000000..87a9425 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Storage/AllKeysList.php @@ -0,0 +1,71 @@ +getKeysData(); + if(isset($keysData[$key])) { + $keyData = $keysData[$key]['data']; + unset($keysData[$key]); + $this->saveKeysData($keysData); + return $keyData; + } + } + + /** + * Save postponed data to storage + * @param string $key + * @param string $data + */ + public function push($key, $data) { + $keysData = $this->getKeysData(); + $this->clearExpiredKeys($keysData); + $keysData[$key] = array( + 'time' => time(), + 'data' => $data + ); + $this->saveKeysData($keysData); + } + + /** + * Remove postponed data that is out of limit + * @param array $keysData + */ + protected function clearExpiredKeys(array &$keysData) { + $expireTime = time() - $this->keyLifetime; + foreach($keysData as $key => $item) { + if($item['time'] < $expireTime) { + unset($keysData[$key]); + } + } + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Storage/ExpiringKeyValue.php b/vendor/php-console/php-console/src/PhpConsole/Storage/ExpiringKeyValue.php new file mode 100644 index 0000000..820f504 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Storage/ExpiringKeyValue.php @@ -0,0 +1,60 @@ +get($key); + if($data) { + $this->delete($key); + } + return $data; + } + + /** + * Save postponed data to storage + * @param string $key + * @param string $data + */ + public function push($key, $data) { + $this->set($key, $data, $this->keyLifetime); + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Storage/File.php b/vendor/php-console/php-console/src/PhpConsole/Storage/File.php new file mode 100644 index 0000000..28230a2 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Storage/File.php @@ -0,0 +1,93 @@ +filePath = realpath($filePath); + + if($validatePathNotUnderDocRoot && $this->isPathUnderDocRoot()) { + throw new \Exception('Path ' . $this->filePath . ' is under DOCUMENT_ROOT. It\'s insecure!'); + } + } + + protected function isPathUnderDocRoot() { + return !empty($_SERVER['DOCUMENT_ROOT']) && strpos($this->filePath, $_SERVER['DOCUMENT_ROOT']) === 0; + } + + protected function initFileHandler() { + $this->fileHandler = fopen($this->filePath, 'a+b'); + if(!$this->fileHandler) { + throw new \Exception('Unable to read/write file ' . $this->filePath); + } + while(!flock($this->fileHandler, LOCK_EX | LOCK_NB)) { + usleep(10000); + } + fseek($this->fileHandler, 0); + } + + /** + * @throws \Exception + * @return array + */ + protected function getKeysData() { + return json_decode(fgets($this->fileHandler), true) ? : array(); + } + + /** + * @param array $keysData + */ + protected function saveKeysData(array $keysData) { + ftruncate($this->fileHandler, 0); + fwrite($this->fileHandler, json_encode($keysData, defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : null)); + } + + protected function closeFileHandler() { + if($this->fileHandler) { + flock($this->fileHandler, LOCK_UN); + fclose($this->fileHandler); + $this->fileHandler = null; + } + } + + public function pop($key) { + $this->initFileHandler(); + $result = parent::pop($key); + $this->closeFileHandler(); + return $result; + } + + public function push($key, $data) { + $this->initFileHandler(); + parent::push($key, $data); + $this->closeFileHandler(); + } + + public function __destruct() { + $this->closeFileHandler(); + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Storage/Memcache.php b/vendor/php-console/php-console/src/PhpConsole/Storage/Memcache.php new file mode 100644 index 0000000..04a2fa0 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Storage/Memcache.php @@ -0,0 +1,54 @@ +memcache = new \Memcache(); + if(!$this->memcache->connect($host, $port)) { + throw new \Exception('Unable to connect to Memcache server'); + } + } + + /** + * Save data by auto-expire key + * @param $key + * @param string $data + * @param int $expire + */ + protected function set($key, $data, $expire) { + $this->memcache->set($key, $data, null, $expire); + } + + /** + * Get data by key if not expired + * @param $key + * @return string + */ + protected function get($key) { + return $this->memcache->get($key); + } + + /** + * Remove key in store + * @param $key + * @return mixed + */ + protected function delete($key) { + $this->memcache->delete($key); + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/Storage/Session.php b/vendor/php-console/php-console/src/PhpConsole/Storage/Session.php new file mode 100644 index 0000000..160411d --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/Storage/Session.php @@ -0,0 +1,38 @@ +sessionKey = $sessionKey; + } + + protected function getKeysData() { + return isset($_SESSION[$this->sessionKey]) ? $_SESSION[$this->sessionKey] : array(); + } + + protected function saveKeysData(array $keysData) { + $_SESSION[$this->sessionKey] = $keysData; + } +} diff --git a/vendor/php-console/php-console/src/PhpConsole/__autoload.php b/vendor/php-console/php-console/src/PhpConsole/__autoload.php new file mode 100644 index 0000000..0ed1be2 --- /dev/null +++ b/vendor/php-console/php-console/src/PhpConsole/__autoload.php @@ -0,0 +1,10 @@ +serverWrapperUrl = $serverWrapperUrl; + $this->secretKey = $secretKey; + $this->scriptsBaseDir = realpath($scriptsBaseDir); + } + + public function getScriptsBaseDir() { + return $this->scriptsBaseDir; + } + + public function getPostDataSignature($rawPostData) { + return hash('sha256', $rawPostData . $this->secretKey); + } + + /** + * @param Request $request + * @param bool $postponedResponseId + * @param null $postponedOutput + * @throws RequestFailed + * @return Response + */ + public function sendRequest(Request $request, $postponedResponseId = null, $postponedOutput = null) { + $clientData = $request->getClientData(); + if($clientData) { + $request->cookies[\PhpConsole\Connector::CLIENT_INFO_COOKIE] = base64_encode(json_encode($clientData)); + } + + if($postponedResponseId) { + $request->postData[\PhpConsole\Connector::POST_VAR_NAME] = array( + 'getPostponedResponse' => $postponedResponseId + ); + } + + $request->postData[static::POST_VAR_NAME] = array( + 'scripts' => $request->getScripts(), + ); + + $postData = $request->postData; + array_walk_recursive($postData, function (&$item) { + if(!is_object($item)) { + $item = base64_encode($item); + } + }); + $rawPostData = serialize($postData); + + $url = $request->isSsl ? str_replace('http://', 'https://', $this->serverWrapperUrl) : $this->serverWrapperUrl; + + $curlOptions = array( + CURLOPT_URL => $url . '?signature=' . $this->getPostDataSignature($rawPostData), + CURLOPT_CONNECTTIMEOUT => 100, + CURLOPT_TIMEOUT => 100, + CURLOPT_HEADER => true, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $rawPostData, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_MAXREDIRS => 3, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_SSL_VERIFYHOST => false, + ); + + if($request->cookies) { + $cookiesData = array(); + foreach($request->cookies as $name => $value) { + $cookiesData[] = rawurlencode($name) . '=' . rawurlencode($value); + } + $curlOptions[CURLOPT_COOKIE] = implode('; ', $cookiesData); + } + + $curlHandle = curl_init(); + curl_setopt_array($curlHandle, $curlOptions); + $responseData = curl_exec($curlHandle); + $code = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + $error = curl_error($curlHandle); + + $responseHeaders = substr($responseData, 0, curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE)); + if(substr($responseHeaders, -1) !== "\n") { // because curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE) is bugged on some PHP versions + $responseHeaders = substr($responseData, 0, strpos($responseData, PHP_EOL . PHP_EOL)); + } + + $responseOutput = substr($responseData, strlen($responseHeaders)); + curl_close($curlHandle); + + $response = new Response(); + $response->code = $code; + $response->output = (string)($postponedResponseId ? $postponedOutput : $responseOutput); + $response->headerData = $this->parseHeaderData($responseHeaders); + $response->cookies = $this->parseCookies($responseHeaders); + + try { + if($error || ($code != 200 && $code != 204 && $code != 500)) { + throw new \Exception('Connection to "' . $this->serverWrapperUrl . '" failed with code "' . $code . '" and error: ' . $error . '" and response: "' . $responseOutput, $code); + } + $packageEncodedData = $postponedResponseId ? $responseOutput : $response->headerData; + if($packageEncodedData) { + $packageData = $this->jsonDecode($packageEncodedData); + if(!empty($packageData['isPostponed'])) { + $request->cookies = $response->cookies; + $response = $this->sendRequest($request, $packageData['id'], $responseOutput); + $response->isPostponed = true; + return $response; + } + $response->package = $this->initResponsePackage($packageData); + } + } + catch(\Exception $exception) { + throw new RequestFailed($exception, $request, $response); + } + + return $response; + } + + public function getScriptPath($alias) { + return $this->scriptsBaseDir . DIRECTORY_SEPARATOR . basename($alias) . '.php'; + } + + public function handleClientEmulatorRequest() { + $_POST = unserialize(file_get_contents('php://input')); + if($_POST === false) { + throw new \Exception('Wrong format of raw POST data'); + } + array_walk_recursive($_POST, function (&$item) { + if(!is_object($item)) { + $item = base64_decode($item); + } + }); + if(!isset($_GET['signature']) || $this->getPostDataSignature(file_get_contents('php://input')) != $_GET['signature']) { + throw new \Exception('Wrong request signature'); + } + if(!empty($_POST[static::POST_VAR_NAME]['scripts'])) { + foreach($_POST[static::POST_VAR_NAME]['scripts'] as $script) { + $scriptPath = $this->getScriptPath($script['alias']); + if(!is_file($scriptPath)) { + throw new \Exception('Script with alias "' . $script['alias'] . '" not found in ' . $scriptPath); + } + $this->runScript($script['alias'], isset($script['params']) ? $script['params'] : array()); + } + } + } + + protected function runScript($_alias, $_params) { + extract($_params, EXTR_SKIP); + require($this->getScriptPath($_alias)); + } + + protected function parseHeaderData($headersData) { + if(preg_match_all('/\n\s*' . preg_quote(\PhpConsole\Connector::HEADER_NAME) . '\s*:\s*(.*?)[\r\n]/', $headersData, $m)) { + if(count($m[1]) > 1) { + throw new \Exception('There is more than one "' . \PhpConsole\Connector::HEADER_NAME . '" header'); + } + return rawurldecode($m[1][0]); + } + elseif(preg_match_all('/\n\s*' . preg_quote(\PhpConsole\Connector::POSTPONE_HEADER_NAME) . '\s*:\s*(.*?)[\r\n]/', $headersData, $m)) { + if(count($m[1]) > 1) { + throw new \Exception('There is more than one "' . \PhpConsole\Connector::POSTPONE_HEADER_NAME . '" header'); + } + return rawurldecode($m[1][0]); + } + } + + protected function parseCookies($headersData) { + $cookies = array(); + preg_match_all('/Set-Cookie:\s*(.*?)=(.*?);/i', $headersData, $m); + foreach($m[1] as $i => $name) { + if($m[2][$i] != 'deleted') { + $cookies[$name] = rawurldecode($m[2][$i]); + } + } + return $cookies; + } + + /** + * + * @param array $packageData + * @throws \Exception + * @return \PhpConsole\Response|null + */ + protected function initResponsePackage(array $packageData) { + $package = new \PhpConsole\Response($packageData); + if($package->auth) { + $package->auth = new \PhpConsole\ServerAuthStatus($package->auth); + } + return $package; + } + + protected function jsonDecode($json) { + $data = @json_decode($json, true); + if(!$data || json_last_error()) { + throw new \Exception('Decoding json failed with error code ' . json_last_error() . '. JSON: ' . $json); + } + return $data; + } +} + +class RequestFailed extends \Exception { + + public $request; + public $response; + + function __construct(\Exception $previous, Request $request, Response $response) { + $this->request = $request; + $this->response = $response; + parent::__construct('ClientEmulator request failed with error: ' . $previous->getMessage(), 0, $previous); + } +} diff --git a/vendor/php-console/php-console/tests/ClientEmulator/Request.php b/vendor/php-console/php-console/tests/ClientEmulator/Request.php new file mode 100644 index 0000000..0c0a944 --- /dev/null +++ b/vendor/php-console/php-console/tests/ClientEmulator/Request.php @@ -0,0 +1,33 @@ +clientData = $clientData; + } + + public function getClientData() { + return $this->clientData; + } + + public function addScript($alias, array $params = array()) { + $this->scripts[] = array( + 'alias' => $alias, + 'params' => $params + ); + } + + public function getScripts() { + return $this->scripts; + } +} diff --git a/vendor/php-console/php-console/tests/ClientEmulator/Response.php b/vendor/php-console/php-console/tests/ClientEmulator/Response.php new file mode 100644 index 0000000..a99edb6 --- /dev/null +++ b/vendor/php-console/php-console/tests/ClientEmulator/Response.php @@ -0,0 +1,14 @@ +connector = \PhpConsole\Connector::getInstance(); + } + + public function testIsSingleton() { + $this->assertIsSingleton('\PhpConsole\Connector'); + } + + public function testIsNotActiveClientByDefault() { + $this->assertFalse(\PhpConsole\Connector::getInstance()->isActiveClient()); + } + + public function testIsNotAuthorizedByDefault() { + $this->assertFalse(\PhpConsole\Connector::getInstance()->isAuthorized()); + } + + public function testGetDebugDispatcher() { + $this->assertInstanceOf('\PhpConsole\Dispatcher\Debug', $this->connector->getDebugDispatcher()); + } + + public function testSetDebugDispatcher() { + $dispatcher = new \PhpConsole\Dispatcher\Debug($this->connector, new \PhpConsole\Dumper()); + $this->connector->setDebugDispatcher($dispatcher); + $this->assertEquals(spl_object_hash($dispatcher), spl_object_hash($this->connector->getDebugDispatcher())); + } + + public function testGetErrorsDispatcher() { + $this->assertInstanceOf('\PhpConsole\Dispatcher\Errors', $this->connector->getErrorsDispatcher()); + } + + public function testSetErrorsDispatcher() { + $dispatcher = new \PhpConsole\Dispatcher\Errors($this->connector, new \PhpConsole\Dumper()); + $this->connector->setErrorsDispatcher($dispatcher); + $this->assertEquals(spl_object_hash($dispatcher), spl_object_hash($this->connector->getErrorsDispatcher())); + } + + public function testSetEvalDispatcher() { + $dispatcher = new \PhpConsole\Dispatcher\Evaluate($this->connector, new \PhpConsole\EvalProvider(), new \PhpConsole\Dumper()); + $this->connector->setEvalDispatcher($dispatcher); + $this->assertEquals(spl_object_hash($dispatcher), spl_object_hash($this->connector->getEvalDispatcher())); + } + + public function testGetEvalDispatcher() { + $this->assertInstanceOf('\PhpConsole\Dispatcher\Evaluate', $this->connector->getEvalDispatcher()); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Dispatcher.php b/vendor/php-console/php-console/tests/Test/Dispatcher.php new file mode 100644 index 0000000..6b5ef63 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Dispatcher.php @@ -0,0 +1,40 @@ +connector = $this->initConnectorMock(); + $this->dispatcher = $this->initDispatcher($this->connector); + } + + protected function initConnectorMock() { + $connector = $this->getMockBuilder('\PhpConsole\Connector') + ->disableOriginalConstructor() + ->setMethods(array('sendMessage', 'isActiveClient')) + ->getMock(); + + $isDispatcherActive =& $this->isDispatcherActive; + $connector->expects($this->any()) + ->method('isActiveClient') + ->will($this->returnCallback(function () use (&$isDispatcherActive) { + return $isDispatcherActive; + })); + + return $connector; + } +} diff --git a/vendor/php-console/php-console/tests/Test/Dispatcher/Debug.php b/vendor/php-console/php-console/tests/Test/Dispatcher/Debug.php new file mode 100644 index 0000000..7fa0b8b --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Dispatcher/Debug.php @@ -0,0 +1,83 @@ +connector->expects($this->once())->method('sendMessage'); + $this->dispatcher->dispatchDebug(123); + } + + public function testDispatchIgnoredOnNotActiveClient() { + $this->isDispatcherActive = false; + $this->connector->expects($this->never())->method('sendMessage'); + $this->dispatcher->dispatchDebug(123); + } + + public function testDispatchDebugTagsAndData() { + $debug = array( + 'data' => 123, + 'tags' => array('t', 'a', 'g', 's'), + ); + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\DebugMessage $message) use ($test, $debug) { + $test->assertContainsRecursive($debug, $message); + return true; + })); + $this->dispatcher->dispatchDebug($debug['data'], implode('.', $debug['tags'])); + } + + public function testDispatchDataIsDumped() { + $this->dispatcher->setDumper(new \PhpConsole\Dumper(1, 1, 9)); + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->equalTo(new \PhpConsole\DebugMessage(array( + 'data' => '123456...', + )))); + $this->dispatcher->dispatchDebug('1234567890'); + } + + public function testTraceAndSourceDetectionDisabledByDefault() { + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\DebugMessage $message) use ($test) { + $test->assertEmpty($message->trace); + return true; + })); + $this->dispatcher->dispatchDebug(123); + } + + public function testSourceAndTraceDetection() { + $lastCallLine = null; + $test = $this; + $this->dispatcher->detectTraceAndSource = true; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\DebugMessage $message) use ($test, &$lastCallLine) { + $test->assertEquals(__FILE__, $message->file); + $test->assertEquals($message->data['line'], $message->line); + $test->assertEquals(new \PhpConsole\TraceCall(array( + 'file' => __FILE__, + 'line' => $lastCallLine, + 'call' => $message->data['class'] . '->' . $message->data['method'] . '(' . $lastCallLine . ', NULL, true, \'01234567890123...\', Array[2], stdClass)' + )), end($message->trace)); + return true; + })); + $this->callDispatchDebug($lastCallLine = __LINE__, null, true, '0123456789012345', array(1, 2), new \stdClass()); + } + + protected function callDispatchDebug() { + $this->dispatcher->dispatchDebug(array('class' => get_class($this), 'method' => __FUNCTION__, 'line' => __LINE__)); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Dispatcher/Errors.php b/vendor/php-console/php-console/tests/Test/Dispatcher/Errors.php new file mode 100644 index 0000000..bdaaa5c --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Dispatcher/Errors.php @@ -0,0 +1,161 @@ +connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test) { + $test->assertContainsRecursive(array( + 'type' => 'error', + 'code' => E_WARNING, + 'class' => 'E_WARNING', + 'data' => 'error_text', + 'file' => __FILE__, + 'line' => 100, + ), $message); + return true; + })); + $this->dispatcher->dispatchError(E_WARNING, 'error_text', __FILE__, 100); + } + + public function testDispatchErrorMessageIsDumped() { + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test) { + $test->assertEquals('123456...', $message->data); + return true; + })); + $this->dispatcher->setDumper(new \PhpConsole\Dumper(1, 1, 9)); + $this->dispatcher->dispatchError(null, 1234567890); + } + + public function testDispatchErrorActualTrace() { + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test) { + $lastCall = end($message->trace); + $test->assertContains(__CLASS__, $lastCall->call); + $test->assertContains($test->getName(), $lastCall->call); + return true; + })); + $this->dispatcher->dispatchError(); + } + + public function testDispatchExceptionMessageData() { + $test = $this; + $exception = new \Exception('exception_test', 100); + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test, $exception) { + $test->assertContainsRecursive(array( + 'type' => 'error', + 'code' => $exception->getCode(), + 'class' => get_class($exception), + 'data' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + ), $message); + return true; + })); + $this->dispatcher->dispatchException($exception); + } + + public function testDispatchExceptionMessageIsDumped() { + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test) { + $test->assertEquals('123456...', $message->data); + return true; + })); + $this->dispatcher->setDumper(new \PhpConsole\Dumper(1, 1, 9)); + $this->dispatcher->dispatchException(new \Exception(1234567890)); + } + + public function testDispatchExceptionActualTrace() { + $test = $this; + $exception = new \Exception(); + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test) { + $lastCall = end($message->trace); + $test->assertContains(__CLASS__, $lastCall->call); + $test->assertContains($test->getName(), $lastCall->call); + return true; + })); + $this->dispatcher->dispatchException($exception); + } + + public function testDispatchPreviousExceptions() { + $this->connector->expects($this->exactly(3))->method('sendMessage'); + $this->dispatcher->dispatchException(new \Exception(null, 0, + new \Exception(null, 0, + new \Exception()))); + } + + public function testDisableDispatchPreviousExceptions() { + $this->connector->expects($this->once())->method('sendMessage'); + $this->dispatcher->dispatchPreviousExceptions = false; + $this->dispatcher->dispatchException(new \Exception(null, 0, + new \Exception(null, 0, + new \Exception()))); + } + + public function testDispatchErrorIgnoreRepeatedSource() { + $this->connector->expects($this->once())->method('sendMessage'); + $this->dispatcher->dispatchError(null, null, __FILE__, 100); + $this->dispatcher->dispatchError(null, null, __FILE__, 100); + } + + public function testDispatchErrorNotIgnoreRepeatedSourceDifferentClass() { + $this->connector->expects($this->exactly(2))->method('sendMessage'); + $this->dispatcher->dispatchError(E_WARNING, null, __FILE__, 100); + $this->dispatcher->dispatchError(E_NOTICE, null, __FILE__, 100); + } + + public function testDispatchErrorWithDisabledIgnoreRepeatedSource() { + $this->dispatcher->ignoreRepeatedSource = false; + $this->connector->expects($this->exactly(2))->method('sendMessage'); + $this->dispatcher->dispatchError(null, null, __FILE__, 100); + $this->dispatcher->dispatchError(null, null, __FILE__, 100); + } + + public function testDispatchExceptionIgnoreRepeatedSource() { + $this->connector->expects($this->once())->method('sendMessage'); + $exception = new \Exception(); + $this->dispatcher->dispatchException($exception); + $this->dispatcher->dispatchException($exception); + } + + public function testDispatchExceptionNotIgnoreRepeatedSourceDifferentClass() { + $this->connector->expects($this->exactly(2))->method('sendMessage'); + $exception1 = new \Exception('', 0, $exception2 = new Dispatcher_ErrorsDraftException()); + $this->dispatcher->dispatchException($exception1); + $this->dispatcher->dispatchException($exception2); + } + + public function testDispatchExceptionWithDisabledIgnoreRepeatedSource() { + $this->dispatcher->ignoreRepeatedSource = false; + $this->connector->expects($this->exactly(2))->method('sendMessage'); + $exception = new \Exception(); + $this->dispatcher->dispatchException($exception); + $this->dispatcher->dispatchException($exception); + } +} + +class Dispatcher_ErrorsDraftException extends \Exception { + +} diff --git a/vendor/php-console/php-console/tests/Test/Dispatcher/Eval.php b/vendor/php-console/php-console/tests/Test/Dispatcher/Eval.php new file mode 100644 index 0000000..fa7edc4 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Dispatcher/Eval.php @@ -0,0 +1,128 @@ +connector->expects($this->once())->method('sendMessage'); + $this->dispatcher->dispatchCode('return 123'); + } + + public function testDispatchIgnoredOnNotActiveClient() { + $this->isDispatcherActive = false; + $this->connector->expects($this->never())->method('sendMessage'); + $this->dispatcher->dispatchCode('return 123'); + } + + public function testDispatchMessageData() { + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\EvalResultMessage $message) use ($test) { + $test->assertContainsRecursive(array( + 'type' => 'eval_result', + 'return' => 321, + 'output' => 123, + ), $message); + $test->assertTrue($message->time > 0 && $message->time < 1); + return true; + })); + + $this->dispatcher->dispatchCode('echo 123; usleep(1000); return 321;'); + } + + public function testDispatchDataIsDumped() { + $dumper = new \PhpConsole\Dumper(1, 1, 10); + $this->dispatcher->setDumper($dumper); + + $actualString = str_repeat('x', $dumper->itemSizeLimit + 10); + $dumpedString = $dumper->dump($actualString); + $this->assertTrue(strlen($dumpedString) < strlen($actualString)); + + $test = $this; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\EvalResultMessage $message) use ($test, $dumpedString) { + $test->assertEquals($dumpedString, $message->return); + $test->assertEquals($dumpedString, $message->output); + return true; + })); + + $this->dispatcher->dispatchCode('echo "' . $actualString . '"; return "' . $actualString . '";'); + } + + public function testGetEvalProvider() { + $this->assertInstanceOf('\PhpConsole\EvalProvider', $this->dispatcher->getEvalProvider()); + } + + public function testSetEvalProvider() { + $evalProvider = new \PhpConsole\EvalProvider(); + $this->dispatcher->setEvalProvider($evalProvider); + $this->assertEquals(spl_object_hash($evalProvider), spl_object_hash($this->dispatcher->getEvalProvider())); + } + + public function testEvalErrorIsDispatched() { + $test = $this; + + $this->connector->expects($this->at(2)) + ->method('sendMessage') + ->with($this->callback(function ($message) use ($test) { + $test->assertContainsRecursive(array( + 'type' => 'error', + 'code' => E_PARSE, + 'line' => 1, + ), $message); + return true; + })); + + $this->connector->expects($this->at(3)) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\Message $message) use ($test) { + $test->assertContainsRecursive(array( + 'type' => 'eval_result', + 'return' => null, + 'output' => null, + ), $message); + return true; + })); + + $this->dispatcher->dispatchCode('if('); + } + + public function testEvalExceptionIsDispatched() { + $test = $this; + + $this->connector->expects($this->at(2)) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\Message $message) use ($test) { + $test->assertContainsRecursive(array( + 'type' => 'error', + 'class' => 'Exception', + 'data' => 321, + 'line' => 1, + ), $message); + return true; + })); + + $this->connector->expects($this->at(3)) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\Message $message) use ($test) { + $test->assertContainsRecursive(array( + 'type' => 'eval_result', + 'return' => null, + 'output' => 123, + ), $message); + return true; + })); + + $this->dispatcher->dispatchCode('echo 123; throw new Exception(321)'); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Dumper.php b/vendor/php-console/php-console/tests/Test/Dumper.php new file mode 100644 index 0000000..e3c2e42 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Dumper.php @@ -0,0 +1,177 @@ +dumper = new \PhpConsole\Dumper(); + } + + public function testScalarItemSizeLimit() { + $this->dumper->itemSizeLimit = 5; + $dumpedString = $this->dumper->dump(str_repeat('x', $this->dumper->itemSizeLimit * 2)); + $this->assertEquals($this->dumper->itemSizeLimit, strlen($dumpedString)); + $this->assertStringEndsWith('...', $dumpedString); + } + + public function testScalarDumpSizeLimit() { + $this->dumper->dumpSizeLimit = 5; + $dumpedString = $this->dumper->dump(str_repeat('x', $this->dumper->dumpSizeLimit * 2)); + $this->assertEquals($this->dumper->dumpSizeLimit, strlen($dumpedString)); + $this->assertStringEndsWith('...', $dumpedString); + } + + public function testItemsCountLimit() { + $this->dumper->itemsCountLimit = 3; + $source = array(1, 2, 3, 4, 5); + $expected = array(1, 2, 3, '...' => '(displayed 3 of 5)'); + $this->assertEquals($expected, $this->dumper->dump($source)); + $this->assertEquals(array(array($expected)), $this->dumper->dump(array(array($source)))); + } + + public function testLevelLimit() { + $this->dumper->levelLimit = 2; + $source = array( + 0, + 1 => array(2 => array(3 => array(4 => array()))), + array(2, array(3, array(4, array()))), + ); + $expected = array( + 0 => 0, + 1 => + array( + 2 => '(array)', + ), + 2 => + array( + 0 => 2, + 1 => '(array)', + )); + $this->assertEquals($expected, $this->dumper->dump($source)); + } + + public function testMixedDataLimits() { + $this->dumper->levelLimit = 3; + $this->dumper->itemsCountLimit = 3; + $this->dumper->itemSizeLimit = 5; + + $source = new \stdClass(); + $source->null = null; + $source->scalar = 123456; + $source->obj = new \stdClass(); + $source->obj->sca = 345678; + $source->obj->arr = array(array()); + $source->array = array( + 'scalar' => 234567, + 'obj' => new \stdClass(), + 3 => array(33), + 4, + 5 + ); + + $expected = array( + ':stdClass' => array( + 'null' => null, + 'scalar' => '12...', + 'obj:stdClass' => array( + 'sca' => '34...', + 'arr' => array( + 0 => '(array)', + ), + ), + '...' => '(displayed 3 of 4)', + )); + + $this->assertEquals($expected, $this->dumper->dump($source)); + } + + public function testDumpBinaryData() { + $binaryData = sha1(123, true); + $this->assertEquals($binaryData, $this->dumper->dump($binaryData)); + $this->dumper->itemSizeLimit = 10; + $this->assertEquals(substr($binaryData, 0, 7) . '...', $this->dumper->dump($binaryData)); + } + + public function testObjectProtectedPrivateProperties() { + $this->assertEquals(array( + ':PhpConsole\Test\DumperDraftClass' => array( + 'public' => 321, + 'protected' => 123, + 'private' => 234, + )), $this->dumper->dump(new DumperDraftClass())); + } + + public function testObjectsRecursion() { + $object = new \stdClass(); + $object->obj = $object; + $this->assertEquals(array( + ':stdClass' => array( + 'obj:stdClass' => '*RECURSION*' + )), $this->dumper->dump($object)); + } + + public function testFunctionDump() { + $function = function () { + }; + $this->assertEquals('(callback function)', $this->dumper->dump($function)); + $this->assertEquals(array('(callback function)'), $this->dumper->dump(array($function))); + } + + public function testCallbacksDump() { + $object = new DumperDraftClass(); + $source = array( + array($object, 'publicMethod'), + array('PhpConsole\Test\DumperDraftClass', 'staticMethod') + ); + $this->assertEquals(array( + 0 => '(callback PhpConsole\Test\DumperDraftClass::publicMethod)', + 1 => '(callback PhpConsole\Test\DumperDraftClass::staticMethod)' + ), $this->dumper->dump($source)); + } + + public function testDumpSizeLimit() { + $this->dumper->dumpSizeLimit = 50; + $source = array( + 1, + 2 => array( + 21, + 22 + ), + 3 => array(33), + 4, + 5 + ); + $expected = array( + 0 => 1, + 2 => + array( + 0 => 21, + '...' => '(displayed 1 of 2)', + ), + 3 => array( + 0 => 33, + ), + 4 => 4, + 5 => 5, + ); + $this->assertEquals($expected, $this->dumper->dump($source)); + } +} + +class DumperDraftClass { + + public $public = 321; + protected $protected = 123; + private $private = 234; + + public function publicMethod() { + } + + public static function staticMethod() { + } +} diff --git a/vendor/php-console/php-console/tests/Test/EvalProvider.php b/vendor/php-console/php-console/tests/Test/EvalProvider.php new file mode 100644 index 0000000..377440b --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/EvalProvider.php @@ -0,0 +1,112 @@ +evalProvider = new \PhpConsole\EvalProvider(); + } + + public static function provideEvalCodeAndExpectedReturns() { + return array( + // forceEndingSemicolon + array('return 123', 123), + array('return 123;', 123), + array('if(true) { return 123; }', 123), + // trimPhpTags + array('', 123), + array('', 123), + array('', 123), + array('', null, 123), + array('echo 3; ?>2evalProvider->evaluate($code); + $this->assertEquals($expectedReturn, $result->return); + $this->assertEquals($expectedOutput, $result->output); + $this->assertNull($result->exception); + } + + public function testEvalExecuteMethodIsStatic() { + $this->assertFalse($this->evalProvider->evaluate('return isset($this)')->return); + } + + public function testTimeInResult() { + $time = $this->evalProvider->evaluate('usleep(10000)')->time; + $this->assertTrue($time > 0 && $time < 1); + } + + public function testSharedVarOverwritesGlobal() { + $_POST = array(123); + $this->evalProvider->addSharedVar('_POST', array(321)); + $this->assertEquals(321, $this->evalProvider->evaluate('return $_POST[0]')->return); + } + + public function testGlobalVarsBackup() { + $_POST = array(123); + $this->evalProvider->evaluate('$_POST = array(321)'); + $this->assertEquals(array(123), $_POST); + } + + public function testAddSharedVar() { + $this->evalProvider->addSharedVar('asd', 123); + $this->assertEquals(123, $this->evalProvider->evaluate('return $asd')->return); + } + + /** + * @expectedException \Exception + */ + public function testAddSameSharedVarThrowsException() { + $this->evalProvider->addSharedVar('asd', 123); + $this->evalProvider->addSharedVar('asd', 123); + } + + public function testAddSharedVarReference() { + $var = 123; + $this->evalProvider->addSharedVarReference('asd', $var); + $var = 321; + $this->assertEquals(321, $this->evalProvider->evaluate('return $asd')->return); + } + + /** + * @expectedException \Exception + */ + public function testAddSameSharedVarReferenceThrowsException() { + $var = 123; + $this->evalProvider->addSharedVar('asd', $var); + $this->evalProvider->addSharedVarReference('asd', $var); + } + + public function testAddCodeHandler() { + $this->evalProvider->addCodeHandler(function (&$code) { + $code = 'return 321'; + }); + $this->assertEquals(321, $this->evalProvider->evaluate('return 123')->return); + } + + /** + * @expectedException \Exception + */ + public function testAddNotCallableCodeHandlerThrowsException() { + $this->evalProvider->addCodeHandler(123); + } + + public function testThrowedInCodeExceptionIsCaught() { + $result = $this->evalProvider->evaluate('throw new \Exception(123)'); + $this->assertEquals(123, $result->exception->getMessage()); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Handler.php b/vendor/php-console/php-console/tests/Test/Handler.php new file mode 100644 index 0000000..5ec0d64 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Handler.php @@ -0,0 +1,230 @@ +handler = \PhpConsole\Handler::getInstance(); + + $this->connector = $this->getMockBuilder('\PhpConsole\Connector') + ->disableOriginalConstructor() + ->setMethods(array('sendMessage', 'onShutDown', 'isActiveClient')) + ->getMock(); + + $this->connector->expects($this->any()) + ->method('isActiveClient') + ->will($this->returnValue(true)); + + $this->setProtectedProperty($this->handler, 'connector', $this->connector); + } + + public function testGetConnector() { + $this->assertInstanceOf('\PhpConsole\Connector', $this->handler->getConnector()); + } + + public function testIsSingleton() { + $this->assertIsSingleton('\PhpConsole\Handler', $this->handler); + } + + /** + * @expectedException \Exception + */ + public function testSetHandleErrorsBeforeStartThrowsException() { + $this->handler->start(); + $this->handler->setHandleErrors(true); + } + + /** + * @expectedException \Exception + */ + public function testSetHandleExceptionsBeforeStartThrowsException() { + $this->handler->start(); + $this->handler->setHandleExceptions(true); + } + + public function testInitErrorsHandler() { + $this->handler->start(); + $this->assertEmpty(ini_get('display_errors')); + $this->assertEmpty(ini_get('html_errors')); + $this->assertEquals(E_ALL | E_STRICT, error_reporting()); + $this->assertEquals(array($this->handler, 'handleError'), set_error_handler($this->getProtectedProperty($this->handler, 'oldErrorsHandler'))); + } + + public function testInitExceptionsHandler() { + $this->handler->start(); + $this->assertEquals(array($this->handler, 'handleException'), set_exception_handler($this->getProtectedProperty($this->handler, 'oldExceptionsHandler'))); + } + + /** + * @expectedException \Exception + */ + public function testDoubleStartThrowsException() { + $this->handler->start(); + $this->handler->start(); + } + + public function testNoStartNoErrorsHandling() { + $this->connector->expects($this->never())->method('sendMessage'); + $this->handler->handleError(1); + } + + public function testNoStartNoExceptionsHandling() { + $this->connector->expects($this->never())->method('sendMessage'); + $this->handler->handleException(new \Exception()); + } + + public function assertOldErrorsHandlerCalls($isEnabled) { + $oldErrorsHandlerCalls = 0; + set_error_handler(function () use (&$oldErrorsHandlerCalls) { + $oldErrorsHandlerCalls++; + }); + $this->handler->start(); + trigger_error(123); + $this->assertEquals($isEnabled ? 1 : 0, $oldErrorsHandlerCalls); + } + + public function assertOldExceptionsHandlerCalls($isEnabled) { + $oldExceptionsHandlerCalls = 0; + set_exception_handler(function () use (&$oldExceptionsHandlerCalls) { + $oldExceptionsHandlerCalls++; + }); + $this->handler->start(); + $this->handler->handleException(new \Exception()); + $this->assertEquals($isEnabled ? 1 : 0, $oldExceptionsHandlerCalls); + } + + public function testOldErrorsHandlerIsCalledByDefault() { + $this->assertOldErrorsHandlerCalls(true); + } + + public function testOldErrorsHandlerCallDisable() { + $this->handler->setCallOldHandlers(false); + $this->assertOldErrorsHandlerCalls(false); + } + + public function testOldExceptionsHandlerIsCalledByDefault() { + $this->assertOldExceptionsHandlerCalls(true); + } + + public function testOldExceptionsHandlerCallDisable() { + $this->handler->setCallOldHandlers(false); + $this->assertOldExceptionsHandlerCalls(false); + } + + public function testHandleErrorData() { + $test = $this; + $error = null; + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test, &$error) { + $lastCall = end($message->trace); + $test->assertContainsRecursive($error, $message); + $test->assertContains(__CLASS__, $lastCall->call); + $test->assertContains($test->getName(), $lastCall->call); + return true; + })); + $this->handler->start(); + $error = array( + 'type' => 'error', + 'code' => E_USER_WARNING, + 'class' => 'E_USER_WARNING', + 'data' => 'err', + 'file' => __FILE__, + 'line' => __LINE__ + 2, + ); + $this->handler->handleError($error['code'], $error['data'], __FILE__, __LINE__); + } + + public function testHandleExceptionData() { + $test = $this; + $exception = new \Exception('exception_test', 100); + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\ErrorMessage $message) use ($test, $exception) { + $lastCall = end($message->trace); + $test->assertContainsRecursive(array( + 'type' => 'error', + 'code' => $exception->getCode(), + 'class' => get_class($exception), + 'data' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + ), $message); + $test->assertContains(__CLASS__, $lastCall->call); + $test->assertContains($test->getName(), $lastCall->call); + + return true; + })); + $this->handler->start(); + $this->handler->handleException($exception); + } + + public function testHandleDebug() { + $debug = null; + $test = $this; + + $this->connector->expects($this->once()) + ->method('sendMessage') + ->with($this->callback(function (\PhpConsole\DebugMessage $message) use ($test, &$debug) { + $lastCall = end($message->trace); + $test->assertContainsRecursive($debug, $message); + $test->assertContains(__CLASS__, $lastCall->call); + $test->assertContains($test->getName(), $lastCall->call); + return true; + })); + $this->handler->start(); + $this->handler->getConnector()->getDebugDispatcher()->detectTraceAndSource = true; + $debug = array( + 'type' => 'debug', + 'data' => 'data', + 'tags' => array('t', 'a', 'g', 's'), + 'file' => __FILE__, + 'line' => __LINE__ + 2, + ); + $this->handler->debug($debug['data'], implode('.', $debug['tags'])); + } + + public function testRecursiveErrorsHandlingLimit() { + $handler = $this->handler; + set_error_handler(function () use ($handler) { + $handler->handleError(); + }); + $this->connector->getErrorsDispatcher()->ignoreRepeatedSource = false; + $this->connector->expects($this->exactly(\PhpConsole\Handler::ERRORS_RECURSION_LIMIT))->method('sendMessage'); + $this->handler->start(); + $this->handler->handleError(); + } + + public function testRecursiveExceptionsHandlingLimit() { + $handler = $this->handler; + set_exception_handler(function () use ($handler) { + $handler->handleException(new \Exception()); + }); + $this->connector->getErrorsDispatcher()->ignoreRepeatedSource = false; + $this->connector->expects($this->exactly(\PhpConsole\Handler::ERRORS_RECURSION_LIMIT))->method('sendMessage'); + $this->handler->start(); + $this->handler->handleException(new \Exception()); + } + + /** + * @expectedException \Exception + */ + public function testSetErrorsHandlerLevelBeforeStartThrowsException() { + $this->handler->start(); + $this->handler->setErrorsHandlerLevel(E_USER_NOTICE); + } + + public function testSetErrorsHandlerLevel() { + $this->handler->setErrorsHandlerLevel(E_ALL ^ E_USER_NOTICE); + $this->handler->start(); + trigger_error('hehe', E_USER_NOTICE); + $this->connector->expects($this->never())->method('sendMessage'); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Helper.php b/vendor/php-console/php-console/tests/Test/Helper.php new file mode 100644 index 0000000..8cb7407 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Helper.php @@ -0,0 +1,113 @@ +connector = \PhpConsole\Connector::getInstance(); + $this->setProtectedProperty($this->connector, 'isActiveClient', true); + + $this->debugDispatcher = $this->getMockBuilder('\PhpConsole\Dispatcher\Debug') + ->setConstructorArgs(array($this->connector, new \PhpConsole\Dumper())) + ->setMethods(array('dispatchDebug')) + ->getMock(); + $this->connector->setDebugDispatcher($this->debugDispatcher); + } + + public function testCallNotRegisteredDebugNotDispatcher() { + $this->debugDispatcher->expects($this->never()) + ->method('dispatchDebug'); + \PhpConsole\Helper::debug(123); + } + + /** + * @expectedException \Exception + */ + public function testGetConnectorBeforeRegisterThrowsException() { + \PhpConsole\Helper::getConnector(); + } + + /** + * @expectedException \Exception + */ + public function testGetHandlerBeforeRegisterThrowsException() { + \PhpConsole\Helper::getHandler(); + } + + /** + * @expectedException \Exception + */ + public function testDoubleRegisterThrowsException() { + \PhpConsole\Helper::register(); + \PhpConsole\Helper::register(); + } + + public function testGetDefaultConnector() { + $connector = \PhpConsole\Helper::register(); + $this->assertTrue($connector instanceof \PhpConsole\Connector); + $this->assertTrue(\PhpConsole\Helper::getConnector() instanceof \PhpConsole\Connector); + } + + public function testIsRegisteredReturnsFalse() { + $this->assertFalse(\PhpConsole\Helper::isRegistered()); + } + + public function testIsRegisteredReturnsTrue() { + \PhpConsole\Helper::register(); + $this->assertTrue(\PhpConsole\Helper::isRegistered()); + } + + public function testGetCustomConnector() { + \PhpConsole\Helper::register($this->connector); + $this->assertEquals(spl_object_hash($this->connector), spl_object_hash(\PhpConsole\Helper::getConnector())); + } + + public function testGetDefaultHandler() { + \PhpConsole\Helper::register(); + $this->assertTrue(\PhpConsole\Helper::getHandler() instanceof \PhpConsole\Handler); + } + + public function testGetCustomHandler() { + $handler = \PhpConsole\Handler::getInstance(); + \PhpConsole\Helper::register($this->connector, $handler); + $this->assertEquals(spl_object_hash($handler), spl_object_hash(\PhpConsole\Helper::getHandler())); + } + + public function testDebug() { + $this->debugDispatcher->expects($this->once()) + ->method('dispatchDebug') + ->with($this->equalTo(123), $this->equalTo('db')); + + \PhpConsole\Helper::register($this->connector); + /** @noinspection PhpUndefinedMethodInspection */ + \PhpConsole\Helper::debug(123, 'db'); + } + + public function testCallStaticDebug() { + $this->debugDispatcher->expects($this->once()) + ->method('dispatchDebug') + ->with($this->equalTo(123), $this->equalTo('db')); + + \PhpConsole\Helper::register($this->connector); + /** @noinspection PhpUndefinedMethodInspection */ + \PhpConsole\Helper::db(123); + } + + public function testShortHelperLoaded() { + \PhpConsole\Helper::register($this->connector); + $this->assertEquals('PhpConsole\Helper', get_parent_class('PC')); + } + + public function testConstructDisabled() { + foreach(array('PhpConsole\Helper', 'PC') as $class) { + $method = new \ReflectionMethod($class, '__construct'); + $this->assertTrue($method->isProtected() || $method->isPrivate()); + } + } +} diff --git a/vendor/php-console/php-console/tests/Test/PsrLogger.php b/vendor/php-console/php-console/tests/Test/PsrLogger.php new file mode 100644 index 0000000..ba7e2bc --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/PsrLogger.php @@ -0,0 +1,82 @@ +connector = $this->initConnectorMock(); + $this->sentMessages = array(); + } + + protected function initConnectorMock() { + $connector = $this->getMockBuilder('\PhpConsole\Connector') + ->disableOriginalConstructor() + ->setMethods(array('sendMessage', 'isActiveClient')) + ->getMock(); + + $connector->expects($this->any()) + ->method('isActiveClient') + ->will($this->returnValue(true)); + + $test = $this; + $connector->expects($this->any()) + ->method('sendMessage') + ->will($this->returnCallback(function (\PhpConsole\Message $message) use ($test) { + $test->sentMessages[] = $message; + })); + + return $connector; + } + + /** + * @return \Psr\Log\LoggerInterface + */ + function getLogger() { + return new \PhpConsole\PsrLogger($this->connector); + } + + /** + * This must return the log messages in order with a simple formatting: " " + * + * Example ->error('Foo') would yield "error Foo" + * + * @return string[] + */ + function getLogs() { + $messagesData = array(); + foreach($this->sentMessages as $message) { + if($message instanceof \PhpConsole\ErrorMessage) { + $messagesData[] = array_search($message->class, \PhpConsole\PsrLogger::$errorsLevels) . ' ' . $message->data; + } + elseif($message instanceof \PhpConsole\DebugMessage) { + $messagesData[] = array_search($message->tags[0], \PhpConsole\PsrLogger::$debugLevels) . ' ' . $message->data; + } + } + return $messagesData; + } + + public function testContextDataIsDumped() { + /** @var \PhpConsole\Dumper $dumper */ + $dumper = $this->connector->getDumper(); + $string = str_repeat('x', $dumper->itemSizeLimit + 1); + $this->getLogger()->info('{var}', array('var' => $string)); + $messagesData = $this->getLogs(); + $this->assertEquals('info ' . $dumper->dump($string), $messagesData[0]); + } + + public function testExceptionContextVarIsDispatched() { + $this->getLogger()->critical('error', array('exception' => new \Exception('exception message'))); + $this->assertEquals(1, count($this->sentMessages)); + /** @var \PhpConsole\ErrorMessage $message */ + $message = $this->sentMessages[0]; + $this->assertInstanceOf('PhpConsole\ErrorMessage', $message); + $message->data = 'exception message'; + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/Auth.php b/vendor/php-console/php-console/tests/Test/Remote/Auth.php new file mode 100644 index 0000000..517147b --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/Auth.php @@ -0,0 +1,83 @@ +assertFalse($this->response->package->auth->isSuccess); + } + + public function assertSuccessAuthInResponse() { + $this->assertTrue($this->response->package->auth->isSuccess); + } + + public function testAuthExistInResponsePackage() { + $this->setConnectorAuth(); + $this->sendRequest(); + $this->assertFailedAuthInResponse(); + } + + public function testNoMessagesInFailedAuth() { + $this->setConnectorAuth(); + $this->sendRequest(); + $this->assertFailedAuthInResponse(); + $this->assertRandomMessageInResponse(false); + } + + public function testAuthFailsOnWrongToken() { + $this->setConnectorAuth(); + $this->setRequestAuth(null, 'oops'); + $this->sendRequest(); + $this->assertFailedAuthInResponse(); + $this->assertRandomMessageInResponse(false); + } + + public function testAuthFailsOnWrongPublicKey() { + $this->setConnectorAuth(); + $this->setRequestAuth('oops'); + $this->sendRequest(); + $this->assertFailedAuthInResponse(); + $this->assertRandomMessageInResponse(false); + } + + public function testAuthFailsOnWrongIp() { + $this->setConnectorAuth(); + $this->setRequestAuth(null, \PhpConsole\Test\SERVER_KEY, true, '1.1.1.1'); + $this->sendRequest(); + $this->assertFailedAuthInResponse(); + $this->assertRandomMessageInResponse(false); + } + + public function testAuthSuccessOnNotPublicKeyByIpWithWrongIp() { + $this->setConnectorAuth(\PhpConsole\Test\SERVER_KEY, false); + $this->setRequestAuth(null, \PhpConsole\Test\SERVER_KEY, false, '1.1.1.1'); + $this->sendRequest(); + $this->assertSuccessAuthInResponse(); + $this->assertRandomMessageInResponse(); + } + + public function testSuccessAuth() { + $this->setConnectorAuth(); + $this->setRequestAuth(); + $this->sendRequest(); + $this->assertSuccessAuthInResponse(); + $this->assertRandomMessageInResponse(); + } + + public function testAuthWithPasswordInCustomServerEncoding() { + if(!extension_loaded('mbstring')) { + $this->markTestSkipped('There is strange bug using iconv in this test'); + return; + } + $password = 'Ёпрст'; + $encoding = 'Windows-1251'; + $encodedPassword = $this->convertEncoding($password, $encoding, 'utf-8'); + $this->request->addScript('set_connector_encoding', array('encoding' => $encoding)); + $this->setConnectorAuth($encodedPassword); + $this->setRequestAuth(null, $password); + $this->sendRequest(); + $this->assertSuccessAuthInResponse(); + $this->assertRandomMessageInResponse(); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/Connector.php b/vendor/php-console/php-console/tests/Test/Remote/Connector.php new file mode 100644 index 0000000..fe3b0b4 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/Connector.php @@ -0,0 +1,163 @@ +sendRequest(); + $this->assertTrue(isset($this->response->cookies[\PhpConsole\Connector::SERVER_COOKIE])); + $this->assertEquals(\PhpConsole\Connector::SERVER_PROTOCOL, $this->response->cookies[\PhpConsole\Connector::SERVER_COOKIE]); + } + + public static function provideDifferentProtocolVersions() { + return static::getOneArgProviderData(array( + \PhpConsole\Connector::SERVER_PROTOCOL - 1, + \PhpConsole\Connector::SERVER_PROTOCOL + 1, + 'x' + )); + } + + /** + * @dataProvider provideDifferentProtocolVersions + * @param $protocolVersion + */ + public function testServerWorksWithDifferentClientVersions($protocolVersion) { + $this->request->setClientData(new \PhpConsole\Client(array( + 'protocol' => $protocolVersion + ))); + $this->sendRequest(); + } + + public function testNotPostponeIfHeadersLimitNotExceeded() { + $this->request->addScript('dispatch_debug', array( + 'data' => 'asd' + )); + $this->sendRequest(); + $this->assertFalse($this->response->isPostponed); + } + + public function testPostponeIfHeadersLimitExceeded() { + $headersLimit = \PhpConsole\ClientEmulator\Connector::HEADERS_LIMIT; + $messageSizeLimit = \PhpConsole\Connector::getInstance()->getDumper()->itemSizeLimit; + for($size = 0; $size < $headersLimit; $size += $messageSizeLimit) { + $this->request->addScript('dispatch_debug', array( + 'data' => str_repeat('x', $messageSizeLimit) + )); + } + $this->sendRequest(); + $this->assertTrue($this->response->isPostponed); + $this->assertMessageInResponse(array( + 'data' => str_repeat('x', $messageSizeLimit) + ), false); + } + + public function testStringEncoding() { + $string = 'Ёпрст'; + $encoding = 'Windows-1251'; + $encodedString = $this->convertEncoding($string, $encoding, 'utf-8'); + $this->request->addScript('set_connector_encoding', array('encoding' => $encoding)); + $this->request->addScript('dispatch_debug', array('data' => $encodedString)); + $this->sendRequest(); + $this->assertNotEmpty($this->findMessageInResponse(array('data' => $string))); + } + + public function testArrayStringEncodingConvert() { + $string = 'Ёпрст'; + $encoding = 'Windows-1251'; + $encodedData = array($this->convertEncoding($string, $encoding, 'utf-8')); + $this->request->addScript('set_connector_encoding', array('encoding' => $encoding)); + $this->request->addScript('dispatch_debug', array('data' => $encodedData)); + $this->sendRequest(); + $this->assertNotEmpty($this->findMessageInResponse(array('data' => array($string)))); + } + + public function testSourcesBasePathInResponse() { + $this->sendRequest(); + $this->assertNotEmpty($this->response->package->sourcesBasePath); + } + + public function testGetBackDataInResponse() { + $data = array(1, 2, 3); + $this->request->postData[\PhpConsole\Connector::POST_VAR_NAME]['getBackData'] = $data; + $this->sendRequest(); + $this->assertEquals($data, $this->response->package->getBackData); + } + + public function testDocRootInResponse() { + $this->sendRequest(); + $this->assertNotEmpty($this->response->package->docRoot); + $this->assertContains(realpath($this->response->package->docRoot), \PhpConsole\Test\BASE_DIR); + } + + public function testIsLocalInResponse() { + $this->sendRequest(); + $this->assertTrue($this->response->package->isLocal); + } + + /** + * @group ssl + */ + public function testSslOnlyNoDataByHttp() { + $this->request->addScript('set_connector_ssl_only'); + $this->sendRequest(); + $this->assertRandomMessageInResponse(false); + $this->assertContainsRecursive(array( + 'protocol' => 5, + 'auth' => null, + 'docRoot' => null, + 'sourcesBasePath' => null, + 'getBackData' => null, + 'isSslOnlyMode' => true, + 'isEvalEnabled' => false, + 'messages' => array()), $this->response->package); + } + + /** + * @group ssl + */ + public function testSslOnlyDataByHttps() { + $this->request->addScript('set_connector_ssl_only'); + $this->request->isSsl = true; + $this->sendRequest(); + $this->assertRandomMessageInResponse(true); + } + + public static function provideSetAllowedIpMasksArgs() { + return array( + // IPv4 + array('10.0.0.1', '10.0.0.1', true), + array('10.0.0.1', '10.0.0.2', false), + array('10.0.0.1', null, false), + array('10.0.0.*', '10.0.0.2', true), + array('10.0.0.*', '10.0.1.2', false), + array('10.0.*.*', '10.0.1.2', true), + array(array('10.0.*.*', '11.0.*.*'), '10.0.1.2', true), + array(array('10.0.*.*', '12.0.*.*'), '13.0.1.2', false), + // IPv6 + array('2001:0:5ef5:79fb:28ac:173b:dad2:96e0', '2001:0:5ef5:79fb:28ac:173b:dad2:96e0', true), + array('2001:0:5ef5:79fb:28ac:173b:dad2:96e0', '2001:0:5ef5:79fb:28ac:173b:dad2:96e1', false), + array('2001:0:5ef5:79fb:28ac:173b:dad2:96e0', null, false), + array('2001:0:5ef5:79fb:28ac:173b:dad2:*', '2001:0:5ef5:79fb:28ac:173b:dad2:96e0', true), + array('2001:0:5ef5:79fb:28ac:173b:dad2:*', '2001:0:5ef5:79fb:28ac:173b:dad3:96e0', false), + array('2001:0:5ef5:79fb:28ac:173b:*:*', '2001:0:5ef5:79fb:28ac:173b:dad2:96e0', true), + array(array('2001:0:5ef5:79fb:28ac:173b:*:*', '2002:0:5ef5:79fb:28ac:173b:*:*'), '2001:0:5ef5:79fb:28ac:173b:dad3:96e0', true), + array(array('2001:0:5ef5:79fb:28ac:173b:*:*', '2002:0:5ef5:79fb:28ac:173b:*:*'), '2003:0:5ef5:79fb:28ac:173b:dad3:96e0', false), + ); + } + + /** + * @dataProvider provideSetAllowedIpMasksArgs + * @param $clientIp + * @param $allowedIpMask + * @param $expectIsAllowed + */ + public function testSetAllowedIpMasks($allowedIpMask, $clientIp, $expectIsAllowed) { + $this->request->addScript('set_connector_allowed_ip', array( + 'clientIp' => $clientIp, + 'ipMasks' => is_array($allowedIpMask) ? $allowedIpMask : array($allowedIpMask) + )); + $this->sendRequest(); + $this->assertRandomMessageInResponse($expectIsAllowed); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/Evaluate.php b/vendor/php-console/php-console/tests/Test/Remote/Evaluate.php new file mode 100644 index 0000000..baf4daf --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/Evaluate.php @@ -0,0 +1,183 @@ +randomOutputMustPresentInResponse = false; + } + + protected function setUpConnector() { + parent::setUpConnector(); + $this->request->addScript('init_default_handler'); + } + + protected function setRequestEval($code, $signature = null, \PhpConsole\Auth $auth = null) { + if(!$auth) { + $auth = $this->setRequestAuth(); + } + $this->request->postData[\PhpConsole\Connector::POST_VAR_NAME]['eval'] = array( + 'data' => $code, + 'signature' => $signature ? : $auth->getSignature($code), + ); + } + + public function testIsEvalNotEnabledInResponse() { + $this->sendRequest(); + $this->assertEmpty($this->response->package->isEvalEnabled); + } + + public function testIsEvalEnabledInResponse() { + $this->setConnectorAuth(); + $this->setRequestAuth(); + $this->request->addScript('set_connector_eval_enabled'); + $this->sendRequest(); + $this->assertTrue($this->response->package->isEvalEnabled); + } + + public function testEnableEvalInNotAuthModeThrowsException() { + $this->request->addScript('set_connector_eval_enabled'); + $this->sendRequest(); + $this->assertMessageInResponse(array( + 'type' => 'error', + 'class' => 'Exception', + 'data' => 'Eval dispatcher is allowed only in password protected mode. See PhpConsole\Connector::getInstance()->setPassword(...)', + )); + } + + public function testEvalResultInResponse() { + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled'); + $this->setRequestEval('echo 321; return 123;'); + + $this->sendRequest(); + + $this->assertMessageInResponse(array( + 'type' => 'eval_result', + 'return' => 123, + 'output' => '321', + )); + + $this->assertEmpty($this->findMessagesInResponse(array( + 'type' => 'error' + ))); + } + + public function testFlushDebugMessagesEnabled() { + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled'); + $this->setRequestEval('return 123'); + $this->sendRequest(); + $this->assertRandomMessageInResponse(false); + } + + public function testFlushDebugMessagesDisabled() { + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled', array( + 'flushDebugMessages' => false + )); + $this->setRequestEval('return 123'); + $this->sendRequest(); + $this->assertRandomMessageInResponse(); + } + + public function testExitOnEvalDisabled() { + $this->randomOutputMustPresentInResponse = true; + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled', array( + 'exitOnEval' => false + )); + $this->setRequestEval('return 123'); + $this->sendRequest(); + } + + public function testNoEvalIfAuthFails() { + $this->setConnectorAuth('oops'); + $this->request->addScript('set_connector_eval_enabled'); + $this->setRequestEval('echo 321; return 123;'); + + $this->sendRequest(); + + $this->assertEmpty($this->findMessageInResponse(array( + 'type' => 'eval_result', + ))); + } + + public function testEvalErrorIsHandled() { + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled'); + $this->setRequestEval('oops()'); + $this->sendRequest(); + $this->assertMessageInResponse(array( + 'type' => 'error', + 'code' => E_ERROR, + 'data' => 'Call to undefined function oops()' + )); + } + + public function testEvalExceptionIsHandled() { + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled'); + $this->setRequestEval('throw new Exception(123)'); + $this->sendRequest(); + $this->assertMessageInResponse(array( + 'type' => 'error', + 'class' => 'Exception', + )); + } + + public function testDisableFileAccessByOpenBaseDir() { + $evalProvider = new \PhpConsole\EvalProvider(); + $evalProvider->disableFileAccessByOpenBaseDir(); + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled', array( + 'evalProvider' => $evalProvider + )); + $this->setRequestEval('echo file_get_contents("' . __FILE__ . '");'); + $this->sendRequest(); + + $this->assertMessageInResponse(array( + 'type' => 'eval_result', + 'return' => null, + 'output' => '', + )); + + $this->assertMessageInResponse(array( + 'type' => 'error', + 'code' => E_WARNING, + )); + } + + public function tesSetOpenBaseDirs() { + $evalProvider = new \PhpConsole\EvalProvider(); + $evalProvider->setOpenBaseDirs(__DIR__); + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled', array( + 'evalProvider' => $evalProvider + )); + $this->setRequestEval('return file_get_contents("' . __FILE__ . '");'); + $this->sendRequest(); + + $this->assertMessageInResponse(array( + 'type' => 'eval_result', + 'return' => __FILE__, + 'output' => '', + )); + } + + public function testEvalWithCustomServerEncoding() { + $string = 'Ёпрст'; + $encoding = 'Windows-1251'; + $this->request->addScript('set_connector_encoding', array('encoding' => $encoding)); + $this->setConnectorAuth(); + $this->request->addScript('set_connector_eval_enabled'); + $this->setRequestEval("return mb_convert_encoding(mb_convert_encoding('$string', 'utf-8', '$encoding'), '$encoding', 'utf-8')"); + $this->sendRequest(); + $this->assertMessageInResponse(array( + 'type' => 'eval_result', + 'return' => $string, + )); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/Handler.php b/vendor/php-console/php-console/tests/Test/Remote/Handler.php new file mode 100644 index 0000000..c10d639 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/Handler.php @@ -0,0 +1,141 @@ +request->addScript('trigger_not_fatal_errors'); + $this->sendRequest(); + $this->assertRandomMessageInResponse(); + + $message = $this->findMessageInResponse(array('code' => E_NOTICE)); + $this->assertContainsRecursive(array( + 'type' => 'error', + 'code' => E_NOTICE, + 'class' => 'E_NOTICE', + 'data' => 'Undefined variable: x', + 'file' => $this->clientEmulator->getScriptPath('trigger_not_fatal_errors'), + 'line' => 5, + ), $message); + $lastCall = end($message['trace']); + $this->assertEquals($lastCall['file'], $this->clientEmulator->getScriptPath('trigger_not_fatal_errors')); + + $message = $this->findMessageInResponse(array('code' => E_WARNING)); + $this->assertContainsRecursive(array( + 'type' => 'error', + 'code' => 2, + 'class' => 'E_WARNING', + 'data' => 'file_get_contents(/not-exists): failed to open stream: No such file or directory', + 'file' => $this->clientEmulator->getScriptPath('trigger_not_fatal_errors'), + 'line' => 6, + ), $message); + $lastCall = end($message['trace']); + $this->assertEquals($lastCall['file'], $this->clientEmulator->getScriptPath('trigger_not_fatal_errors')); + } + + public static function provideFatalScriptsError() { + return static::getAssocTwoArgsProviderData(array( + 'trigger_fatal_error' => array( + array( + 'type' => 'error', + 'code' => E_ERROR, + 'class' => 'E_ERROR', + 'data' => 'undefined', + )), + 'trigger_parse_error' => array( + array( + 'type' => 'error', + 'code' => E_PARSE, + 'class' => 'E_PARSE', + 'data' => 'syntax error', + )), + 'trigger_compile_error' => array( + array( + 'type' => 'error', + 'code' => E_COMPILE_ERROR, + 'class' => 'E_COMPILE_ERROR', + 'data' => 'require_once', + ), + array( + 'type' => 'error', + 'code' => E_WARNING, + 'class' => 'E_WARNING', + 'data' => 'require_once', + )), + 'trigger_memory_limit_error' => array( + array( + 'type' => 'error', + 'code' => E_ERROR, + 'class' => 'E_ERROR', + 'data' => 'Allowed memory size', + )), + )); + } + + /** + * @dataProvider provideFatalScriptsError + * @param $scriptAlias + * @param array $expectedMessages + */ + public function testFatalErrorsHandling($scriptAlias, array $expectedMessages) { + $this->randomOutputMustPresentInResponse = false; + $this->request->addScript($scriptAlias); + $this->sendRequest(); + $this->assertRandomMessageInResponse(true); + + foreach($expectedMessages as $expectedMessage) { + $message = $this->findMessageInResponse(array( + 'code' => $expectedMessage['code'] + )); + + $this->assertContains($expectedMessage['data'], $message['data']); + unset($expectedMessage['data']); + + $expectedMessage['file'] = $this->clientEmulator->getScriptPath($scriptAlias); + $this->assertContainsRecursive($expectedMessage, $message); + } + } + + /** + * @group slow + */ + public function testMaxExecutionErrorHandling() { + $this->testFatalErrorsHandling('trigger_max_execution_time_error', array(array( + 'type' => 'error', + 'code' => E_ERROR, + 'class' => 'E_ERROR', + 'data' => 'Maximum execution time', + ))); + } + + public function testUncaughtExceptionHandling() { + $scriptAlias = 'trigger_exception'; + $this->randomOutputMustPresentInResponse = false; + $expectedMessage = array( + 'data' => 'oops', + 'code' => 100, + 'class' => 'Exception', + 'file' => $this->clientEmulator->getScriptPath($scriptAlias), + 'line' => 4 + ); + $this->request->addScript($scriptAlias, array( + 'message' => $expectedMessage['data'], + 'code' => $expectedMessage['code'], + )); + $this->sendRequest(); + $this->assertRandomMessageInResponse(true); + + $message = $this->findMessageInResponse(array( + 'code' => $expectedMessage['code'] + )); + $this->assertContainsRecursive($expectedMessage, $message); + + $lastCall = end($message['trace']); + $this->assertContainsRecursive(array( + 'file' => $this->clientEmulator->getScriptPath($scriptAlias), + 'line' => 7, + ), $lastCall); + $this->assertContains('closure', $lastCall['call']); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/HandlerAfterConnector.php b/vendor/php-console/php-console/tests/Test/Remote/HandlerAfterConnector.php new file mode 100644 index 0000000..8ef0491 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/HandlerAfterConnector.php @@ -0,0 +1,11 @@ +request->addScript('init_default_connector'); + $this->request->addScript('init_default_handler'); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/HandlerBeforeConnector.php b/vendor/php-console/php-console/tests/Test/Remote/HandlerBeforeConnector.php new file mode 100644 index 0000000..e2da9ec --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/HandlerBeforeConnector.php @@ -0,0 +1,11 @@ +request->addScript('init_default_handler'); + $this->request->addScript('init_default_connector'); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Remote/Test.php b/vendor/php-console/php-console/tests/Test/Remote/Test.php new file mode 100644 index 0000000..8ab4043 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Remote/Test.php @@ -0,0 +1,207 @@ +request->setClientData(new \PhpConsole\Client(array( + 'protocol' => \PhpConsole\Connector::SERVER_PROTOCOL + ))); + $this->setUpConnector(); + $this->addRandomMessageToRequest(); + } + + protected function setUpConnector() { + $this->request->addScript('init_default_connector'); + } + + protected function beforeRequestSend() { + $this->addRandomOutputToRequest(); + } + + protected function afterRequestSent() { + if(!$this->response) { + throw new \Exception('Request was not sent'); + } + if($this->randomOutputMustPresentInResponse !== null) { + $this->assertRandomOutputInResponse($this->randomOutputMustPresentInResponse); + } + $this->notHandledErrorsInResponse = count($this->findMessagesInResponse(array( + 'type' => 'error' + ))); + } + + protected function tearDown() { + parent::tearDown(); + $this->assertEquals(0, $this->notHandledErrorsInResponse); + } + + public function assertMessageInResponse(array $propertiesValue, $onlyOne = true) { + $this->assertNotEmpty($onlyOne ? $this->findMessageInResponse($propertiesValue) : $this->findMessagesInResponse($propertiesValue)); + } + + public function addRandomOutputToRequest() { + $this->request->addScript('print', array( + 'string' => $this->uniqueTestString + )); + } + + public function assertRandomOutputInResponse($isPresent = true) { + if($isPresent) { + if($this->randomOutputMustPresentInResponse) { + $this->assertEquals($this->uniqueTestString, $this->response->output); + } + else { + $this->assertNotContains($this->uniqueTestString, $this->response->output); + } + } + } + + protected function addRandomMessageToRequest() { + $this->request->addScript('dispatch_debug', array( + 'data' => $this->uniqueTestString, + 'tags' => 'test' . $this->uniqueTestString, + )); + } + + public function assertRandomMessageInResponse($isPresent = true) { + $message = $this->findMessageInResponse(array( + 'data' => $this->uniqueTestString, + 'tags' => 'test' . $this->uniqueTestString, + )); + if($isPresent) { + $this->assertNotEmpty($message); + } + else { + $this->assertEmpty($message); + } + } + + protected final function sendRequest() { + $this->beforeRequestSend(); + $this->response = $this->clientEmulator->sendRequest($this->request); + $this->afterRequestSent(); + return $this->response; + } + + protected function setUp() { + $this->notHandledErrorsInResponse = 0; + $this->clientEmulator = \PhpConsole\Test\getClientEmulator(); + $this->request = new \PhpConsole\ClientEmulator\Request(); + $this->uniqueTestString = mt_rand() . mt_rand(); + $this->setUpRequestDefaults(); + } + + protected function onNotSuccessfulTest(\Exception $exception) { + $request = $this->request; + $response = $this->response; + if($exception instanceof \PhpConsole\ClientEmulator\RequestFailed) { + $request = $exception->response; + $response = $exception->response; + } + print_r($response); + print_r($request); + parent::onNotSuccessfulTest($exception); + } + + protected function getAuthPublicKey($secretKey = \PhpConsole\Test\SERVER_KEY, $publicKeyByIp = true, $clientIp = \PhpConsole\Test\LOCAL_IP) { + $request = new \PhpConsole\ClientEmulator\Request(); + $request->setClientData(new \PhpConsole\Client(array( + 'protocol' => \PhpConsole\Connector::SERVER_PROTOCOL + ))); + $request->addScript('init_default_connector'); + $this->setConnectorAuth($secretKey, $publicKeyByIp, $clientIp, $request); + $response = $this->clientEmulator->sendRequest($request); + return $response->package->auth->publicKey; + } + + public function setRequestAuth($publicKey = null, $password = \PhpConsole\Test\SERVER_KEY, $publicKeyByIp = true, $clientIp = \PhpConsole\Test\LOCAL_IP) { + $auth = new \PhpConsole\Auth($password, $publicKeyByIp); + $_SERVER['REMOTE_ADDR'] = $clientIp; + $this->request->setClientData(new \PhpConsole\Client(array( + 'protocol' => \PhpConsole\Connector::SERVER_PROTOCOL, + 'auth' => new \PhpConsole\ClientAuth(array( + 'publicKey' => $publicKey ? : $this->getAuthPublicKey($password, $publicKeyByIp, $clientIp), + 'token' => $this->callProtectedMethod($auth, 'getToken') + )) + ))); + return $auth; + } + + protected function setConnectorAuth($password = \PhpConsole\Test\SERVER_KEY, $publicKeyByIp = true, $clientIp = \PhpConsole\Test\LOCAL_IP, \PhpConsole\ClientEmulator\Request $request = null) { + $request = $request ? : $this->request; + $request->addScript('set_connector_auth', array( + 'password' => $password, + 'publicKeyByIp' => $publicKeyByIp, + 'clientIp' => $clientIp, + )); + } + + public function findMessagesInResponse(array $propertiesValues) { + if(isset($propertiesValues['tags'])) { + $propertiesValues['tags'] = explode('.', $propertiesValues['tags']); + } + $messages = array(); + if($this->response->package) { + foreach($this->response->package->messages as $message) { + $isMatch = true; + foreach($propertiesValues as $property => $value) { + if(!array_key_exists($property, $message) || $message[$property] !== $value) { + $isMatch = false; + break; + } + } + if($isMatch) { + if($message['type'] == 'error') { + $this->notHandledErrorsInResponse--; + } + $messages[] = $message; + } + } + } + return $messages; + } + + /** + * @param array $propertiesValues + * @return null|\PhpConsole\ErrorMessage|\PhpConsole\DebugMessage|\PhpConsole\EvalResultMessage + * @throws \Exception + */ + public function findMessageInResponse(array $propertiesValues) { + $messages = $this->findMessagesInResponse($propertiesValues); + if($messages) { + if(count($messages) > 1) { + throw new \Exception('There is more than one matched messages'); + } + return reset($messages); + } + } + + function convertEncoding($string, $toEncoding, $fromEncoding) { + if(extension_loaded('mbstring')) { + return mb_convert_encoding($string, $toEncoding, $fromEncoding); + } + else { + return iconv($fromEncoding, $toEncoding, $string); + } + } +} diff --git a/vendor/php-console/php-console/tests/Test/Storage.php b/vendor/php-console/php-console/tests/Test/Storage.php new file mode 100644 index 0000000..d32ca68 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Storage.php @@ -0,0 +1,50 @@ +storage = $this->initStorage(); + } + + protected function generateKey() { + return mt_rand() . mt_rand() . mt_rand(); + } + + public function testPush() { + $key = $this->generateKey(); + $data = $this->generateKey(); + $this->storage->push($key, $data); + $this->assertEquals($data, $this->storage->pop($key)); + } + + public function testPop() { + $key = $this->generateKey(); + $data = $this->generateKey(); + $this->storage->push($key, $data); + $this->storage->pop($key); + $this->assertNull($this->storage->pop($key)); + } + + /** + * @group slow + */ + public function testSetKeyLifetime() { + $key = $this->generateKey(); + $this->storage->setKeyLifetime(1); + $this->storage->push($key, 123); + sleep(2); + $this->storage->push($this->generateKey(), 123); + $this->assertNull($this->storage->pop($key)); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Storage/File.php b/vendor/php-console/php-console/tests/Test/Storage/File.php new file mode 100644 index 0000000..5dade0a --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Storage/File.php @@ -0,0 +1,40 @@ +filePath = \PhpConsole\Test\BASE_DIR . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'file_storage_test.data'; + if(file_exists($this->filePath)) { + unlink($this->filePath); + } + return new \PhpConsole\Storage\File($this->filePath, $validatePathUnderDocRoot); + } + + protected function tearDown() { + parent::tearDown(); + if(file_exists($this->filePath)) { + unlink($this->filePath); + } + } + + /** + * @expectedException \Exception + */ + public function testPathUnderDocRootThrowsException() { + $_SERVER['DOCUMENT_ROOT'] = dirname($this->filePath); + $this->initStorage(true); + } + + public function testPathNotUnderDocRoot() { + $_SERVER['DOCUMENT_ROOT'] = $this->filePath . DIRECTORY_SEPARATOR . 'bla'; + $this->initStorage(true); + } +} diff --git a/vendor/php-console/php-console/tests/Test/Storage/Memcache.php b/vendor/php-console/php-console/tests/Test/Storage/Memcache.php new file mode 100644 index 0000000..09eff60 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Storage/Memcache.php @@ -0,0 +1,21 @@ +markTestSkipped('Memcache extension not installed'); + } + try { + return new \PhpConsole\Storage\Memcache(); + } + catch(\Exception $exception) { + $this->markTestSkipped('Unable to connect to memcache server'); + } + } +} diff --git a/vendor/php-console/php-console/tests/Test/Storage/Session.php b/vendor/php-console/php-console/tests/Test/Storage/Session.php new file mode 100644 index 0000000..b6b9d71 --- /dev/null +++ b/vendor/php-console/php-console/tests/Test/Storage/Session.php @@ -0,0 +1,14 @@ + $arg2) { + $calls[] = array($arg1, $arg2); + } + return $calls; + } + + protected function setProtectedProperty($object, $property, $value) { + $propertyRef = new \ReflectionProperty($object, $property); + $propertyRef->setAccessible(true); + $propertyRef->setValue($object, $value); + } + + protected function getProtectedProperty($objectOrClass, $property) { + if(is_object($objectOrClass)) { + $propertyRef = new \ReflectionProperty($objectOrClass, $property); + $propertyRef->setAccessible(true); + return $propertyRef->getValue($objectOrClass); + } + else { + $classRef = new \ReflectionClass($objectOrClass); + $properties = $classRef->getDefaultProperties(); + if(!isset($properties[$property])) { + throw new \Exception('Property "' . $property . '" not found in class "' . $objectOrClass . '"'); + } + return $properties[$property]; + } + } + + protected function callProtectedMethod($object, $method, array &$args = array()) { + $method = new \ReflectionMethod($object, $method); + $method->setAccessible(true); + return $args ? $method->invokeArgs($object, $args) : $method->invoke($object); + } + + public function assertContainsRecursive($needle, $haystack) { + if(is_object($needle)) { + $needle = get_object_vars($needle); + } + if(is_object($haystack)) { + $haystack = get_object_vars($haystack); + } + if(!is_array($needle) || !is_array($haystack)) { + throw new \Exception('Arguments can by type of array or object'); + } + $replacedHaystack = array_replace_recursive($haystack, $needle); + if($haystack != $replacedHaystack) { + throw new \PHPUnit_Framework_ExpectationFailedException('Failed asserting that two arrays are equal.', + new \PHPUnit_Framework_ComparisonFailure($haystack, $replacedHaystack, print_r($haystack, true), print_r($replacedHaystack, true))); + } + } + + protected function assertIsSingleton($class, $instance = null) { + foreach(array('__construct', '__clone') as $methodName) { + $method = new \ReflectionMethod($class, $methodName); + $this->assertTrue($method->isProtected() || $method->isPrivate()); + } + $getInstance = function () use ($class) { + return call_user_func(array($class, 'getInstance')); + }; + if($instance) { + $this->assertEquals(spl_object_hash($instance), spl_object_hash($getInstance())); + } + $this->assertEquals(spl_object_hash($getInstance()), spl_object_hash($getInstance())); + } +} diff --git a/vendor/php-console/php-console/tests/bootstrap.php b/vendor/php-console/php-console/tests/bootstrap.php new file mode 100644 index 0000000..9ccf2f7 --- /dev/null +++ b/vendor/php-console/php-console/tests/bootstrap.php @@ -0,0 +1,5 @@ + + + + + + + + + + + + + + Test + + + + diff --git a/vendor/php-console/php-console/tests/scripts/dispatch_debug.php b/vendor/php-console/php-console/tests/scripts/dispatch_debug.php new file mode 100644 index 0000000..24c41fb --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/dispatch_debug.php @@ -0,0 +1,6 @@ +getDebugDispatcher()->dispatchDebug($data + , isset($tags) ? $tags : null + , !empty($withTraceAndSource) + , isset($skipTraceCalls) ? $skipTraceCalls : 1); diff --git a/vendor/php-console/php-console/tests/scripts/init_default_connector.php b/vendor/php-console/php-console/tests/scripts/init_default_connector.php new file mode 100644 index 0000000..04ad317 --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/init_default_connector.php @@ -0,0 +1,4 @@ +setSourcesBasePath(PhpConsole\Test\getClientEmulator()->getScriptsBaseDir()); diff --git a/vendor/php-console/php-console/tests/scripts/init_default_handler.php b/vendor/php-console/php-console/tests/scripts/init_default_handler.php new file mode 100644 index 0000000..875344a --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/init_default_handler.php @@ -0,0 +1,3 @@ +start(); diff --git a/vendor/php-console/php-console/tests/scripts/print.php b/vendor/php-console/php-console/tests/scripts/print.php new file mode 100644 index 0000000..8f36087 --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/print.php @@ -0,0 +1,3 @@ +setAllowedIpMasks($ipMasks); diff --git a/vendor/php-console/php-console/tests/scripts/set_connector_auth.php b/vendor/php-console/php-console/tests/scripts/set_connector_auth.php new file mode 100644 index 0000000..5fe570f --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/set_connector_auth.php @@ -0,0 +1,4 @@ +setPassword($password, $publicKeyByIp); diff --git a/vendor/php-console/php-console/tests/scripts/set_connector_encoding.php b/vendor/php-console/php-console/tests/scripts/set_connector_encoding.php new file mode 100644 index 0000000..ac2c179 --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/set_connector_encoding.php @@ -0,0 +1,9 @@ +setServerEncoding($encoding); diff --git a/vendor/php-console/php-console/tests/scripts/set_connector_eval_enabled.php b/vendor/php-console/php-console/tests/scripts/set_connector_eval_enabled.php new file mode 100644 index 0000000..acbe8ae --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/set_connector_eval_enabled.php @@ -0,0 +1,12 @@ +getEvalDispatcher()->setEvalProvider($evalProvider); +} +$connector->startEvalRequestsListener($exitOnEval, $flushDebugMessages); + diff --git a/vendor/php-console/php-console/tests/scripts/set_connector_ssl_only.php b/vendor/php-console/php-console/tests/scripts/set_connector_ssl_only.php new file mode 100644 index 0000000..dfcc217 --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/set_connector_ssl_only.php @@ -0,0 +1,3 @@ +enableSslOnlyMode(); diff --git a/vendor/php-console/php-console/tests/scripts/set_server_encoding.php b/vendor/php-console/php-console/tests/scripts/set_server_encoding.php new file mode 100644 index 0000000..14fa9d8 --- /dev/null +++ b/vendor/php-console/php-console/tests/scripts/set_server_encoding.php @@ -0,0 +1,8 @@ +handleClientEmulatorRequest(); diff --git a/vendor/php-console/php-console/tests/vendor/README.md b/vendor/php-console/php-console/tests/vendor/README.md new file mode 100644 index 0000000..4556142 --- /dev/null +++ b/vendor/php-console/php-console/tests/vendor/README.md @@ -0,0 +1 @@ +To init vendors run "composer install" in parent directory \ No newline at end of file diff --git a/wp-php-console.php b/wp-php-console.php index ed1a573..0eafd32 100644 --- a/wp-php-console.php +++ b/wp-php-console.php @@ -9,7 +9,7 @@ * Plugin Name: WP PHP Console * Plugin URI: https://github.com/nekojira/wp-php-console/ * Description: An implementation of PHP Console for WordPress. Easily debug and trace PHP errors and warnings from your Chrome dev tools console using a Google Chrome extension. - * Version: 1.1.0 + * Version: 1.2.0 * Author: nekojira * Author URI: https://github.com/nekojira/ * License: GPL-2.0+ @@ -25,7 +25,7 @@ * @link https://github.com/barbushin/php-console * Copyright (c) 2011-2013 by Barbushin Sergey . */ -require_once plugin_dir_path( __FILE__ ) . 'lib/php-console/src/PhpConsole/__autoload.php'; +require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; /** * The main class of this plugin. @@ -35,4 +35,4 @@ /** * Instantiate this plugin. */ -$WP_PHP_Console = new WP_PHP_Console(); \ No newline at end of file +$wpPhpConsole = new WP_PHP_Console(); \ No newline at end of file