php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64356 \ResourceBundle does not implement ArrayAccess properly
Submitted: 2013-03-05 09:18 UTC Modified: 2013-03-06 04:37 UTC
From: bschussek at gmail dot com Assigned:
Status: Open Package: intl (PECL)
PHP Version: 5.4.12 OS: Ubuntu 12.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bschussek at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-05 09:18 UTC] bschussek at gmail dot com
Description:
------------
Even though \ResourceBundle provides array access, it does not implement the 
\ArrayAccess interface nor allows to call isset() on its entries.

The following resource is necessary for the below test script:

en.txt:
---------------
en{
    Exists{"value"}
}

You need to convert this file to a .res file and place it in the same directory 
as the test script:

> genrb en.txt

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

$bundle = new \ResourceBundle('en', __DIR__);

var_dump($bundle instanceof \ArrayAccess);
var_dump($bundle['Exists']);
var_dump($bundle['ExistsNot']);
var_dump(isset($bundle['ExistsNot']));


Expected result:
----------------
bool(true)
string(5) "value"
NULL
bool(false)

Actual result:
--------------
bool(false)
string(5) "value"
NULL

Fatal error: Cannot use object of type ResourceBundle as array in test.php on 
line 8

Call Stack:
    0.0002     128452   1. {main}() test.php:0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-06 04:37 UTC] laruence@php.net
from the codes, I think it is intentional, change to feature reqeust
 [2013-03-06 04:37 UTC] laruence@php.net
-Type: Bug +Type: Feature/Change Request
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 18:03:37 2021 UTC