From bfef65106ff99d321620787d8e08598cebb029cc Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 16 Sep 2018 12:38:00 +0200 Subject: [PATCH 1/2] Split dev namespace --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4d922c5..6044881 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,11 @@ }, "autoload": { "psr-4": { - "PHPPM\\": "", + "PHPPM\\": "" + } + }, + "autoload-dev": { + "psr-4": { "PHPPM\\Tests\\": "tests" } } From d9f958f6c2af0a51f46c482690739c375be36315 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 16 Sep 2018 13:01:02 +0200 Subject: [PATCH 2/2] Support Laravel 5.7 --- .phpstan.neon | 1 + .travis.yml | 2 +- Bootstraps/Laravel.php | 29 ++++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.phpstan.neon b/.phpstan.neon index d634f04..63fc859 100644 --- a/.phpstan.neon +++ b/.phpstan.neon @@ -8,3 +8,4 @@ parameters: - '#Instantiated class Drupal.Core#' - '#PHPPM.Laravel.SessionGuard#' - '#Property Illuminate.Auth.SessionGuard#' + - '#Method Illuminate\\Foundation\\Application::register.. invoked with 3 parameters, 1-2 required.#' diff --git a/.travis.yml b/.travis.yml index b77a6ba..16e1568 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ jobs: # Unit test - ./vendor/bin/phpunit # Static analyzer check - - ./vendor/bin/phpstan analyze -c .phpstan.neon --level=4 --no-progress Bootstraps Bridges Laravel || true + - ./vendor/bin/phpstan analyze -c .phpstan.neon --level=4 --no-progress Bootstraps Bridges Laravel # Check the code style - IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS - ./vendor/bin/php-cs-fixer fix --config=.php_cs.php -v --dry-run --diff --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}" diff --git a/Bootstraps/Laravel.php b/Bootstraps/Laravel.php index c8cd529..7f69c61 100644 --- a/Bootstraps/Laravel.php +++ b/Bootstraps/Laravel.php @@ -28,6 +28,13 @@ class Laravel implements */ protected $app; + /** + * Laravel Application->register() parameter count + * + * @var int + */ + private $appRegisterParameters; + /** * Instantiate the bootstrap, storing the $appenv * @@ -143,6 +150,26 @@ protected function resetProvider($providerName) return; } - $this->app->register($providerName, [], true); + $this->appRegister($providerName, true); + } + + /** + * Register application provider + * Workaround for BC break in https://github.com/laravel/framework/pull/25028 + * @param string $providerName + * @param bool $force + */ + protected function appRegister($providerName, $force = false) + { + if (!$this->appRegisterParameters) { + $method = new \ReflectionMethod(get_class($this->app), ['name' => 'register']); + $this->appRegisterParameters = count($method->getParameters()); + } + + if ($this->appRegisterParameters == 3) { + $this->app->register($providerName, [], $force); + } else { + $this->app->register($providerName, $force); + } } }