How to read and convert a protected object to an associative array in PHP : <p>I am working with an api which answers the requests with "protected" data object</p>

<p>like this</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>(
    [id:protected] =&gt; id:NYhXwGRVDzAAAAAAAAAA62
    [name:protected] =&gt; 5cf8cdd54328c.EDF
    [rev:protected] =&gt; 014a0000000150eaacf0
    [size:protected] =&gt; 25136208
    [server_modified:protected] =&gt; 2019-06-06T08:25:00Z
    [has_explicit_shared_members:protected] =&gt; 
    [data:protected] =&gt; Array
        (
            [name] =&gt; 5cf8cdd54328c.EDF
            [path_lower] =&gt; /5cf8cdd54328c.edf
            [path_display] =&gt; /5cf8cdd54328c.EDF
            [id] =&gt; id:NYhXwGRVDzAAAAAAAA125
            [client_modified] =&gt; 2019-06-06T08:25:00Z
            [server_modified] =&gt; 2019-06-06T08:25:00Z
            [rev] =&gt; 014a0000000150eaacf0
            [size] =&gt; 25136208
            [is_downloadable] =&gt; 1
            [content_hash] =&gt; 86442139304784e3b18d1d46f1b20bc48847
        )
)</code></pre>
</div>
</div>
</p>

<p>I have converted the object to array with the following code</p>

<pre><code>$metadata = (array)$file-&gt;getMetadata();
</code></pre>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Array
(
    [*id] =&gt; id:NYhXwGRVDzAAAAAA44554
    [*name] =&gt; 5cf8cdd54328c.EDF
    [*rev] =&gt; 014a0000000150eaacf0
    [*size] =&gt; 25136208
    [*media_info] =&gt; 
    [*sharing_info] =&gt; 
    [*path_display] =&gt; /5cf8cdd54328c.EDF
    [*client_modified] =&gt; 2019-06-06T08:25:00Z
    [*server_modified] =&gt; 2019-06-06T08:25:00Z

    [*data] =&gt; Array
        (
            [name] =&gt; 5cf8cdd54328c.EDF
            [path_display] =&gt; /5cf8cdd54328c.EDF
            [id] =&gt; id:NYhXwGRVDzAAAAAAA23382
            [client_modified] =&gt; 2019-06-06T08:25:00Z
            [server_modified] =&gt; 2019-06-06T08:25:00Z
            [rev] =&gt; 014a0000000150eaacf0
            [size] =&gt; 25136208
            [is_downloadable] =&gt; 1
            [content_hash] =&gt; 86442139304784e3b18d1d46f1b20bc4884
        )

)</code></pre>
</div>
</div>
</p>

<p>But when i try to print the value <code>print_r($metadata['*size']);</code> </p>

<blockquote>
  <p>Notice: Undefined index: *size in C:\xampp\htdocs\Proyectos\kardion\kardion\sistema\download.php on line 28</p>
</blockquote>

<p>I think it will be a very easy answer but I have no idea how to do it</p>
