Skip to content

Commit 4b510bf

Browse files
committed
Disable no-op calls to setAccessible for PHP < 8.1 in tests
1 parent a67676a commit 4b510bf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/Sentry/TestCase.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ protected function getCurrentSentryScope(): Scope
125125
$hub = $this->getSentryHubFromContainer();
126126

127127
$method = new ReflectionMethod($hub, 'getScope');
128-
$method->setAccessible(true);
128+
if (\PHP_VERSION_ID < 80100)
129+
{
130+
// This method is no-op starting from PHP 8.1; see also https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible
131+
$method->setAccessible(true);
132+
}
129133

130134
return $method->invoke($hub);
131135
}
@@ -136,7 +140,11 @@ protected function getCurrentSentryBreadcrumbs(): array
136140
$scope = $this->getCurrentSentryScope();
137141

138142
$property = new ReflectionProperty($scope, 'breadcrumbs');
139-
$property->setAccessible(true);
143+
if (\PHP_VERSION_ID < 80100)
144+
{
145+
// This method is no-op starting from PHP 8.1; see also https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible
146+
$property->setAccessible(true);
147+
}
140148

141149
return $property->getValue($scope);
142150
}

0 commit comments

Comments
 (0)