Hi,
I think this proposal has been made before maybe here or discussed
elsewhere. Still, I'd like to give my input on the idea.
The basic concept is when a method has the internal access modifier, it can
only be called from within the same namespace.
The case for this is to protect classes from being used in ways unintended,
while still allowing classes within the same namespace to interact with
each other non-api methods.
I've created a commit:
https://github.com/orolyn/php-src/commit/2ddec7149c308a80b33653da31b5ba214f679bb8
Please forgive any mistakes, it is a proof of concept and just complete
enough to fulfil the feature.
Currently, a limitation is internal methods can only be called from within
another scope in the same namespace, as opposed to outside a class.
For this implementation I needed to store the namespace of the class during
the declaration, so to test that I added the function get_class_namespace
to help me iron out some bugs. I have left the function there.
Thank you,
Dominic
Dominic Grostate wrote on 24/11/2015 12:14:
I think this proposal has been made before maybe here or discussed
elsewhere. Still, I'd like to give my input on the idea.
There have indeed been a couple of discussions of this recently. Try
searching for threads on a list archive using terms such as "package
visibility", "namespace visibility", "private class", and the related
notion of "friend class" / "friend function".
I wonder if we should maintain a Usenet-style FAQ for this list, to make
it easier to find what has previously been discussed on a topic.
Regards,
Rowan Collins
[IMSoP]
Dominic Grostate wrote on 24/11/2015 12:14: > I think this proposal has
been made before maybe here or discussed > elsewhere. Still, I'd like to
give my input on the idea. There have indeed been a couple of discussions
of this recently. Try searching for threads on a list archive using terms
such as "package visibility", "namespace visibility", "private class", and
the related notion of "friend class" / "friend function". I wonder if we
should maintain a Usenet-style FAQ for this list, to make it easier to find
what has previously been discussed on a topic. Regards, -- Rowan Collins
[IMSoP]
Ah yes, I've seen them in the request bugs.
https://bugs.php.net/bug.php?id=52297
It was suggested that a prototype be made, I have provided one, and it
should pass basic demos. I just didn't want to take it further than that
unless it generate some interest.
Dominic Grostate wrote on 24/11/2015 12:33:
Dominic Grostate wrote on 24/11/2015 12:14: > I think this proposal
has been made before maybe here or discussed > elsewhere. Still, I'd
like to give my input on the idea. There have indeed been a couple of
discussions of this recently. Try searching for threads on a list
archive using terms such as "package visibility", "namespace
visibility", "private class", and the related notion of "friend class"
/ "friend function". I wonder if we should maintain a Usenet-style FAQ
for this list, to make it easier to find what has previously been
discussed on a topic. Regards, -- Rowan Collins [IMSoP]Ah yes, I've seen them in the request bugs.
https://bugs.php.net/bug.php?id=52297It was suggested that a prototype be made, I have provided one, and it
should pass basic demos. I just didn't want to take it further than
that unless it generate some interest.
I was thinking more of recent threads on this list, such as these:
http://marc.info/?l=php-internals&m=144608749903477&w=2
http://marc.info/?t=144720154700001&r=1&w=2
http://marc.info/?t=144639397900001&r=1&w=2
There are probably more if you search around, and a couple of people do
seem to be working on prototypes.
Regards,
Rowan Collins
[IMSoP]