Skip to content

Commit 2dd7110

Browse files
committed
Fix lang.reflection.Constructor invoking setAccessible()
1 parent d60ada5 commit 2dd7110

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/php/lang/reflection/Constructor.class.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public function newInstance(array $args= []) {
4242
// invoke after creating an instance without invoking the constructor.
4343
if (!$this->reflect->isPublic()) {
4444
$instance= $this->class->newInstanceWithoutConstructor();
45-
$this->reflect->setAccessible(true);
45+
46+
// TODO: Remove superfluous call to setAccessible() if on PHP8.1+
47+
// see https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
48+
PHP_VERSION_ID < 80100 && $this->reflect->setAccessible(true);
49+
4650
$this->reflect->invokeArgs($instance, $pass);
4751
return $instance;
4852
} else {

0 commit comments

Comments
 (0)