从另一个类调用变量而不创建新的实例[PHP]


Call variabile from another class without making new instance [ PHP ]

我在我的类"Parse"中有一个数组在这个数组中我有多个数据,它看起来像(我在这里只显示一些重要的行:

class Parse
{
    public static $data = array();  
    public function parseXML()
    {
        .
        .
        .
        $items = $doc->getElementsByTagName( "item" );
        foreach( $items as $item )
        {  
          $keys = $item->getElementsByTagName( "key" );
          $key = $keys->item(0)->nodeValue;
          $values = $item->getElementsByTagName( "value" );
          $value = $values->item(0)->nodeValue;
          //adding login and password to array              
          $data[$key] = $value;
        }       
        $claimNumber = $doc->getElementsByTagName( "ClaimNumber" );
        $claimNumber = $claimNumber->item(0)->nodeValue;
        $vin = $doc->getElementsByTagName( "VIN" );
        $vin = $vin->item(0)->nodeValue;    
        //adding claimnumber and VIN to array
        $data['claimNumber'] = $claimNumber;        
        $data['vin'] = $vin;
        $this->data = $data;
        return $data;
    }

在$data中,我应该有vin, claimnumber和一些来自foreach的东西(为了不让你混淆,我们忽略foreach中的数据)

好的,现在我想从另一个类和方法访问这些数据,我不想创建它的新实例,因为这将截断从以前使用的方法parseXML()中已经在$data中的所有数据其他类{Public $token = null;

public function authorization()
{
    //define enviroment and path        
    $host = enviroment;
    $path = "/oauth/token"; 
    $username = Parse::$data['claimNumber'];

这是我在另一个stackoverflow问题中发现的东西,但它只是返回:Undefined index: claimNumber也试图添加Parse::$data;,结果基本相同。

有人能帮我一下吗?

self::$data = $data;代替parseXML()法中的$this->data = $data;