Skip to content

Commit 4d4c713

Browse files
committed
refactor: add comments for safe access to protected properties in EloquentDataTable
1 parent 8126490 commit 4d4c713

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/EloquentDataTable.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,10 @@ private function getForeignKeys($model): array
495495
$reflection = new \ReflectionClass($model);
496496
if ($reflection->hasProperty('foreignKeys')) {
497497
$property = $reflection->getProperty('foreignKeys');
498-
$property->setAccessible(true);
499-
$foreignKeys = $property->getValue($model);
498+
// Safe: Accessing protected property from third-party package (staudenmeir/eloquent-has-many-deep)
499+
// The property exists and is part of the package's internal API
500+
$property->setAccessible(true); // NOSONAR
501+
$foreignKeys = $property->getValue($model); // NOSONAR
500502
if (is_array($foreignKeys) && ! empty($foreignKeys)) {
501503
return $foreignKeys;
502504
}
@@ -520,8 +522,10 @@ private function getLocalKeys($model): array
520522
$reflection = new \ReflectionClass($model);
521523
if ($reflection->hasProperty('localKeys')) {
522524
$property = $reflection->getProperty('localKeys');
523-
$property->setAccessible(true);
524-
$localKeys = $property->getValue($model);
525+
// Safe: Accessing protected property from third-party package (staudenmeir/eloquent-has-many-deep)
526+
// The property exists and is part of the package's internal API
527+
$property->setAccessible(true); // NOSONAR
528+
$localKeys = $property->getValue($model); // NOSONAR
525529
if (is_array($localKeys) && ! empty($localKeys)) {
526530
return $localKeys;
527531
}
@@ -545,8 +549,10 @@ private function getThroughModels($model): array
545549
$reflection = new \ReflectionClass($model);
546550
if ($reflection->hasProperty('through')) {
547551
$property = $reflection->getProperty('through');
548-
$property->setAccessible(true);
549-
$through = $property->getValue($model);
552+
// Safe: Accessing protected property from third-party package (staudenmeir/eloquent-has-many-deep)
553+
// The property exists and is part of the package's internal API
554+
$property->setAccessible(true); // NOSONAR
555+
$through = $property->getValue($model); // NOSONAR
550556
if (is_array($through) && ! empty($through)) {
551557
return $through;
552558
}

0 commit comments

Comments
 (0)