Req #52297 [Com]: visibility identifier namespace-protected
| From: | florent dot biville at insa-rouen dot fr | Date: | Wed, 30 Mar 2011 09:59:53 +0000 |
| Subject: | Req #52297 [Com]: visibility identifier namespace-protected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159843@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: florent dot biville at insa-rouen dot fr
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
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2010-07-16 14:03:25] 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
------------------------------------------------------------------------
[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