php.net |  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
Votes:9
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
 [2010-07-01 20:58 UTC] wil dot moore at wilmoore dot com
Description:
------------
The parse_ini_file/parse_ini_string pair of functions do not expand namespaced constants.

Test script:
---------------
<?php
namespace my;
const PROJECT_NAME = 'parse_ini_file_namespaced';
$ini = parse_ini_string(<<<EOF
[TEST_SECTION]
project.constant.global     = PROJECT_NAME
project.constant.namspaced  = my\PROJECT_NAME
EOF
);
var_export($ini);

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

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-03 15:44 UTC] felipe@php.net
-Type: Bug +Type: Feature/Change Request
 [2010-07-03 15:44 UTC] felipe@php.net
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] cmb@php.net
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] <https://www.php.net/mailing-lists.php#internals>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 08:01:32 2024 UTC