Skip to content

Commit

Permalink
Return new static instance to allow LSB
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored and OndraM committed May 7, 2020
1 parent 14a8720 commit 4e7f5fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
6 changes: 5 additions & 1 deletion src/CiDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 4e7f5fc

Please sign in to comment.