Skip to content

Commit f01dcf0

Browse files
committed
Detector: Strict code
1 parent 5f707b8 commit f01dcf0

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Detector.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class Detector
3737
public const MODE_FULL = self::MODE_ENABLER | self::MODE_SIMPLE;
3838

3939

40-
private ?Enabler $enabler;
40+
private Enabler $enabler;
41+
4142
/** @var string[] */
4243
private array $ips = ['::1', '127.0.0.1'];
4344

@@ -65,17 +66,19 @@ public function __construct(int $mode = self::MODE_SIMPLE, ?Enabler $enabler = n
6566
]
6667
);
6768

68-
$this->enabler = $enabler;
69+
if ($enabler) {
70+
$this->enabler = $enabler;
71+
}
6972
}
7073

7174
public function hasEnabler(): bool
7275
{
73-
return $this->enabler !== null;
76+
return isset($this->enabler);
7477
}
7578

7679
public function getEnabler(): Enabler
7780
{
78-
if ($this->enabler === null) {
81+
if (isset($this->enabler) === false) {
7982
throw new InconsistentEnablerModeException('Unable to get Enabler because Detector constructed without it');
8083
}
8184

tests/DetectorTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ public function getSettedIpDataProvider(): array
128128

129129
/**
130130
* @dataProvider getSettedIpDataProvider
131-
* @param $testValue
132-
* @param $expected
133131
*/
134132
public function testSettedIp(array $setIp, $testValue, $expected): void
135133
{
@@ -158,8 +156,6 @@ public function getAddedIpDataProvider(): array
158156

159157
/**
160158
* @dataProvider getAddedIpDataProvider
161-
* @param $testValue
162-
* @param $expected
163159
*/
164160
public function testAddedIp(array $setIp, $testValue, $expected): void
165161
{
@@ -195,7 +191,7 @@ public function testEnabler($testValue): void
195191
public function testMissingEnablerMode(): void
196192
{
197193
Assert::exception(function () {
198-
$detector = new Detector(Detector::MODE_FULL);
194+
new Detector(Detector::MODE_FULL);
199195
}, InconsistentEnablerModeException::class);
200196
}
201197

@@ -214,7 +210,7 @@ public function testMissingEnablerShortcut(): void
214210
}, InconsistentEnablerModeException::class);
215211
}
216212

217-
public function testPluginPrepend()
213+
public function testPluginPrepend(): void
218214
{
219215
$detector = new Detector(0);
220216
$detector->prependPlugin(
@@ -229,7 +225,7 @@ public function __invoke(Detector $detector): ?bool
229225
$detector->isDebugMode();
230226
}
231227

232-
public function testPluginAppend()
228+
public function testPluginAppend(): void
233229
{
234230
$detector = new Detector(0);
235231
$detector->appendPlugin(

0 commit comments

Comments
 (0)