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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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
 [2021-11-11 11:16 UTC] nikic@php.net
-Package: intl +Package: I18N and L10N related
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Nov 28 11:05:53 2022 UTC