How the php reflection class gets the private properties obtained by the constructor

class test{
    private $a=array();
    public function __construct() {
        $this->geta ();
    }
    private function geta(){
        $b [] = 1;
        $b [] = 2;
        
        $this->a = $b;
        // return
    }
}


//
$ref_class = new ReflectionClass("test");
$geta= $ref_class->newInstance();
$method = $ref_class->getmethod("geta");
$method->setAccessible(true);
$a = $method->invoke($rongyuclass); //geta

there is such a class. Now the private method geta does not return any data, but the constructor assigns a value to the private attribute a. When I directly use reflection to get the variable $a, I can only get a null value. How to perform the construction first and then get the assigned private attribute a?

Php
Mar.03,2021

$ref = new ReflectionClass ('test');
$a = $ref- > getProperty (' a');
$a-> setAccessible (true); / / set access to attribute a
var_dump ($a-> getValue (new test));


class test{
    private $a=array();
    public function __construct() {
        $this->geta ();
    }
    private function geta(){
        $b [] = 1;
        $b [] = 2;
        
        $this->a = $b;
        // return
    }
}

$test = new test;

$closure = function() {
    return $this->a;
};
// rebinds the closure to the $test object
$closure  = $closure->bindTo($test, $test);
print_r($closure());
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea9bf9-47d43.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea9bf9-47d43.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?