|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52297 visibility identifier namespace-protected
Submitted: 2010-07-09 02:56 UTC Modified: 2010-07-16 07:09 UTC
Avg. Score:4.6 ± 1.1
Reproduced:14 of 14 (100.0%)
Same Version:10 (71.4%)
Same OS:11 (78.6%)
From: giorgio dot liscio at email dot it Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: 5.3.2 OS: all
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.
Bug Type:
From: giorgio dot liscio at email dot it
New email:
PHP Version: OS:


 [2010-07-09 02:56 UTC] giorgio dot liscio at email dot it
hi, in php is missing a visibility identifier to protect methods and properties inside the namespace


namespace Oracle;  // abstraction layer for Oracle

class Connection
    // ociresource should be visible only in the namespace
    // in php 5.3 the property is public to world
    namespace-protected $ociresource;

    public function __construct()
         $this->ociresource = oci_connect();
    public function query($sql)
         return new Query($this, $sql);

class Query
    public function __construct(Connection $con, $sql)
         $x = oci_parse($con->ociresource, $sql);    // $ociresource is accessible only in this namespace


suggested visibility identifier:

    (if namespace is \Test\Abc\ the method/property is only accessible within \Test\Abc\)
    (if namespace is \Test\Abc\ the method/property can be accessible within \Test\Abc\ and, for example \Test\Abc\Foo\ )


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-16 07:09 UTC]
-Status: Open +Status: Wont fix
 [2010-07-16 07:09 UTC]
PHP namespaces really aren't meant to be anything more than a way of
avoiding name collisions and allowing aliasing -- visibility modifiers
are somewhat beyond the scope of what they're trying to achieve.

If you really want to push this, I'd suggest raising this on the
Internals mailing list (preferably with a prototype patch) with a view
to putting this through the RFC process instead, given it would be a
moderately significant language change.
 [2010-07-16 14:03 UTC] giorgio dot liscio at email dot it
hi aharvey
i really want to contribute but my English is not good
i hope someone want to write an rfc

for anyone reads: feel free to write comments about this
 [2011-03-30 11:59 UTC] florent dot biville at insa-rouen dot fr
I agree such a modifier is necessary.

From an API designer point of view, how would it be possible to distinct API classes/methods from classes/methods needed within (and only within) the framework without this ?

This current limitation leads to unsafe overrides of internal classes/methods.

Since PHP 5.3 now embeds namespaces, this modifier must be available.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Sep 28 03:03:36 2021 UTC