php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43046 Introduce constant NAMESPACE_SEPARATOR
Submitted: 2007-10-19 22:21 UTC Modified: 2007-10-20 14:52 UTC
From: lars at strojny dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.3CVS-2007-10-19 (snap) OS: Gentoo Linux
Private report: No CVE-ID: None
 [2007-10-19 22:21 UTC] lars at strojny dot net
Description:
------------
A constant for the namespace separator should be defined. I would propose to define NAMESPACE_SEPARATOR to "::", similiar to DIRECTORY_SEPARATOR.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-19 22:30 UTC] derick@php.net
Why is this useful?
 [2007-10-19 22:32 UTC] lars at strojny dot net
Sorry, wrong version.
 [2007-10-19 22:40 UTC] lars at strojny dot net
Could help to keep a codebase cleaner and better readable. Take a look at:
$path = str_replace('::', DIRECTORY_SEPARATOR, $class_name);
vs.
$path = str_replace(NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, $class_name);
is - in my opinion - easier to understand and better to read.
 [2007-10-19 23:10 UTC] lars at strojny dot net
Sorry, changed summary by accident
 [2007-10-20 14:52 UTC] johannes@php.net
The reason for DIRECTORY_SEPARATOR is that the value is platform dependent, the namespace separator isn't.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 05:01:32 2024 UTC