title: Why does "scalar" appear like this when I cast json_decode() (in non-associative mode) to an object?
body: <p>While doing some code refactoring I momentarily ended up in a situation where I was basically doing the (somewhat abstracted-out) equivalent of</p>
  
  <pre><code>$data = (object)json_decode('"test"');
  </code></pre>
  
  <p>Of course I understand <code>json_decode()</code> generates objects on its own unless <code>assoc</code> is false. (Incidentally I got into this situation because I was in the middle of moving some format processing code around, and I hadn't yet realized one of my <code>(object)</code> casts was now redundant.)</p>
  
  <p>But... when this happened, PHP decided that <code>$data</code> contained:</p>
  
  <pre><code>stdClass Object
  (
      [scalar] =&gt; test
  )
  </code></pre>
  
  <p><strong><em>Wat.</em></strong></p>
  
  <p><code>scalar</code>?!</p>
  
  <p>Last I learned, <code>"test"</code> is a <em>string</em>, so it seems more than one pile of things has fallen over internally here. Or is this unintuitive yet intended design?!</p>
  
  <p>I have of course removed the <code>(object)</code> and things work exactly how I intended now. So there's no bug here per se. I just wanted to understand what just happened.</p>
  
  <p>Here you go, in case you want to join in the headscratching:</p>
  
  <pre><code>php -r 'print_r((object)json_decode("\"test\""));'
  </code></pre>
  
  <p>I'm using 7.0.25.</p>