Bug #68186 [NEW]: A stdClass shouldn't allow invalid proprieties names.

From: Date: Wed, 08 Oct 2014 13:40:38 +0000
Subject: Bug #68186 [NEW]: A stdClass shouldn't allow invalid proprieties names.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187955@lists.php.net to get a copy of this message
From:             ceceldada at gmail dot com
Operating system: 
PHP version:      Irrelevant
Package:          Class/Object related
Bug Type:         Bug
Bug description:A stdClass shouldn't allow invalid proprieties names.

Description:
------------
A stdClass shouldn't allow invalid proprieties names.

Numbers are not valid propriety name.

$object = new stdClass();
$object->0 = 1; //This is invalid
$object->{"\0"} = 1; //This is valid, why???

Test script:
---------------
<?php

$data = array( 'a', 'asdas' => 2312 );

print_r( (object) $data );

Expected result:
----------------
stdClass Object
(
    [asdas] => 2312
)

Actual result:
--------------
stdClass Object
(
    [0] => a
    [asdas] => 2312
)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=68186&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68186&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68186&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68186&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68186&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68186&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68186&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68186&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68186&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68186&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68186&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68186&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68186&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68186&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68186&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68186&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68186&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68186&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68186&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68186&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68186&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#187955) next »