Bug #81662 [NEW]: Private functions are invokable without need to use "setAccessible".

From: Date: Fri, 26 Nov 2021 15:16:57 +0000
Subject: Bug #81662 [NEW]: Private functions are invokable without need to use "setAccessible".
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237996@lists.php.net to get a copy of this message
From:             werlos at gmail dot com
Operating system: linux
PHP version:      8.1.0
Package:          Reflection related
Bug Type:         Bug
Bug description:Private functions are invokable without need to use "setAccessible".

Description:
------------
Prior to PHP 8.1 to invoke private method with ReflectionMethod calling
"setAccessible" with "true" was needed.

Test script:
---------------
<?php

class Foo {
    private function bar() { return 42; }
}

$foo = new Foo();

$reflection = new \ReflectionMethod($foo, 'bar');

echo $reflection->invoke($foo);

Expected result:
----------------
The need of calling "setAccessible":
"$reflection->setAccessible(true);".


-- 
Edit bug report at https://bugs.php.net/bug.php?id=81662&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81662&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81662&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81662&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81662&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81662&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81662&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81662&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81662&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81662&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81662&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81662&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81662&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81662&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81662&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81662&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81662&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81662&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#237996) next »