Req #52297 [Opn->Wfx]: visibility identifier namespace-protected
| From: | aharvey@php.net | Date: | Fri, 16 Jul 2010 05:09:45 +0000 |
| Subject: | Req #52297 [Opn->Wfx]: visibility identifier namespace-protected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152455@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52297&edit=1
ID: 52297
Updated by: aharvey@php.net
Reported by: giorgio dot liscio at email dot it
Summary: visibility identifier namespace-protected
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
Operating System: all
PHP Version: 5.3.2
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2010-07-09 02:56:36] giorgio dot liscio at email dot it
Description:
------------
hi, in php is missing a visibility identifier to protect methods and
properties inside the namespace
example:
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
oci_execute($x);
}
}
----
suggested visibility identifier:
namespace-private
(if namespace is \Test\Abc\ the method/property is only accessible
within \Test\Abc\)
namespace-protected
(if namespace is \Test\Abc\ the method/property can be accessible
within \Test\Abc\ and, for example \Test\Abc\Foo\ )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52297&edit=1