Req #52297 [Com]: visibility identifier namespace-protected
| From: | giorgio dot liscio at email dot it | Date: | Fri, 16 Jul 2010 12:03:26 +0000 |
| Subject: | Req #52297 [Com]: visibility identifier namespace-protected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152476@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
Comment by: giorgio dot liscio at email dot it
Reported by: giorgio dot liscio at email dot it
Summary: visibility identifier namespace-protected
Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
Operating System: all
PHP Version: 5.3.2
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2010-07-16 07:09:44] aharvey@php.net
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-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