Skip to content

Commit

Permalink
Chore: Explicitly mark parameters as nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed Nov 22, 2024
1 parent e70f9eb commit c5f6e98
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'nullable_type_declaration_for_default_null_value' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Metrics/DefaultMetricsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
}

#[Override]
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
if (!$this->configuration->isMetricsEnabled()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Metrics/MetricsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

interface MetricsHandler
{
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void;
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void;
}
2 changes: 1 addition & 1 deletion tests/AbstractHttpClientTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function setUp(): void
);

$this->metricsHandler = new class implements MetricsHandler {
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/ClientSpecificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testClientSpecifications()
$this->registrationService,
$configuration,
new class implements MetricsHandler {
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/Configuration/UnleashContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testCurrentTimeE2E()
->setAutoRegistrationEnabled(false)
->setCache($this->getCache()),
new class implements MetricsHandler {
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testMissingValues()
->setMetricsEnabled(false)
->setAutoRegistrationEnabled(false),
new class implements MetricsHandler {
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setCache(CacheInterface $cache): void
$this->cache = $cache;
}

public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setConfiguration(UnleashConfiguration $configuration): void
$this->configuration = $configuration;
}

public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class MetricsSenderAwareMetricsHandler implements MetricsHandler, MetricsS
*/
public $metricsSender = null;

public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class RequestFactoryAwareEventDispatcher implements EventDispatcherInterfa
*/
public $requestFactory = null;

public function dispatch(object $event, string $eventName = null): object
public function dispatch(object $event, ?string $eventName = null): object
{
return new stdClass();
}
Expand All @@ -41,7 +41,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber): void
{
}

public function getListeners(string $eventName = null): array
public function getListeners(?string $eventName = null): array
{
return [];
}
Expand All @@ -51,7 +51,7 @@ public function getListenerPriority(string $eventName, callable $listener): ?int
return null;
}

public function hasListeners(string $eventName = null): bool
public function hasListeners(?string $eventName = null): bool
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/UnleashBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public function testWithMetricsCacheHandler()
public function testWithMetricsHandler()
{
$metricsHandler = new class implements MetricsHandler {
public function handleMetrics(Feature $feature, bool $successful, Variant $variant = null): void
public function handleMetrics(Feature $feature, bool $successful, ?Variant $variant = null): void
{
}
};
Expand Down

0 comments on commit c5f6e98

Please sign in to comment.