Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion analysis-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,12 @@ code = "mixed-operand"
message = "Left operand in `>=` comparison has `mixed` type."
count = 2

[[issues]]
file = "src/OpenTelemetry/Propagation/SentryPropagator.php"
code = "mixed-assignment"
message = "Assigning `mixed` type to a variable may lead to unexpected behavior."
count = 2

[[issues]]
file = "src/Options.php"
code = "deprecated-method"
Expand Down Expand Up @@ -1059,7 +1065,7 @@ count = 1
[[issues]]
file = "src/Profiling/Profile.php"
code = "invalid-return-statement"
message = '''Invalid return type for function `Sentry\Profiling\Profile::getFormattedData`: expected `array{'device': array{'architecture': string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': string}, 'platform': string, 'profile': array{'frames': array<int, array{'abs_path': string, 'filename': string, 'function': string, 'lineno': int|null, 'module': null|string}>, 'samples': array<int, array{'elapsed_since_start_ns': int, 'stack_id': int, 'thread_id': string}>, 'stacks': array<int, array<int, int>>}, 'release': string, 'runtime': array{'name': string, 'version': string}, 'timestamp': string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': string, 'trace_id': string}, 'version': string}|null`, but found `array{'device': array{'architecture': null|string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': null|string}, 'platform': string('php'), 'profile': array{'frames': array{}|list<array{'abs_path': string, 'filename': string, 'function': string, 'lineno': int, 'module': null|string}>, 'samples': array{}|non-empty-list<array{'elapsed_since_start_ns': int, 'stack_id': non-negative-int, 'thread_id': string}>, 'stacks': list<array<array-key, mixed>>}, 'release': string, 'runtime': array{'name': string, 'sapi': null|string, 'version': null|string}, 'timestamp': non-empty-string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': null|string, 'trace_id': null|string}, 'version': string}`.'''
message = '''Invalid return type for function `Sentry\Profiling\Profile::getFormattedData`: expected `array{'device': array{'architecture': string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': string}, 'platform': string('php'), 'profile': array{'frames': array<int, array{'abs_path': string, 'filename': string, 'function': string, 'lineno': int|null, 'module': null|string}>, 'samples': array<int, array{'elapsed_since_start_ns': int, 'stack_id': int, 'thread_id': string}>, 'stacks': array<int, array<int, int>>}, 'release': string, 'runtime': array{'name': string, 'version': string}, 'timestamp': string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': string, 'trace_id': string}, 'version': string}|null`, but found `array{'device': array{'architecture': null|string}, 'environment': string, 'event_id': string, 'os': array{'build_number': string, 'name': string, 'version': null|string}, 'platform': string('php'), 'profile': array{'frames': array{}|list<array{'abs_path': string, 'filename': string, 'function': string, 'lineno': int, 'module': null|string}>, 'samples': array{}|non-empty-list<array{'elapsed_since_start_ns': int, 'stack_id': non-negative-int, 'thread_id': string}>, 'stacks': list<array<array-key, mixed>>}, 'release': string, 'runtime': array{'name': string, 'sapi': null|string, 'version': null|string}, 'timestamp': non-empty-string, 'transaction': array{'active_thread_id': string, 'id': string, 'name': null|string, 'trace_id': null|string}, 'version': string}`.'''
count = 1

[[issues]]
Expand Down
2 changes: 1 addition & 1 deletion src/Profiling/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* version: string,
* build_number: string,
* },
* platform: string,
* platform: 'php',
* release: string,
* environment: string,
* runtime: array{
Expand Down
2 changes: 1 addition & 1 deletion src/State/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public function applyToEvent(Event $event, ?EventHint $hint = null, ?Options $op
'flag' => key($flag),
'result' => current($flag),
];
}, $this->flags),
}, array_values($this->flags)),
]);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/FunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ public function testTraceDoesntCreateSpanIfTransactionIsNotSampled(): void
$transaction->setSampled(false);

$scope->expects($this->never())
->method('setSpan');
->method('setSpan');
$scope->expects($this->exactly(3))
->method('getSpan')
->willReturn($transaction);
->method('getSpan')
->willReturn($transaction);

SentrySdk::setCurrentHub($hub);

Expand Down
25 changes: 25 additions & 0 deletions tests/State/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,31 @@ public function testSetFlag(): void
], $event->getContexts()['flags']);
}

public function testSetFlagKeepsDuplicateFlagUpdatesSerializedAsList(): void
{
$scope = new Scope();

$scope->addFeatureFlag('feature-flag-1', true);
$scope->addFeatureFlag('feature-flag-2', false);
$scope->addFeatureFlag('feature-flag-1', false);

$event = $scope->applyToEvent(Event::createEvent());

$this->assertNotNull($event);
$this->assertArrayHasKey('flags', $event->getContexts());
$this->assertSame([
[
'flag' => 'feature-flag-2',
'result' => false,
],
[
'flag' => 'feature-flag-1',
'result' => false,
],
], $event->getContexts()['flags']['values']);
$this->assertSame('[{"flag":"feature-flag-2","result":false},{"flag":"feature-flag-1","result":false}]', json_encode($event->getContexts()['flags']['values']));
}

public function testSetFlagLimit(): void
{
$scope = new Scope();
Expand Down
Loading