类范围可访问的静态数组,试图推送它,但一直空着

class UpcomingEvents {

//Variable I'm trying to make accessible and modify throughout the class methods
private static $postObjArr = array();
private static $postIdArr = array(); 

private static $pinnedPost;  

//My attempt at a get method to solve this issue, it did not
private static function getPostObjArr() {
    $postObjArr = static::$postObjArr;
    return $postObjArr;
}

private static function sortByDateProp($a, $b) {
    $Adate = strtotime(get_field('event_date',$a->ID));
    $Bdate = strtotime(get_field('event_date',$b->ID));
    if ($Adate == $Bdate) {
        return 0;
    }
    return ($Adate < $Bdate) ? -1 : 1;
}

private static function queryDatesAndSort($args) {

    $postQuery = new WP_Query( $args );

    if( $postQuery->have_posts() ) {
        while( $postQuery->have_posts() ) {
            $postQuery->the_post();

            //Trying to push to the array, to no avail
            array_push(static::getPostObjArr(), get_post());
        }
    }

    //Trying to return the array after pushing to it, comes back empty
    return(var_dump(static::getPostObjArr()));

    //Trying to sort it
    usort(static::getPostObjArr(), array(self,'sortByDateProp'));  

    foreach (static::getPostObjArr() as $key => $value) {
        array_push(static::$postIdArr, $value->ID);
    }  

}
}

I'm trying to access $postObjArr within the class, and push to it with the queryDatesAndSort(); method. I've tried a couple of things, most recent being to use a get method for the variable. I don't want to make it global as it's bad practice I've heard. I've also tried passing by reference I.E

&static::$postObjArr;

But when it hits the vardump, it spits out an empty array. What would be the solution and best practice here? To allow the class methods to access and modify a single static array variable.

static::$postObjArr[] = get_post()

I didn't think it would of made a difference, but it worked. Can you explain to me why that worked but array.push(); Did not?

Arrays are always copy-on-write in PHP. If you assign an array to another variable, pass it into a function, or return it from a function, it's for all intents and purposes a different, new array. Modifying it does not modify the "original" array. If you want to pass an array around and continue to modify the original array, you'll have to use pass-by-reference everywhere. Meaning you will have to add a & everywhere you assign it to a different variable, pass it into a function, or return it from a function. If you forget your & anywhere, the reference is broken.

Since that's rather annoying to work with, you rarely use references in PHP and you either modify your arrays directly (static::$postObjArr), or you use objects (stdClass or a custom class) instead which can be passed around without breaking reference.