diff --git a/CHANGELOG.md b/CHANGELOG.md index 350f821..acb31d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ ## Unreleased - Add AWS CodeBuild detection support. +- Allow late static binding in `CiDetector::fromEnvironment()` when inheriting the class. ## 3.3.0 - 2020-03-06 -- Allow injecting instance of `Env` into `CiDetector` (useful for environment mocking in unit tests). +- Allow injecting instance of `Env` using `CiDetector::fromEnvironment()` (useful for environment mocking in unit tests). ## 3.2.0 - 2020-02-18 - Add GitHub Actions detection support. diff --git a/phpstan.neon b/phpstan.neon index 0fb9031..44f7afa 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,10 @@ parameters: ignoreErrors: - '/Parameter \#1 \$function of function call_user_func expects callable/' + + # TODO: should be solved in next major version by declaring CiDetector final + - message: '#Unsafe usage of new static\(\)#' + path: 'src/CiDetector.php' level: 7 paths: - src/ diff --git a/src/CiDetector.php b/src/CiDetector.php index 62fb147..ec6ed98 100644 --- a/src/CiDetector.php +++ b/src/CiDetector.php @@ -34,7 +34,11 @@ public function __construct() public static function fromEnvironment(Env $environment): self { - return new static($environment); + $detector = new static(); + + $detector->environment = $environment; + + return $detector; } /**