Skip to content

Commit 0b34edc

Browse files
authored
Decrease psalm error level (#85)
1 parent f16f39d commit 0b34edc

14 files changed

+22
-21
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"kevinrob/guzzle-cache-middleware": "^3",
2525
"phpunit/php-code-coverage": "^9",
2626
"phpunit/phpunit": "^9",
27-
"vimeo/psalm": "4.9.2"
27+
"vimeo/psalm": "^4.0"
2828
},
2929
"suggest": {
3030
"guzzlehttp/guzzle": "(^7) Required when using GuzzleEventPublisher or the default FeatureRequester",

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<psalm
3-
errorLevel="4"
3+
errorLevel="2"
44
resolveFromConfigFile="true"
55
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
66
xmlns="https://getpsalm.org/schema/config"

src/LaunchDarkly/FeatureFlagsState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FeatureFlagsState implements \JsonSerializable
2121
/** @var array */
2222
protected $_flagValues;
2323

24-
/** @var array */
24+
/** @var array<string, array{debugEventsUntilDate?: int|null, reason?: EvaluationReason, trackEvents?: true, variation?: int|null, version?: int}> **/
2525
protected $_flagMetadata;
2626

2727
/**

src/LaunchDarkly/FeatureRequester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getSegment(string $key): ?Segment;
3333
/**
3434
* Gets all feature flags.
3535
*
36-
* @return array|null The decoded FeatureFlags, or null if missing
36+
* @return array<string, FeatureFlag>|null The decoded FeatureFlags, or null if missing
3737
*/
3838
public function getAllFeatures(): ?array;
3939
}

src/LaunchDarkly/Impl/Events/EventFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function newEvalEvent(
5858
if ($prereqOfFlag) {
5959
$e['prereqOf'] = $prereqOfFlag->getKey();
6060
}
61-
if (($addExperimentData || $this->_withReasons) && $detail->getReason()) {
61+
if (($addExperimentData || $this->_withReasons)) {
6262
$e['reason'] = $detail->getReason()->jsonSerialize();
6363
}
6464
if ($user->getAnonymous()) {
@@ -88,7 +88,7 @@ public function newDefaultEvent(FeatureFlag $flag, LDUser $user, EvaluationDetai
8888
if ($flag->getDebugEventsUntilDate()) {
8989
$e['debugEventsUntilDate'] = $flag->getDebugEventsUntilDate();
9090
}
91-
if ($this->_withReasons && $detail->getReason()) {
91+
if ($this->_withReasons) {
9292
$e['reason'] = $detail->getReason()->jsonSerialize();
9393
}
9494
if ($user->getAnonymous()) {
@@ -111,7 +111,7 @@ public function newUnknownFlagEvent(string $key, LDUser $user, EvaluationDetail
111111
'default' => $detail->getValue()
112112
];
113113
// the following properties are handled separately so we don't waste bandwidth on unused keys
114-
if ($this->_withReasons && $detail->getReason()) {
114+
if ($this->_withReasons) {
115115
$e['reason'] = $detail->getReason()->jsonSerialize();
116116
}
117117
if ($user->getAnonymous()) {

src/LaunchDarkly/Impl/Events/EventProcessor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ class EventProcessor
2525
/** @var int */
2626
private $_capacity;
2727

28-
public function __construct(string $sdkKey, array $options = [])
28+
/**
29+
* @psalm-param array{capacity: int} $options
30+
*/
31+
public function __construct(string $sdkKey, array $options)
2932
{
3033
$this->_eventPublisher = $this->getEventPublisher($sdkKey, $options);
3134
$this->_eventSerializer = new EventSerializer($options);
32-
35+
3336
$this->_capacity = $options['capacity'];
3437
}
3538

src/LaunchDarkly/Impl/Integrations/FeatureRequesterBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function getSegment(string $key): ?Segment
125125
/**
126126
* Gets all features
127127
*
128-
* @return array|null The decoded FeatureFlags, or null if missing
128+
* @return array<string, FeatureFlag>|null The decoded FeatureFlags, or null if missing
129129
*/
130130
public function getAllFeatures(): ?array
131131
{

src/LaunchDarkly/Impl/Integrations/FileDataFeatureRequester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function getSegment(string $key): ?Segment
5555
/**
5656
* Gets all feature flags
5757
*
58-
* @return array|null The decoded FeatureFlags, or null if missing
58+
* @return array<string, FeatureFlag>|null The decoded FeatureFlags, or null if missing
5959
*/
6060
public function getAllFeatures(): ?array
6161
{

src/LaunchDarkly/Impl/Integrations/GuzzleEventPublisher.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function __construct(string $sdkKey, array $options = [])
4949
public function publish(string $payload): bool
5050
{
5151
$client = new Client(['base_uri' => $this->_eventsUri]);
52-
$response = null;
5352

5453
try {
5554
$options = $this->_requestOptions;

src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getSegment(string $key): ?Segment
111111
/**
112112
* Gets all features from a likely cached store
113113
*
114-
* @return array|null The decoded FeatureFlags, or null if missing
114+
* @return array<string, FeatureFlag>|null The decoded FeatureFlags, or null if missing
115115
*/
116116
public function getAllFeatures(): ?array
117117
{

0 commit comments

Comments
 (0)