Skip to content

Commit 6ca2aec

Browse files
committed
fixes
1 parent 1065e75 commit 6ca2aec

19 files changed

+70
-73
lines changed

rector.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__DIR__ . '/tests',
1212
])
1313
// uncomment to reach your current PHP version
14-
// ->withPhpSets()
15-
->withTypeCoverageLevel(0)
16-
->withDeadCodeLevel(0)
17-
->withCodeQualityLevel(0);
14+
->withPhpSets(php82: true)
15+
->withTypeCoverageLevel(1024)
16+
->withDeadCodeLevel(1024)
17+
->withCodeQualityLevel(1024);

src/ActionableFlag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function isDebuggable(): bool
3636
return (bool) $this->debug;
3737
}
3838

39-
public function storeInspectionInformation(string $pipe, string $reason, ?bool $result = null)
39+
public function storeInspectionInformation(string $pipe, string $reason, ?bool $result = null): void
4040
{
4141
$this->debug->addDecision($pipe, $reason, $result);
4242
}

src/FeatureFlagsServiceProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FeatureFlagsServiceProvider extends ServiceProvider
2828
/**
2929
* Bootstrap the application services.
3030
*/
31-
public function boot()
31+
public function boot(): void
3232
{
3333
if ($this->app->runningInConsole()) {
3434
$this->publishes([
@@ -96,7 +96,7 @@ public function register(): void
9696
$this->app->singleton(FeaturesContract::class, Manager::class);
9797
}
9898

99-
$this->app->scoped(MaintenanceRepository::class, fn (Container $app) => new MaintenanceRepository($app->make(FeaturesContract::class), $app));
99+
$this->app->scoped(MaintenanceRepository::class, fn (Container $app): \YlsIdeas\FeatureFlags\Support\MaintenanceRepository => new MaintenanceRepository($app->make(FeaturesContract::class), $app));
100100

101101
$this->app->extend(MaintenanceModeManager::class, fn (MaintenanceModeManager $manager) => $manager->extend('features', fn (): MaintenanceMode => new MaintenanceDriver(
102102
$this->app->make(MaintenanceRepository::class)
@@ -109,7 +109,7 @@ protected function schedulingMacros()
109109
/** @noRector \Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector */
110110
Event::macro('skipWithoutFeature', fn (string $feature): Event =>
111111
/** @var Event $this */
112-
$this->skip(fn () => ! Features::accessible($feature)));
112+
$this->skip(fn (): bool => ! Features::accessible($feature)));
113113
}
114114

115115
if (! Event::hasMacro('skipWithFeature')) {
@@ -141,7 +141,7 @@ protected function aboutCommandInfo(): void
141141
{
142142
if (class_exists(AboutCommand::class)) {
143143
AboutCommand::add('Feature Flags', [
144-
'Pipeline' => fn () => implode(', ', config('features.pipeline')),
144+
'Pipeline' => fn (): string => implode(', ', config('features.pipeline')),
145145
]);
146146
}
147147
}

src/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function pipeline(): Pipeline
6666
*/
6767
public function accessible(string $feature): bool
6868
{
69-
if ($this->expiredFeaturesHandler) {
69+
if ($this->expiredFeaturesHandler instanceof \YlsIdeas\FeatureFlags\Contracts\ExpiredFeaturesHandler) {
7070
$this->expiredFeaturesHandler->isExpired($feature);
7171
}
7272

@@ -289,7 +289,7 @@ protected function pipes(): array
289289
$pipes = $this->container->make(Repository::class)->get('features.pipeline');
290290

291291
return collect($pipes)
292-
->map(fn (string $pipe) => $this->resolve($pipe))
292+
->map(fn (string $pipe): \YlsIdeas\FeatureFlags\Support\GatewayInspector => $this->resolve($pipe))
293293
->all();
294294
}
295295

src/Support/FeatureFake.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function accessible(string $feature): bool
5050
return $featureValue;
5151
}
5252

53-
public function assertAccessed(string $feature, ?int $count = null, string $message = '')
53+
public function assertAccessed(string $feature, ?int $count = null, string $message = ''): void
5454
{
5555
if ($count === null) {
5656
Assert::assertGreaterThan(0, $this->getCount($feature), $message);
@@ -59,12 +59,12 @@ public function assertAccessed(string $feature, ?int $count = null, string $mess
5959
}
6060
}
6161

62-
public function assertNotAccessed(string $feature, string $message = '')
62+
public function assertNotAccessed(string $feature, string $message = ''): void
6363
{
6464
Assert::assertLessThan(1, $this->getCount($feature), $message);
6565
}
6666

67-
public function assertAccessedCount(string $feature, int $count = 0, string $message = '')
67+
public function assertAccessedCount(string $feature, int $count = 0, string $message = ''): void
6868
{
6969
$this->assertAccessed($feature, $count, $message);
7070
}

src/Support/GatewayCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function delete(string $feature): void
3636
$this->repository->delete($this->generateKey($feature));
3737
}
3838

39-
public function generateKey($feature)
39+
public function generateKey(string $feature): string
4040
{
4141
return $this->namespace . ':' . $this->cacheable->generateKey($feature);
4242
}

src/Support/MaintenanceRepository.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ public function callDeactivation(): void
4444
$this->container->call($this->uponDeactivation, ['features' => $this->features]);
4545
}
4646

47-
public function onEnabled($feature): MaintenanceScenario
47+
public function onEnabled(string $feature): MaintenanceScenario
4848
{
4949
return tap((new MaintenanceScenario())->whenEnabled($feature), function (MaintenanceScenario $scenario): void {
5050
$this->scenarios[] = $scenario;
5151
});
5252
}
5353

54-
public function onDisabled($feature): MaintenanceScenario
54+
public function onDisabled(string $feature): MaintenanceScenario
5555
{
5656
return tap((new MaintenanceScenario())->whenDisabled($feature), function (MaintenanceScenario $scenario): void {
5757
$this->scenarios[] = $scenario;
@@ -75,15 +75,12 @@ public function parameters(): ?array
7575
protected function findScenario(): ?MaintenanceScenario
7676
{
7777
return $this->foundScenario = collect($this->scenarios)
78-
->first(function (MaintenanceScenario $scenario) {
78+
->first(function (MaintenanceScenario $scenario): bool {
7979
if ($scenario->onEnabled && $this->features->accessible($scenario->feature)) {
8080
return true;
8181
}
82-
if (! $scenario->onEnabled && ! $this->features->accessible($scenario->feature)) {
83-
return true;
84-
}
8582

86-
return false;
83+
return ! $scenario->onEnabled && ! $this->features->accessible($scenario->feature);
8784
});
8885
}
8986
}

tests/GatewayDriverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected function getPackageProviders($app): array
1616
];
1717
}
1818

19-
public function test_throws_exception_creating_a_gateway_driver()
19+
public function test_throws_exception_creating_a_gateway_driver(): void
2020
{
2121
config()->set('features.pipeline', ['gate']);
2222
config()->set('features.gateways', [
@@ -30,7 +30,7 @@ public function test_throws_exception_creating_a_gateway_driver()
3030
$this->app->make(Manager::class)->pipeline();
3131
}
3232

33-
public function test_create_a_gateway_driver()
33+
public function test_create_a_gateway_driver(): void
3434
{
3535
config()->set('features.pipeline', ['gate']);
3636
config()->set('features.gateways', [

tests/Gateways/DatabaseGatewayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function test_it_can_store_the_state_of_features_switched_on(): void
111111
->andReturn($query);
112112

113113
$query->shouldReceive('updateOrInsert')
114-
->withArgs(function ($find, $data) {
114+
->withArgs(function (array $find, array $data): true {
115115
$this->assertArrayHasKey('feature', $find);
116116
$this->assertArrayHasKey('active_at', $data);
117117

tests/MaintenanceModeTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,35 @@
1414

1515
class MaintenanceModeTest extends TestCase
1616
{
17-
public function test_maintenance_mode_enabled()
17+
public function test_maintenance_mode_enabled(): void
1818
{
1919
Features::fake(['system.down' => true]);
2020
Features::maintenanceMode()
2121
->onEnabled('system.down');
2222

23-
Route::get('/', fn () => 'Foo Bar');
23+
Route::get('/', fn (): string => 'Foo Bar');
2424

2525
$this->get('/')
2626
->assertServiceUnavailable();
2727

2828
Features::assertAccessed('system.down');
2929
}
3030

31-
public function test_maintenance_mode_disabled()
31+
public function test_maintenance_mode_disabled(): void
3232
{
3333
Features::fake(['system.down' => false]);
3434
Features::maintenanceMode()
3535
->onEnabled('system.down');
3636

37-
Route::get('/', fn () => 'Foo Bar');
37+
Route::get('/', fn (): string => 'Foo Bar');
3838

3939
$this->get('/')
4040
->assertOk();
4141

4242
Features::assertAccessed('system.down');
4343
}
4444

45-
public function test_it_handles_the_first_match()
45+
public function test_it_handles_the_first_match(): void
4646
{
4747
Features::fake(['system.api' => true,]);
4848
Features::maintenanceMode()
@@ -52,7 +52,7 @@ public function test_it_handles_the_first_match()
5252
->onEnabled('system.api')
5353
->statusCode(500);
5454

55-
Route::get('/', fn () => 'Foo Bar');
55+
Route::get('/', fn (): string => 'Foo Bar');
5656

5757
$this->get('/')
5858
->assertStatus(500);
@@ -61,7 +61,7 @@ public function test_it_handles_the_first_match()
6161
Features::assertAccessed('system.api');
6262
}
6363

64-
public function test_upon_activation()
64+
public function test_upon_activation(): void
6565
{
6666
$called = false;
6767
Features::maintenanceMode()
@@ -75,15 +75,15 @@ public function test_upon_activation()
7575
}
7676

7777
#[\PHPUnit\Framework\Attributes\DataProvider('exceptsValues')]
78-
public function test_maintenance_mode_respects_excepts_values(string $path, int $status)
78+
public function test_maintenance_mode_respects_excepts_values(string $path, int $status): void
7979
{
8080
Features::fake(['system.down' => true]);
8181
Features::maintenanceMode()
8282
->onEnabled('system.down')
8383
->exceptPaths(['/test']);
8484

85-
Route::get('/', fn () => 'Foo Bar');
86-
Route::get('/test', fn () => 'Foo Bar Foo');
85+
Route::get('/', fn (): string => 'Foo Bar');
86+
Route::get('/test', fn (): string => 'Foo Bar Foo');
8787

8888
$this
8989
->withoutExceptionHandling([\Symfony\Component\HttpKernel\Exception\HttpException::class])
@@ -103,7 +103,7 @@ public static function exceptsValues(): \Generator
103103
];
104104
}
105105

106-
public function test_upon_deactivation()
106+
public function test_upon_deactivation(): void
107107
{
108108
$called = false;
109109
Features::fake(['system.down' => true]);

0 commit comments

Comments
 (0)