Skip to content

Commit e9283c4

Browse files
authored
Remove calls to PHP 8.5-deprecated setAccessible (#1744)
These are no-op as of PHP 8.1 and thus no longer needed See also https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
1 parent 12a0d7d commit e9283c4

File tree

3 files changed

+0
-8
lines changed

3 files changed

+0
-8
lines changed

php-templates/translations.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ function vscodeCollectTranslations(string $path, ?string $namespace = null)
124124
$property = $reflection->hasProperty('paths')
125125
? $reflection->getProperty('paths')
126126
: $reflection->getProperty('path');
127-
$property->setAccessible(true);
128127

129128
$paths = Illuminate\Support\Arr::wrap($property->getValue($loader));
130129

src/Console/ModelsCommand.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ protected function isRelationNullable(string $relation, Relation $relationObj):
887887

888888
if (in_array($relation, ['hasOne', 'hasOneThrough', 'morphOne'], true)) {
889889
$defaultProp = $reflectionObj->getProperty('withDefault');
890-
$defaultProp->setAccessible(true);
891890

892891
return !$defaultProp->getValue($relationObj);
893892
}
@@ -897,7 +896,6 @@ protected function isRelationNullable(string $relation, Relation $relationObj):
897896
}
898897

899898
$fkProp = $reflectionObj->getProperty('foreignKey');
900-
$fkProp->setAccessible(true);
901899

902900
$enforceNullableRelation = $this->laravel['config']->get('ide-helper.enforce_nullable_relationships', true);
903901

@@ -930,7 +928,6 @@ protected function isMorphToRelationNullable(Relation $relationObj): bool
930928
}
931929

932930
$fkProp = $reflectionObj->getProperty('foreignKey');
933-
$fkProp->setAccessible(true);
934931

935932
foreach (Arr::wrap($fkProp->getValue($relationObj)) as $foreignKey) {
936933
if (isset($this->nullableColumns[$foreignKey])) {
@@ -1283,9 +1280,6 @@ protected function hasCamelCaseModelProperties()
12831280
*/
12841281
protected function getAttributeTypes(Model $model, \ReflectionMethod $reflectionMethod): Collection
12851282
{
1286-
// Private/protected ReflectionMethods require setAccessible prior to PHP 8.1
1287-
$reflectionMethod->setAccessible(true);
1288-
12891283
/** @var Attribute $attribute */
12901284
$attribute = $reflectionMethod->invoke($model);
12911285

src/Factories.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public static function all()
1616
$factory = app(Factory::class);
1717

1818
$definitions = (new ReflectionClass(Factory::class))->getProperty('definitions');
19-
$definitions->setAccessible(true);
2019

2120
foreach ($definitions->getValue($factory) as $factory_target => $config) {
2221
try {

0 commit comments

Comments
 (0)