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: 2010-07-03 15:44 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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC