Skip to content

Fix PHP8.5 deprecation warnings with ReflectionProperty::setAccessible() #4230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2025
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
5 changes: 4 additions & 1 deletion src/Fixable/Patcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use function sha1;
use function str_starts_with;
use function substr;
use const PHP_VERSION_ID;
use const PREG_SPLIT_DELIM_CAPTURE;
use const PREG_SPLIT_NO_EMPTY;

Expand Down Expand Up @@ -62,7 +63,9 @@ public function applyDiffs(string $fileName, array $diffs): string

$refMerge = new ReflectionClass(PhpMerge::class);
$refMergeMethod = $refMerge->getMethod('mergeHunks');
$refMergeMethod->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$refMergeMethod->setAccessible(true);
}

$result = Line::createArray(array_map(
static fn ($l) => [$l, Differ::OLD],
Expand Down
4 changes: 3 additions & 1 deletion src/Testing/TestCaseSourceLocatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public function create(): SourceLocator
),
];
$vendorDirProperty = $classLoaderReflection->getProperty('vendorDir');
$vendorDirProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$vendorDirProperty->setAccessible(true);
}
foreach ($classLoaders as $classLoader) {
$composerProjectPath = dirname($vendorDirProperty->getValue($classLoader));
if (!is_file($composerProjectPath . '/composer.json')) {
Expand Down
Loading