|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
19 + 37 = ?
Subscribe to this entry?

 [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 18:03:37 2021 UTC