Skip to content

Commit b8ae0a2

Browse files
committed
Support Laravel 5.7
1 parent 92dd0a3 commit b8ae0a2

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

Diff for: .phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ parameters:
88
- '#Instantiated class Drupal.Core#'
99
- '#PHPPM.Laravel.SessionGuard#'
1010
- '#Property Illuminate.Auth.SessionGuard#'
11+
- '#Method Illuminate\\Foundation\\Application::register.. invoked with 3 parameters, 1-2 required.#'

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Unit test
2323
- ./vendor/bin/phpunit
2424
# Static analyzer check
25-
- ./vendor/bin/phpstan analyze -c .phpstan.neon --level=4 --no-progress Bootstraps Bridges Laravel || true
25+
- ./vendor/bin/phpstan analyze -c .phpstan.neon --level=4 --no-progress Bootstraps Bridges Laravel
2626
# Check the code style
2727
- IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS
2828
- ./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 for: Bootstraps/Laravel.php

+28-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ class Laravel implements
2828
*/
2929
protected $app;
3030

31+
/**
32+
* Laravel Application->register() parameter count
33+
*
34+
* @var int
35+
*/
36+
private $appRegisterParameters;
37+
3138
/**
3239
* Instantiate the bootstrap, storing the $appenv
3340
*
@@ -143,6 +150,26 @@ protected function resetProvider($providerName)
143150
return;
144151
}
145152

146-
$this->app->register($providerName, [], true);
153+
$this->appRegister($providerName, true);
154+
}
155+
156+
/**
157+
* Register application provider
158+
* Workaround for BC break in https://github.com/laravel/framework/pull/25028
159+
* @param string $providerName
160+
* @param bool $force
161+
*/
162+
protected function appRegister($providerName, $force = false)
163+
{
164+
if (!$this->appRegisterParameters) {
165+
$method = new \ReflectionMethod(get_class($this->app), ['name' => 'register']);
166+
$this->appRegisterParameters = count($method->getParameters());
167+
}
168+
169+
if ($this->appRegisterParameters == 3) {
170+
$this->app->register($providerName, [], $force);
171+
} else {
172+
$this->app->register($providerName, $force);
173+
}
147174
}
148175
}

0 commit comments

Comments
 (0)