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: 2021-11-11 11:16 UTC
From: bschussek at gmail dot com Assigned:
Status: Open Package: I18N and L10N related
PHP Version: 5.4.12 OS: Ubuntu 12.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
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

Pull Requests

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
 [2021-11-11 11:16 UTC] nikic@php.net
-Package: intl +Package: I18N and L10N related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC