Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002932 [Quercus] minor always 09-14-08 00:19 09-15-08 15:16
Reporter koreth View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.2.1
Summary 0002932: Casting array to object drops numeric keys
Description <?php
print_r((object)array('a' => 'b'));
print_r((object)array(1 => 2));

Vanilla PHP prints

stdClass Object
(
    [a] => b
)
stdClass Object
(
    [1] => 2
)


Quercus prints

stdClass Object
(
    [a] => b
)
stdClass Object
(
)
Additional Information
Attached Files

- Relationships

- Notes
(0003436)
koreth
09-14-08 00:30

Temporary workaround: Replace casts to "object" with calls to:

function to_object($value) {
  if (!is_array($value)) {
    return (object)$value;
  }
  $nval = (object)array();
  foreach ($value as $key => $val) {
    $nval->$key = $val;
  }
  return $nval;
}
 
(0003440)
ferg
09-15-08 15:16

php/03oe

Changed so Quercus converts the key to a string.

However, it looks like PHP is actually using an integer as the key, which seems odd since object keys are supposed to be strings.
 

- Issue History
Date Modified Username Field Change
09-14-08 00:19 koreth New Issue
09-14-08 00:30 koreth Note Added: 0003436
09-15-08 15:16 ferg Note Added: 0003440
09-15-08 15:16 ferg Assigned To  => ferg
09-15-08 15:16 ferg Status new => closed
09-15-08 15:16 ferg Resolution open => fixed
09-15-08 15:16 ferg Fixed in Version  => 3.2.1


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
31 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker