|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52227 parse_ini_* does not parse namespaced constants
Submitted: 2010-07-01 20:58 UTC Modified: 2021-09-10 15:34 UTC
Avg. Score:4.2 ± 0.6
Reproduced:8 of 9 (88.9%)
Same Version:8 (100.0%)
Same OS:7 (87.5%)
From: wil dot moore at wilmoore dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.3.2 OS: Linux, Mac, Windows
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:
Bug Type:
From: wil dot moore at wilmoore dot com
New email:
PHP Version: OS:


 [2010-07-01 20:58 UTC] wil dot moore at wilmoore dot com
The parse_ini_file/parse_ini_string pair of functions do not expand namespaced constants.

Test script:
namespace my;
const PROJECT_NAME = 'parse_ini_file_namespaced';
$ini = parse_ini_string(<<<EOF
project.constant.namspaced  = my\PROJECT_NAME

Expected result:
array (
  '' => 'parse_ini_file_namespaced',
  'project.constant.namspaced' => 'my\\PROJECT_NAME',

Actual result:
array (
  '' => 'PROJECT_NAME',
  'project.constant.namspaced' => 'my\\PROJECT_NAME',


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-03 15:44 UTC]
-Type: Bug +Type: Feature/Change Request
 [2010-07-03 15:44 UTC]
Changed to feature request.
 [2010-07-04 08:49 UTC] wil dot moore at wilmoore dot com
I disagree with the demotion to "Feature Request". This was submitted as a bug 
due to the following rationale:

1 - The parse_ini_* functions currently support expanding constants.
2 - Namespaces were added as a feature and they include allowing constants to be 
included under a namespace.
3 - Every other usage of a function, class/method, or constant works with the 
namespace implementation, exception for parse_ini_* functions.
4 - A constant is a constant regardless of if it is a global constant, class 
constant, or namespaced constant -- functions that support constants should 
honor each of these variations or at the very least, it should be well-
documented if there is a discrepancy.

Give the above facts, I would say this should remain filed as a bug. If this is 
not a software bug, then this is a documentation bug (error). Either way, it is 
a bug.
 [2021-09-10 15:34 UTC]
Well, bug vs. feature request is secondary here; the bigger issue
is the BC break this change would introduce (especially with your
expected result).  At the very least this should be discussed on
the internals mailing list[1].

[1] <>
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Oct 02 22:05:53 2022 UTC